[
  {
    "path": ".gitattributes",
    "content": ".gitattributes export-ignore\n.gitignore export-ignore\n* text=auto eol=lf\nvendor/** linguist-vendored\n\n# generated files\nsrc/lexer.[ch] linguist-generated=true\nsrc/parser.[ch] linguist-generated=true\ntests/man.test linguist-generated=true\ntests/manonig.test linguist-generated=true\njq.1.prebuilt linguist-generated=true\ndocs/Pipfile.lock linguist-generated=true\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "content": "---\nname: Bug report\nabout: Create a report to help us improve\n\n---\n\n<!--\nREAD THIS FIRST!\n\nIf you have a usage question, please ask us on [Stack Overflow](https://stackoverflow.com/questions/tagged/jq), in the [#jq channel](https://web.libera.chat/#jq) on [Libera.Chat](https://libera.chat/), or in our [Discord server](https://discord.gg/yg6yjNmgAC).\n\n-->\n\n**Describe the bug**\nA clear and concise description of what the bug is.\n\n**To Reproduce**\nProvide a minimal test case to reproduce the behavior.\nIf the input is large, either attach it as a file, or [create a gist](https://gist.github.com) and link to it here.\n\n**Expected behavior**\nA clear and concise description of what you expected to happen.\n\n**Environment (please complete the following information):**\n\n- OS and Version: [e.g. macOS, Windows, Linux (please specify distro)]\n- jq version [e.g. 1.5]\n\n**Additional context**\nAdd any other context about the problem here.\n"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "version: 2\nupdates:\n  - package-ecosystem: \"pip\"\n    directory: \"docs/\"\n    schedule:\n      interval: \"monthly\"\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      interval: \"weekly\"\n    groups:\n      official-actions:\n        patterns: [\"actions/*\"]\n      docker-actions:\n        patterns: [\"docker/*\"]\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: CI\non:\n  push:\n    branches:\n      - master\n    tags:\n      - \"jq-*\"\n  pull_request:\n\njobs:\n  linux:\n    strategy:\n      fail-fast: false\n      matrix:\n        arch:\n          - amd64\n          - arm64\n          - armel\n          - armhf\n          - i386\n          - mips\n          - mips64\n          - mips64el\n          - mips64r6\n          - mips64r6el\n          - mipsel\n          - mipsr6\n          - mipsr6el\n          - powerpc\n          - ppc64el\n          - riscv64\n          - s390x\n        include:\n          - arch: amd64\n            CC: x86_64-linux-gnu\n          - arch: arm64\n            CC: aarch64-linux-gnu\n          - arch: armel\n            CC: arm-linux-gnueabi\n          - arch: armhf\n            CC: arm-linux-gnueabihf\n          - arch: i386\n            CC: i686-linux-gnu\n          - arch: mips\n            CC: mips-linux-gnu\n          - arch: mips64\n            CC: mips64-linux-gnuabi64\n          - arch: mips64el\n            CC: mips64el-linux-gnuabi64\n          - arch: mips64r6\n            CC: mipsisa64r6-linux-gnuabi64\n          - arch: mips64r6el\n            CC: mipsisa64r6el-linux-gnuabi64\n          - arch: mipsel\n            CC: mipsel-linux-gnu\n          - arch: mipsr6\n            CC: mipsisa32r6-linux-gnu\n          - arch: mipsr6el\n            CC: mipsisa32r6el-linux-gnu\n          - arch: powerpc\n            CC: powerpc-linux-gnu\n          - arch: ppc64el\n            CC: powerpc64le-linux-gnu\n          - arch: riscv64\n            CC: riscv64-linux-gnu\n          - arch: s390x\n            CC: s390x-linux-gnu\n    runs-on: ${{ matrix.arch == 'i386' && 'ubuntu-22.04' || 'ubuntu-24.04' }}\n    env:\n      AR: ${{ matrix.CC }}-ar\n      CHOST: ${{ matrix.CC }}\n      CC: ${{ matrix.CC }}-gcc\n      CPP: ${{ matrix.CC }}-cpp\n      LDFLAGS: -s\n      SUFFIX: linux-${{ matrix.arch }}\n    steps:\n      - name: Clone repository\n        uses: actions/checkout@v6\n        with:\n          submodules: true\n      - name: Install packages\n        run: |\n          sudo apt-get update\n          sudo apt-get install -y automake autoconf libtool crossbuild-essential-${{ matrix.arch }}\n      - name: Build\n        run: |\n          autoreconf -i\n          ./configure \\\n            --host=${{ matrix.CC }} \\\n            --disable-docs \\\n            --with-oniguruma=builtin \\\n            --enable-static \\\n            --enable-all-static \\\n            CFLAGS=\"-O2 -pthread -fstack-protector-all\"\n          make -j\"$(nproc)\"\n          file ./jq\n          cp ./jq jq-${{ env.SUFFIX }}\n      - name: Test\n        # Only run tests for amd64 matching the CI machine arch\n        if: ${{ matrix.arch == 'amd64' }}\n        run: |\n          make check VERBOSE=yes\n          git diff --exit-code\n      - name: Upload Test Logs\n        if: ${{ failure() }}\n        uses: actions/upload-artifact@v7\n        with:\n          name: test-logs-${{ env.SUFFIX }}\n          retention-days: 7\n          path: |\n            test-suite.log\n            tests/*.log\n      - name: Upload artifacts\n        uses: actions/upload-artifact@v7\n        with:\n          name: jq-${{ env.SUFFIX }}\n          path: jq-${{ env.SUFFIX }}\n          if-no-files-found: error\n          retention-days: 7\n\n  macos:\n    strategy:\n      fail-fast: false\n      matrix:\n        arch:\n          - amd64\n          - arm64\n        include:\n          - arch: amd64\n            target: x86_64-apple-darwin\n          - arch: arm64\n            target: arm64-apple-darwin\n    runs-on: macos-14\n    env:\n      LDFLAGS: -dead_strip\n      SUFFIX: macos-${{ matrix.arch }}\n    steps:\n      - name: Clone repository\n        uses: actions/checkout@v6\n        with:\n          submodules: true\n      - name: Install packages\n        run: |\n          # brew update sometimes fails with \"Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!\"\n          brew update || brew update-reset\n          brew install autoconf automake libtool\n      - name: Set CC\n        run: |\n          echo \"CC=clang -target ${{ matrix.target }}$(uname -r)\" >> \"$GITHUB_ENV\"\n      - name: Build\n        run: |\n          autoreconf -i\n          ./configure \\\n            --host=\"${{ matrix.target }}$(uname -r)\" \\\n            --disable-docs \\\n            --with-oniguruma=builtin \\\n            --disable-shared \\\n            --enable-static \\\n            --enable-all-static \\\n            CFLAGS=\"-O2 -pthread -fstack-protector-all\"\n          make -j\"$(sysctl -n hw.logicalcpu)\"\n          strip ./jq\n          file ./jq\n          cp ./jq jq-${{ env.SUFFIX }}\n      - name: Test\n        run: |\n          make check VERBOSE=yes\n          git diff --exit-code\n      - name: Upload Test Logs\n        if: ${{ failure() }}\n        uses: actions/upload-artifact@v7\n        with:\n          name: test-logs-${{ env.SUFFIX }}\n          retention-days: 7\n          path: |\n            test-suite.log\n            tests/*.log\n      - name: Upload artifacts\n        uses: actions/upload-artifact@v7\n        with:\n          name: jq-${{ env.SUFFIX }}\n          path: jq-${{ env.SUFFIX }}\n          if-no-files-found: error\n          retention-days: 7\n\n  windows:\n    strategy:\n      fail-fast: false\n      matrix:\n        arch:\n          - amd64\n          - i386\n          - arm64\n        include:\n          - arch: amd64\n            msystem: UCRT64\n            os: windows-2022\n          - arch: i386\n            msystem: MINGW32\n            os: windows-2022\n          - arch: arm64\n            msystem: CLANGARM64\n            os: windows-11-arm\n    runs-on: ${{ matrix.os }}\n    env:\n      LDFLAGS: -s\n      SUFFIX: windows-${{ matrix.arch }}\n    defaults:\n      run:\n        shell: msys2 {0}\n    steps:\n      - name: Prepare git config\n        run: git config --system core.autocrlf false\n        shell: bash\n      - name: Clone repository\n        uses: actions/checkout@v6\n        with:\n          submodules: true\n      - uses: msys2/setup-msys2@v2\n        with:\n          update: true\n          msystem: ${{ matrix.msystem }}\n          install: >-\n            base-devel\n            git\n            autoconf\n            automake\n            libtool\n          pacboy: >-\n            toolchain:p\n      - name: Build\n        run: |\n          autoreconf -i\n          ./configure \\\n            --disable-docs \\\n            --with-oniguruma=builtin \\\n            --disable-shared \\\n            --enable-static \\\n            --enable-all-static \\\n            CFLAGS=\"-O2 -pthread -fstack-protector-all -Wl,--stack,8388608\"\n          make -j$(nproc)\n          file ./jq.exe\n          cp ./jq.exe jq-${{ env.SUFFIX }}.exe\n      - name: Test\n        run: |\n          make check VERBOSE=yes\n          git diff --exit-code\n      - name: Upload Test Logs\n        if: ${{ failure() }}\n        uses: actions/upload-artifact@v7\n        with:\n          name: test-logs-${{ env.SUFFIX }}\n          retention-days: 7\n          path: |\n            test-suite.log\n            tests/*.log\n      - name: Upload artifacts\n        uses: actions/upload-artifact@v7\n        with:\n          name: jq-${{ env.SUFFIX }}\n          path: jq-${{ env.SUFFIX }}.exe\n          if-no-files-found: error\n          retention-days: 7\n\n  dist:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Clone repository\n        uses: actions/checkout@v6\n        with:\n          submodules: true\n      - name: Install packages\n        run: |\n          sudo apt-get update -qq\n          sudo apt-get install -y automake autoconf\n      - name: Create dist\n        run: |\n          autoreconf -i\n          ./configure \\\n            --disable-docs \\\n            --with-oniguruma=builtin\n          make distcheck\n          make dist dist-zip\n          git diff --exit-code\n      - name: Upload artifacts\n        uses: actions/upload-artifact@v7\n        with:\n          name: jq-dist\n          if-no-files-found: error\n          retention-days: 7\n          path: |\n            jq-*.tar.gz\n            jq-*.zip\n\n  docker:\n    runs-on: ubuntu-latest\n    permissions:\n      id-token: write\n      contents: read\n      attestations: write\n      packages: write\n    needs: linux\n    steps:\n      - name: Clone repository\n        uses: actions/checkout@v6\n      - name: Download executables\n        uses: actions/download-artifact@v8\n        with:\n          pattern: jq-linux-*\n          merge-multiple: true\n      - name: Move executables\n        run: |\n          mkdir -p linux/{386,amd64,arm64,arm/v7,mips64le,ppc64le,riscv64,s390x}\n          chmod +x jq-linux-*\n          mv jq-linux-i386 linux/386/jq\n          mv jq-linux-amd64 linux/amd64/jq\n          mv jq-linux-arm64 linux/arm64/jq\n          mv jq-linux-armhf linux/arm/v7/jq\n          mv jq-linux-mips64el linux/mips64le/jq\n          mv jq-linux-ppc64el linux/ppc64le/jq\n          mv jq-linux-riscv64 linux/riscv64/jq\n          mv jq-linux-s390x linux/s390x/jq\n      - name: Create Dockerfile\n        run: |\n          cat <<'EOF' >Dockerfile\n          FROM scratch\n          ARG TARGETPLATFORM\n          COPY AUTHORS COPYING $TARGETPLATFORM/jq /\n          RUN [\"/jq\", \"--version\"]\n          ENTRYPOINT [\"/jq\"]\n          EOF\n      - name: Docker metadata\n        uses: docker/metadata-action@v6\n        id: metadata\n        with:\n          images: ghcr.io/${{ github.repository }}\n          tags: >\n            ${{ startsWith(github.ref, 'refs/tags/jq-')\n            && format('type=match,pattern=jq-(.*),group=1,value={0}', github.ref_name)\n            || 'type=sha,format=long' }}\n      - name: Set up QEMU\n        uses: docker/setup-qemu-action@v4\n      - name: Set up Docker Buildx\n        uses: docker/setup-buildx-action@v4\n      - name: Login to GitHub Container Registry\n        uses: docker/login-action@v4\n        with:\n          registry: ghcr.io\n          username: ${{ github.repository_owner }}\n          password: ${{ secrets.GITHUB_TOKEN }}\n      - name: Build and release Docker image\n        uses: docker/build-push-action@v7\n        id: build-push\n        with:\n          context: .\n          push: ${{ startsWith(github.ref, 'refs/tags/jq-') }}\n          provenance: false\n          platforms: linux/386,linux/amd64,linux/arm64,linux/arm/v7,linux/mips64le,linux/ppc64le,linux/riscv64,linux/s390x\n          tags: ${{ steps.metadata.outputs.tags }}\n          labels: ${{ steps.metadata.outputs.labels }}\n      - name: Generate signed attestations\n        if: startsWith(github.ref, 'refs/tags/jq-')\n        uses: actions/attest@v4\n        with:\n          subject-name: ghcr.io/${{ github.repository }}\n          subject-digest: ${{ steps.build-push.outputs.digest }}\n          push-to-registry: true\n\n  release:\n    runs-on: ubuntu-latest\n    permissions:\n      contents: write\n      id-token: write\n      attestations: write\n      pull-requests: write\n    environment: release\n    needs: [linux, macos, windows, dist, docker]\n    if: startsWith(github.ref, 'refs/tags/jq-')\n    steps:\n      - name: Clone repository\n        uses: actions/checkout@v6\n      - name: Download artifacts\n        uses: actions/download-artifact@v8\n        with:\n          pattern: jq-*\n          merge-multiple: true\n      - name: Upload release\n        env:\n          TAG_NAME: ${{ github.ref_name }}\n          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        run: |\n          cp jq-linux-amd64 jq-linux64\n          cp jq-macos-amd64 jq-osx-amd64\n          cp jq-windows-amd64.exe jq-win64.exe\n          sha256sum jq-* > sha256sum.txt\n          gh release create \"$TAG_NAME\" --draft --title \"jq ${TAG_NAME#jq-}\" --generate-notes\n          gh release upload \"$TAG_NAME\" --clobber jq-* sha256sum.txt\n      - name: Generate signed attestations\n        uses: actions/attest@v4\n        with:\n          subject-path: jq-*\n      - name: Import GPG key\n        uses: crazy-max/ghaction-import-gpg@v7\n        with:\n          gpg_private_key: ${{ secrets.JQ_RELEASE_GPG_PRIVATE_KEY }}\n          passphrase: ${{ secrets.JQ_RELEASE_GPG_PASSPHRASE }}\n      - name: Update signatures\n        env:\n          TAG_NAME: ${{ github.ref_name }}\n          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        run: |\n          sig_dir=\"sig/v${TAG_NAME#jq-}\"\n          mkdir -p \"$sig_dir\"\n          mv sha256sum.txt \"$sig_dir\"\n          for file in jq-*; do\n            gpg --detach-sign --armor --batch --output \"${sig_dir}/${file#*/}.asc\" \"$file\"\n          done\n          git add sig\n          git config user.name 'github-actions[bot]'\n          git config user.email 'github-actions[bot]@users.noreply.github.com'\n          title=\"Update signatures of ${TAG_NAME#jq-}\"\n          git commit -m \"$title\"\n          branch=\"update-signatures-${TAG_NAME#jq-}\"\n          git push origin \"HEAD:refs/heads/$branch\"\n          gh pr create --title \"$title\" --body \"\" --head \"$branch\"\n"
  },
  {
    "path": ".github/workflows/decnum.yml",
    "content": "name: decnum\non:\n  push:\n    branches:\n      - master\n  pull_request:\n\njobs:\n  disabled:\n    runs-on: ubuntu-24.04\n    steps:\n      - name: Clone repository\n        uses: actions/checkout@v6\n        with:\n          submodules: true\n      - name: Install packages\n        run: |\n          sudo apt-get update\n          sudo apt-get install -y automake autoconf libtool\n      - name: Build\n        run: |\n          autoreconf -i\n          ./configure \\\n            --disable-docs \\\n            --disable-maintainer-mode \\\n            --disable-decnum\n          make -j\"$(nproc)\"\n          file ./jq\n      - name: Test\n        run: |\n          diff <(echo 100000000000000000000 | ./jq) <(echo 1e+20)\n          make check VERBOSE=yes\n          git diff --exit-code\n      - name: Upload Test Logs\n        if: ${{ failure() }}\n        uses: actions/upload-artifact@v7\n        with:\n          name: test-logs-decnum-disabled\n          retention-days: 7\n          path: |\n            test-suite.log\n            tests/*.log\n"
  },
  {
    "path": ".github/workflows/manpage.yml",
    "content": "name: Building man page, man.test, manonig.test\non:\n  push:\n    paths:\n      - '.github/workflows/manpage.yml'\n      - 'docs/**'\n      - 'tests/man.test'\n      - 'tests/manonig.test'\n      - 'jq.1.prebuilt'\n  pull_request:\n    paths:\n      - '.github/workflows/manpage.yml'\n      - 'docs/**'\n      - 'tests/man.test'\n      - 'tests/manonig.test'\n      - 'jq.1.prebuilt'\n\njobs:\n  manpages:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v6\n      - name: Setup Python\n        uses: actions/setup-python@v6\n        with:\n          python-version: '3.11'\n          cache: pipenv\n      - name: Install pipenv\n        run: pip install pipenv\n      - name: Install dependencies\n        run: pipenv sync\n        working-directory: docs\n      - name: Validate manual schema\n        run: pipenv run python3 validate_manual_schema.py content/manual/**/*.yml\n        working-directory: docs\n      - name: Configure\n        run: |\n          autoreconf -i\n          ./configure --enable-docs\n      - name: Build man page, man.test, manonig.test\n        run: |\n          mv jq.1.prebuilt jq.1.old\n          rm -f tests/man.test manonig.test\n          make jq.1.prebuilt tests/man.test tests/manonig.test\n      - name: Make sure that jq.1.prebuilt, man.test, manonig.test are up to date\n        run: |\n          git diff --exit-code tests/man.test tests/manonig.test\n          # skip build date in jq.1.prebuilt\n          test -s jq.1.prebuilt\n          diff -- <(tail -n +3 jq.1.old) <(tail -n +3 jq.1.prebuilt)\n"
  },
  {
    "path": ".github/workflows/oniguruma.yml",
    "content": "name: oniguruma\non:\n  push:\n    branches:\n      - master\n  pull_request:\n\n# Since builtin oniguruma is tested in the CI workflow,\n# we test other options for --with-oniguruma here.\njobs:\n  installed:\n    runs-on: ubuntu-24.04\n    steps:\n      - name: Clone repository\n        uses: actions/checkout@v6\n      - name: Install packages\n        run: |\n          sudo apt-get update\n          sudo apt-get install -y automake autoconf libtool valgrind libonig-dev\n      - name: Build\n        run: |\n          autoreconf -i\n          ./configure \\\n            --disable-docs \\\n            --enable-valgrind \\\n            --with-oniguruma=yes\n          make -j\"$(nproc)\"\n          file ./jq\n      - name: Test\n        run: |\n          ./jq -n '\"\" | test(\"\")'\n          make check VERBOSE=yes\n          git diff --exit-code\n      - name: Upload Test Logs\n        if: ${{ failure() }}\n        uses: actions/upload-artifact@v7\n        with:\n          name: test-logs-oniguruma-installed\n          retention-days: 7\n          path: |\n            test-suite.log\n            tests/*.log\n\n  disabled:\n    runs-on: ubuntu-24.04\n    steps:\n      - name: Clone repository\n        uses: actions/checkout@v6\n      - name: Install packages\n        run: |\n          sudo apt-get update\n          sudo apt-get install -y automake autoconf libtool valgrind\n      - name: Build\n        run: |\n          autoreconf -i\n          ./configure \\\n            --disable-docs \\\n            --enable-valgrind \\\n            --with-oniguruma=no\n          make -j\"$(nproc)\"\n          file ./jq\n      - name: Test\n        run: |\n          ! ./jq -n '\"\" | test(\"\")'\n          make check VERBOSE=yes\n          git diff --exit-code\n      - name: Upload Test Logs\n        if: ${{ failure() }}\n        uses: actions/upload-artifact@v7\n        with:\n          name: test-logs-oniguruma-disabled\n          retention-days: 7\n          path: |\n            test-suite.log\n            tests/*.log\n"
  },
  {
    "path": ".github/workflows/scanbuild.yml",
    "content": "name: Clang scan-build Static Analyzer Build\n\non:\n  push:\n    branches:\n      - master\n\njobs:\n  scan-build:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Clone repository\n        uses: actions/checkout@v6\n        with:\n          submodules: true\n      - name: Install packages\n        run: |\n          sudo apt-get update -qq\n          sudo apt-get install -y automake autoconf gdb valgrind clang clang-tools\n          echo \"CC=clang\" >> \"$GITHUB_ENV\"\n      - name: Build\n        run: |\n          autoreconf -i\n          ./configure --enable-valgrind CFLAGS=\"-g -O0\"\n          scan-build --keep-going --exclude vendor/ make -j\"$(nproc)\"\n      - name: Test\n        run: |\n          ulimit -c unlimited\n          scan-build --keep-going --exclude vendor/ make -j\"$(nproc)\" check\n      - name: Core dump stacks\n        run: |\n          if [[ -f core ]]; then\n            gdb -batch -ex \"thread apply all bt\" \\\n              \"$(file core | sed \"s/^[^']*'//; s/[ '].*$//\")\" core\n            exit 1\n          fi\n      - name: Test logs\n        if: ${{ failure() }}\n        run: |\n          cat test-suite.log tests/*.log\n      - name: Upload Logs\n        uses: actions/upload-artifact@v7\n        with:\n          name: Scan-Build Reports\n          path: /tmp/scan-build*\n          if-no-files-found: ignore\n          retention-days: 7\n"
  },
  {
    "path": ".github/workflows/valgrind.yml",
    "content": "name: valgrind\non:\n  push:\n    branches:\n      - master\n  pull_request:\n\njobs:\n  linux:\n    runs-on: ubuntu-24.04\n    steps:\n      - name: Clone repository\n        uses: actions/checkout@v6\n        with:\n          submodules: true\n      - name: Install packages\n        run: |\n          sudo apt-get update\n          sudo apt-get install -y automake autoconf libtool valgrind\n      - name: Build\n        run: |\n          autoreconf -i\n          ./configure \\\n            --disable-docs \\\n            --enable-valgrind \\\n            --with-oniguruma=builtin\n          make -j\"$(nproc)\"\n          file ./jq\n      - name: Test\n        run: |\n          make check VERBOSE=yes\n          git diff --exit-code\n      - name: Upload Test Logs\n        if: ${{ failure() }}\n        uses: actions/upload-artifact@v7\n        with:\n          name: test-logs-valgrind-linux\n          retention-days: 7\n          path: |\n            test-suite.log\n            tests/*.log\n"
  },
  {
    "path": ".github/workflows/website.yml",
    "content": "name: Update website\non:\n  push:\n    branches:\n      - master\n    paths:\n      - 'docs/**'\nconcurrency: website\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    defaults:\n      run:\n        working-directory: docs\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v6\n      - name: Setup Python\n        uses: actions/setup-python@v6\n        with:\n          python-version: '3.11'\n          cache: pipenv\n      - name: Install pipenv\n        run: pip install pipenv\n      - name: Install dependencies\n        run: pipenv sync\n      - name: Build website\n        run: pipenv run python3 build_website.py\n      - name: Upload pages artifact\n        uses: actions/upload-pages-artifact@v4\n        with:\n          path: docs/output/\n\n  deploy:\n    needs: build\n    permissions:\n      pages: write\n      id-token: write\n    environment:\n      name: github-pages\n      url: ${{ steps.deployment.outputs.page_url }}\n    runs-on: ubuntu-latest\n    steps:\n      - name: Deploy to GitHub Pages\n        uses: actions/deploy-pages@v4\n        id: deployment\n"
  },
  {
    "path": ".gitignore",
    "content": "*.o\n*.a\n*.lo\n*.la\n*.lai\n*.so\n*.so.*\n*.gcda\n*.gcno\n*.gcov\n*~\n.*.sw[a-p]\ntags\n\njq\n!tests/modules/lib/jq/\njq.1\n\n# Generated source\nsrc/builtin.inc\nsrc/config_opts.inc\n*.pc\n\n# Autotools junk\n.libs\n.deps\n.dirstamp\nlibtool\n*.log\nstamp-h1\nconfig.log\nconfig.status\nautom4te.cache\nconfdefs.h\nconftest*\nINSTALL\nMakefile\njq-*.tar.gz\njq-*.zip\nconfigure\naclocal.m4\nMakefile.in\nversion.h\n.remake-version-h\nconfig.cache\n*.rpm\nm4/libtool.m4\nm4/ltoptions.m4\nm4/ltsugar.m4\nm4/ltversion.m4\nm4/lt~obsolete.m4\ntests/*.trs\n\n# Docs output\ndocs/output\n\ncscope.in.out\ncscope.out\ncscope.po.out\njq.dSYM\n"
  },
  {
    "path": ".gitmodules",
    "content": "[submodule \"vendor/oniguruma\"]\n\tpath = vendor/oniguruma\n\turl = https://github.com/kkos/oniguruma.git\n"
  },
  {
    "path": "AUTHORS",
    "content": "Created By:\nStephen Dolan        <mu@netsoc.tcd.ie>\n\nMaintained by:\nDavid Tolnay         <dtolnay@gmail.com>\nEmanuele Torre       <torreemanuele6@gmail.com>\nLeonid S. Usov       <leonid@practi.net>\nMattias Wadman       <mattias.wadman@gmail.com>\nMuh Muhten           <muh.muhten@gmail.com>\nNicolas Williams     <nico@cryptonector.com>\nOwen Ou              <o@owenou.com>\nWilliam Langford     <wlangfor@gmail.com>\nitchyny              <itchyny@cybozu.co.jp>\npkoppstein           <pkoppstein@gmail.com>\n\nContributions by:\n13ren                <melbourne.research@gmail.com>\nAJ Jordan            <alex@strugee.net>\nAaron Peschel        <apeschel@zendesk.com>\nAdam Lindberg        <hello@alind.io>\nAlanscut             <wp_scut@163.com>\nAleksey Tsalolikhin  <atsalolikhin@spokeo.com>\nAlex Chamberlain     <alex@alexchamberlain.co.uk>\nAlex Jurkiewicz      <alex@jurkiewi.cz>\nAlex Ozdemir         <aozdemir@hmc.edu>\nAlex Wilson          <gpg@probablyfine.co.uk>\nAlexandre Jasmin     <ajasmin@transtex-llc.com>\nAllan Clark          <allanc@chickenandporn.com>\nAndreas Heiduk       <asheiduk@users.noreply.github.com>\nAndrew O'Brien       <obrien.andrew@gmail.com>\nAndrew Rodland       <andrew@cleverdomain.org>\nAndrew Speed         <andrew.cspeed@gmail.com>\nAndy Lester          <andy@petdance.com>\nAnkur                <ankz.kothari@gmail.com>\nAnthony Shortland    <anthony@dtosolutions.com>\nAnthony Sottile      <asottile@umich.edu>\nAssaf Gordon         <assafgordon@gmail.com>\nAttila Fülöp         <attila@fueloep.org>\nBenjamin Wuethrich   <benjamin@koho.ca>\nBenoit de Chezelles  <bew@users.noreply.github.com>\nBernard Niset        <bernard.niset@gmail.com>\nBhargava Mummadireddy <kishoreinvits@gmail.com>\nBinbin Qian          <qianbinbin@hotmail.com>\nBradley Skaggs       <bskaggs@acm.org>\nBrahm Lower          <bplower@gmail.com>\nBrendan Macmillan    <melbourne.research@gmail.com>\nCameron Sparr        <cameronsparr@gmail.com>\nChance Zibolski      <czibolsk@redhat.com>\nCharles Merriam      <charles.merriam@gmail.com>\nChris LaRose         <cjlarose@gmail.com>\nChris Moore          <dooglus@gmail.com>\nChristoph Anton Mitterer <calestyo@scientia.org>\nChristopher Degawa   <ccom@randomderp.com>\nCiaran McNamara      <1372986+ciaranmcnamara@users.noreply.github.com>\nClément MATHIEU      <clement@unportant.info>\nColin Leroy-Mira     <colin@colino.net>\nColin von Heuring    <colin@janrain.com>\nDag-Erling Smørgrav  <des@des.no>\nDamian Gryski        <damian@gryski.com>\nDan Church           <h3xx@users.noreply.github.com>\nDaniel Lange         <DLange@git.local>\nDavid Biesack        <David.Biesack@apiture.com>\nDavid Fetter         <david@fetter.org>\nDavid Haguenauer     <ml@kurokatta.org>\nDavid Korczynski     <david@adalogics.com>\nDavid R. MacIver     <david@drmaciver.com>\nDavidKorczynski      <david@adalogics.com>\nDawid Ferenczy Rogožan <ferenczy@users.noreply.github.com>\nDerrick Pallas       <derrick@pallas.us>\nDoug Luce            <doug@github.con.com>\nEiichi Sato          <sato.eiichi@gmail.com>\nEli Schwartz         <eschwartz@archlinux.org>\nEloy Coto            <eloy.coto@gmail.com>\nEric Bréchemier      <eric@egull.co>\nErik Brinkman        <erik.brinkman@gmail.com>\nEugen                <EugenGez@gmail.com>\nEvan Zacks           <zackse@gmail.com>\nFabian Dellwing      <fabian.dellwing@mbconnectline.de>\nFelix Wolfsteller    <felix.wolfsteller@gmail.com>\nFilippo Giunchedi    <fgiunchedi@gmail.com>\nFilippo Valsorda     <filippo.valsorda@gmail.com>\nFlorian Weimer       <fweimer@redhat.com>\nFrederic Cambus      <fcambus@users.sourceforge.net>\nGabriel Marin        <gbrlmarn@gmail.com>\nGaelan Steele        <gbs@canishe.com>\nGeorge Hopkins       <george-hopkins@null.net>\nGert Van Gool        <gertvangool@gmail.com>\nGijs Kunze           <gwkunze@gmail.com>\nGustav               <gustav@invoke.se>\nHE, Tao              <sighingnow@gmail.com>\nHan Jiang            <jhcarl0814@gmail.com>\nHanfei Shen          <qqshfox@gmail.com>\nHanson Char          <hanson.char@gmail.com>\nHaochen Xie          <haochenx@acm.org>\nHelmut K. C. Tessarek <tessarek@evermeet.cx>\nHenré Botha          <henrebotha@gmail.com>\nIan Miell            <ian.miell@gmail.com>\nIkko Ashimine        <eltociear@gmail.com>\nJ Phani Mahesh       <github@phanimahesh.me>\nJ. B. Rainsberger    <me@jbrains.ca>\nJack Pearkes         <jackpearkes@gmail.com>\nJakub Jirutka        <jakub@jirutka.cz>\nJakub Wilk           <jwilk@jwilk.net>\nJames Andariese      <james.andariese@locationlabs.com>\nJames Pearson Hughes <xiong.chiamiov@gmail.com>\nJan Schulz           <jasc@gmx.net>\nJanne Cederberg      <janne.cederberg@gmail.com>\nJason Hood           <jadoxa@yahoo.com.au>\nJay Satiro           <raysatiro@yahoo.com>\nJesper Rønn-Jensen   <jesperrr@gmail.com>\nJingwen Owen Ou      <jingweno@gmail.com>\nJoe Littlejohn       <joe.littlejohn@nokia.com>\nJoel Nothman         <joel.nothman@gmail.com>\nJoel Purra           <code+github@joelpurra.com>\nJonathan Chan Kwan Yin <sofe2038@gmail.com>\nJonathan Word        <argoday@argoday.com>\nJosh Soref           <2119212+jsoref@users.noreply.github.com>\nJuan Guerrero        <juan.guerrero.lozano@gmail.com>\nKamontat Chantrachirathumrong <14089557+kamontat@users.noreply.github.com>\nKenny Shen           <kenny.shen@zalora.com>\nKim De Mey           <kim.demey@gmail.com>\nKim Toms             <kim.toms@bplglobal.net>\nKirk McKelvey        <kirkoman@gmail.com>\nKlemens Nanni        <kn@openbsd.org>\nLCD 47               <lcd047@gmail.com>\nLarry Aasen          <larryaasen@gmail.com>\nLee Thompson         <stagr.lee@gmail.com>\nLoamhoof             <soeren.medard@gmail.com>\nLucas Trzesniewski   <lucas.trzesniewski@gmail.com>\nLukas Lansky         <lukas.lansky@suse.com>\nMCApollo             <34170230+MCApollo@users.noreply.github.com>\nMarc Abramowitz      <marc@marc-abramowitz.com>\nMarc Bruggmann       <marcbr@spotify.com>\nMarcin Kłopotek      <marcin.klopotek@gmail.com>\nMarcin Serwin        <marcin@serwin.dev>\nMark Feit            <mfeit@internet2.edu>\nMark McKinstry       <mmckinst@umich.edu>\nMarkus Lanthaler     <mark_lanthaler@gmx.net>\nMatt Clegg           <m@cle.gg>\nMatt Meyers          <matt@mattmeyers.dev>\nMatti Åstrand        <mattiastr@gmail.com>\nMattias Hansson      <hansson.mattias@gmail.com>\nMaxime Biais         <maxime.biais@gmail.com>\nMaximilian Roos      <5635139+max-sixty@users.noreply.github.com>\nMichael Daines       <michael@mdaines.com>\nMichael Färber       <01mf02@gmail.com>\nMike Daines          <mdaines@users.noreply.github.com>\nMike Fletcher        <john.m.fletcher@bankofamerica.com>\nMike McCabe          <mccabe@archive.org>\nNathan Baulch        <nathan.baulch@gmail.com>\nNaïm Favier          <n@monade.li>\nNicolas Pouillard    <nicolas.pouillard@gmail.com>\nNicole Wren          <nicole@wren.systems>\nPaul Chvostek        <paul+gitkraken@it.ca>\nPaul Wise            <pabs3@bonedaddy.net>\nPeter van Dijk       <peter@7bits.nl>\nPhilipp Hagemeister  <phihag@phihag.de>\nRicardo Constantino  <wiiaboo@gmail.com>\nRichard Groves       <richard@noodlfroot.com>\nRichard H Lee        <richard@webdezign.co.uk>\nRiley Avron          <riley.avron@gmail.com>\nRob Wills            <rob.wills@gmail.com>\nRobert Aboukhalil    <robert.aboukhalil@gmail.com>\nRoland C. Dowdeswell <roland.dowdeswell@twosigma.com>\nRoman Inflianskas    <rominf@users.noreply.github.com>\nRomero Malaquias     <romero.malaquias@gmail.com>\nRyoichi KATO         <ryo1kato@gmail.com>\nRémy Léone           <remy.leone@gmail.com>\nSArpnt               <sarpnt@ficial.net>\nSamar Sunkaria       <sameesunkaria@me.com>\nSantiago Lapresta    <santiago.lapresta@gmail.com>\nSean Wei             <me@sean.taipei>\nSebastian Freundt    <freundt@ga-group.nl>\nShaun Guth           <sguth@practicefusion.com>\nShay Elkin           <shay@everything.me>\nSimon Elsbrock       <simon@iodev.org>\nStefan               <stefan.haubenthal@gmail.com>\nStefan Seemayer      <stefan@seemayer.de>\nStephen Roantree     <stroantree@gmail.com>\nStephen Shaw         <stesh@netsoc.tcd.ie>\nSteven Ihde          <sihde@hamachi.us>\nSteven Maude         <StevenMaude@users.noreply.github.com>\nSteven Penny         <svnpenn@gmail.com>\nThalia Archibald     <thalia@archibald.dev>\nTheOdd               <owenhines@protonmail.com>\nThomas Bozeman th026106 <thomas.bozeman@digitalglobe.com>\nThomas R. Hall       <trhall@trhall.org>\nThomas Sibley        <tom@zulutango.org>\nTim McCormack        <cortex@brainonfire.net>\nTimothy John Perisho Eccleston <combinatorist@users.noreply.github.com>\nTom Wolf             <github@incognitox.org>\nTomas Halman         <thalman@redhat.com>\nTravis Gockel        <travis@gockelhut.com>\nTyler Rockwood       <rockwotj@users.noreply.github.com>\nUlrich Eckhardt      <ulrich.eckhardt@base-42.de>\nW-Mark Kubacki       <wmark@hurrikane.de>\nWilliam Chargin      <wchargin@gmail.com>\nYasuhiro Matsumoto   <mattn.jp@gmail.com>\nYeikel               <email@yeikel.com>\nYoichi Nakayama      <yoichi.nakayama@gmail.com>\nZhaohui Mei          <mzh.whut@gmail.com>\nZhiming Wang         <zmwangx@gmail.com>\ncalpeconsulting      <61429736+calpeconsulting@users.noreply.github.com>\ncdnbacon             <mike@busbud.com>\ndak180               <dak180@users.sf.net>\ndavkor               <david@adalogics.com>\ndependabot[bot]      <49699333+dependabot[bot]@users.noreply.github.com>\neitsupi              <50911393+eitsupi@users.noreply.github.com>\nfletcher gornick     <fletcher@gornick.dev>\ngithub-actions[bot]  <41898282+github-actions[bot]@users.noreply.github.com>\ngoodactive           <167312449+goodactive@users.noreply.github.com>\ni                    <isomorphisms@sdf.org>\njkleint              <jkleint@gmail.com>\nlectrical            <14344693+lectrical@users.noreply.github.com>\nliviubobocu          <liviu.bobocu@uipath.com>\nmaflcko              <6399679+maflcko@users.noreply.github.com>\nmail6543210          <mail6543210@yahoo.com.tw>\nmjarosie             <mjarosie@users.noreply.github.com>\nmyaaaaaaaaa          <103326468+myaaaaaaaaa@users.noreply.github.com>\nnmulcahey            <nmulcahey@gmail.com>\norbea                <orbea@riseup.net>\npolyester            <paul@cleanclothes.org>\nrain1                <rain1@airmail.cc>\nriastradh            <campbell+github@mumble.net>\nsachint              <32639496+sachintu47@users.noreply.github.com>\nsheepster            <omer531998@gmail.com>\ntal@whatexit.org     <tal@whatexit.org>\ntaoky                <taoky99@outlook.com>\ntrantor              <trantorvega@gmail.com>\nwellweek             <148746285+wellweek@users.noreply.github.com>\nwllm-rbnt            <william.robinet@conostix.com>\nzstadler             <zeev.stadler@gmail.com>\nнаб                  <nabijaczleweli@nabijaczleweli.xyz>\n엄태용               <lg65438805@gmail.com>\n"
  },
  {
    "path": "COPYING",
    "content": "jq is copyright (C) 2012 Stephen Dolan\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n\njq's documentation (everything found under the docs/ subdirectory in\nthe source tree) is licensed under the Creative Commons CC BY 3.0\nlicense, which can be found at:\n\n         https://creativecommons.org/licenses/by/3.0/\n\nThe documentation website includes a copy of Twitter's Bootstrap and\nrelies on Bonsai, Liquid templates and various other projects, look\nthem up for detailed licensing conditions.\n\n\n\njq incorporates David M. Gay's dtoa.c and g_fmt.c, which bear the\nfollowing notices:\n\ndtoa.c:\nThe author of this software is David M. Gay.\n\nCopyright (c) 1991, 2000, 2001 by Lucent Technologies.\n\nPermission to use, copy, modify, and distribute this software for any\npurpose without fee is hereby granted, provided that this entire notice\nis included in all copies of any software which is or includes a copy\nor modification of this software and in all copies of the supporting\ndocumentation for such software.\n\nTHIS SOFTWARE IS BEING PROVIDED \"AS IS\", WITHOUT ANY EXPRESS OR IMPLIED\nWARRANTY.  IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY\nREPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY\nOF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.\n\ng_fmt.c:\nThe author of this software is David M. Gay.\n\nCopyright (c) 1991, 1996 by Lucent Technologies.\n\nPermission to use, copy, modify, and distribute this software for any\npurpose without fee is hereby granted, provided that this entire notice\nis included in all copies of any software which is or includes a copy\nor modification of this software and in all copies of the supporting\ndocumentation for such software.\n\nTHIS SOFTWARE IS BEING PROVIDED \"AS IS\", WITHOUT ANY EXPRESS OR IMPLIED\nWARRANTY.  IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY\nREPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY\nOF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.\n\n\n\njq uses parts of the open source C library \"decNumber\", which is distributed\nunder the following license:\n\n\nICU License - ICU 1.8.1 and later\n\nCOPYRIGHT AND PERMISSION NOTICE\n\nCopyright (c) 1995-2005 International Business Machines Corporation and others\nAll rights reserved.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, and/or sell copies of the Software, and to permit persons\nto whom the Software is furnished to do so, provided that the above\ncopyright notice(s) and this permission notice appear in all copies of\nthe Software and that both the above copyright notice(s) and this\npermission notice appear in supporting documentation.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\nOF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR\nHOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL\nINDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING\nFROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\nNEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION\nWITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\nExcept as contained in this notice, the name of a copyright holder\nshall not be used in advertising or otherwise to promote the sale, use\nor other dealings in this Software without prior written authorization\nof the copyright holder.\n\n--------------------------------------------------------------------------------\nAll trademarks and registered trademarks mentioned herein are the property of their respective owners.\n\n\n\njv_thread.h is copied from Heimdal's lib/base/heimbase.h and some code\nin jv.c is copied from Heimdal's lib/base/dll.c:\n\n\nPortions Copyright (c) 2016 Kungliga Tekniska Högskolan\n(Royal Institute of Technology, Stockholm, Sweden).\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n1. Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\nFOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\nCOPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\nINDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\nSTRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\nOF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n\njq uses a modified version of NetBSD implementation strptime(),\nwhich is distributed under the following license:\n\nCopyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.\nAll rights reserved.\n\nThis code was contributed to The NetBSD Foundation by Klaus Klein.\nHeavily optimised by David Laight\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n1. Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\nTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "ChangeLog",
    "content": "2015-07-10  Nicolas Williams  nico@cryptonector.com\n\n\tUse `include` for import into namespace\n\n\tSimplify import docs\n\n\tFix typo in docs\n\n2015-07-06  James Andariese  james.andariese@locationlabs.com\n\n\tDockerfile reorganized\n\n2015-07-04  David Tolnay  dtolnay@gmail.com\n\n\tMake jq.h usable from C++\n\n2015-07-03  Nicolas Williams  nico@cryptonector.com\n\n\tDocument math support\n\n2015-06-30  David Tolnay  dtolnay@gmail.com\n\n\tstrftime wrong day-of-week (fix #838)\n\n2015-06-28  Nicolas Williams  nico@cryptonector.com\n\n\tDocument --run-tests\n\n\tMake --run-tests' jv_test() quiet\n\n2015-06-27  Nicolas Williams  nico@cryptonector.com\n\n\tMake --run-tests less verbose by default\n\n\tAdd more basic number tests\n\n\tAdd `pow`, better libm detection (fix #443)\n\n2015-06-27  David Tolnay  dtolnay@gmail.com\n\n\tgcov exclusions\n\n\tflag to enable gcov and coveralls\n\n\tadd configure option to run tests without valgrind\n\n2015-06-20  David Tolnay  dtolnay@gmail.com\n\n\tget Travis CI working\n\n2015-06-26  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `{$var}` `. as {$var}` syntax (fix #831)\n\n\tAdd streaming utilities (fix #827)\n\n2015-06-04  Santiago Lapresta  santiago@typeform.com\n\n\tAdd combinations/0 and combinations/1\n\n2015-06-22  Nicolas Williams  nico@cryptonector.com\n\n\tWriteFile() on WIN32 when stdout isatty (fix #824)\n\n2015-06-19  David Tolnay  dtolnay@gmail.com\n\n\tfix errors flagged by clang static analyzer\n\n2015-06-19  Nicolas Williams  nico@cryptonector.com\n\n\tFix #811: use CommandLineToArgvW() and _wfopen()\n\n2015-06-18  David Tolnay  dtolnay@gmail.com\n\n\tfix use after free in f_strptime\n\n\tseparate jq, oniguruma, sh, and man tests\n\n2015-06-18  Nicolas Williams  nico@cryptonector.com\n\n\targv[] may not be UTF-8 (fix #811)\n\n2015-06-18  Doug Luce  doug@github.con.com\n\n\tAdd alloca() discovery to configure.ac\n\n2015-06-18  Nicolas Williams  nico@cryptonector.com\n\n\tFix `finites`\n\n2015-06-17  David Tolnay  dtolnay@gmail.com\n\n\tfix broken tests in manual.yml\n\n2015-06-17  Nicolas Williams  nico@cryptonector.com\n\n\tAdd isnormal and related, rename *inf\n\n2015-06-17  Nicolas Williams  nico@cryptonector.com\n\n\tFix #814: raise on div-0, add inf isinf nan isnan\n\n2015-06-17  Nicolas Williams  nico@cryptonector.com\n\n\tSequence parser: wait for RS on startup (fix #687)\n\n2015-06-07  David Tolnay  dtolnay@gmail.com\n\n\tarray and object destructuring (fix #533)\n\n2015-06-03  Nicolas Williams  nico@cryptonector.com\n\n\tAdd --tab and -indent n options\n\n2015-05-29  Nicolas Williams  nico@cryptonector.com\n\n\tFixup --slurpfile/argile docs\n\n\tAdd --slurpfile\n\n\tBetter handling of stdout errors\n\n2015-05-25  Nicolas Williams  nico@cryptonector.com\n\n\tAdd ./configure --enable-all-static\n\n2015-05-25  Nicolas Williams  nico@cryptonector.com\n\n\tKeywords should be OK as object keys (fix #794)\n\n2015-03-04  Travis Gockel  travis@gockelhut.com\n\n\tAdd wrapping and clamping to jv_array_slice\n\n2015-04-17  Assaf Gordon  assafgordon@gmail.com\n\n\tPrint offending object in runtime error messages\n\n\tAdd filename/line functions to jq (fix #753)\n\n2015-04-17  Assaf Gordon  assafgordon@gmail.com\n\n\tReport filename:line on runtime errors (fix #752)\n\n2015-05-19  Nicolas Williams  nico@cryptonector.com\n\n\tDocument gsub/3\n\n2015-05-03  Nicolas Williams  nico@cryptonector.com\n\n\tAdd error injection library\n\n2015-04-28  Nicolas Williams  nico@cryptonector.com\n\n\tReport read errors too (and fix #772)\n\n2015-05-02  Nicolas Williams  nico@cryptonector.com\n\n\tREADME: send questions to SO and Freenode\n\n2015-04-28  Nicolas Williams  nico@cryptonector.com\n\n\tusage() should check fprintf() result (fix #771)\n\n2015-04-28  Nicolas Williams  nico@cryptonector.com\n\n\tFix header guards (fix #770)\n\n2015-04-24  Nicolas Williams  nico@cryptonector.com\n\n\t--raw-input wrongly adds NULs (fix #761)\n\n2015-04-23  Nicolas Williams  nico@cryptonector.com\n\n\tWith `inputs` builtin, -n and -R can now coexist\n\n\t--raw-input ought to read NULs (partial fix #760)\n\n\t--slurp --raw-input is broken (fix #761)\n\n\tfrom_entries is broken (fix #767)\n\n2015-04-22  Assaf Gordon  assafgordon@gmail.com\n\n\tregex functions: report informative error if not available.\n\n2015-04-21  Andrew O'Brien  obrien.andrew@gmail.com\n\n\tFixes manual generation with psych\n\n2015-04-20  Assaf Gordon  assafgordon@gmail.com\n\n\tHandle NUL in escaped-string output\n\n2015-04-03  tal@whatexit.org  tal@whatexit.org\n\n\tmanual.yml: Clarify how to specify keys with \":\" and special chars.\n\n2015-04-15  Assaf Gordon  assafgordon@gmail.com\n\n\tdocs: expand @tsv section - add escape sequences.\n\n\t@tsv: escape \\r, \\n, \\\\\n\n2015-03-30  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `$__loc__` (fix #740)\n\n2015-03-29  Nicolas Williams  nico@cryptonector.com\n\n\tInclude filename and lineno in error messages\n\n2015-03-06  Assaf Gordon  assafgordon@gmail.com\n\n\tdetect and report output writing errors\n\n2015-03-18  Santiago Lapresta  santiago.lapresta@gmail.com\n\n\tAdds Dockerfile\n\n2015-03-10  Assaf Gordon  assafgordon@gmail.com\n\n\tpartial handling of input errors\n\n2015-03-09  Assaf Gordon  assafgordon@gmail.com\n\n\talways propagate input errors to exit code\n\n2015-03-23  William Langford  wlangfor@gmail.com\n\n\tFix #735 (SIGFPE on modulo by 0)\n\n2015-03-08  Nicolas Williams  nico@cryptonector.com\n\n\tAdd more date builtins\n\n\tAutomake: jq depends on version.h (fix #721)\n\n2015-03-06  Assaf Gordon  assafgordon@gmail.com\n\n\texit with non-zero code on runtime exceptions\n\n2015-03-06  Nicolas Williams  nico@cryptonector.com\n\n\tAdd date builtins (fix #364)\n\n2015-02-18  Stefan Seemayer  stefan@seemayer.de\n\n\tCorrect automake and autoconf version requirements\n\n2015-02-17  Nicolas Williams  nico@cryptonector.com\n\n\tMention --disable-maintainer-mode in bison error\n\n2015-02-16  Sebastian Freundt  freundt@ga-group.nl\n\n\tFix oniguruma detection logic\n\n2015-02-15  Nicolas Williams  nico@cryptonector.com\n\n\tAdd --disable-maintainer-mode; make bison optional\n\n2015-02-14  Nicolas Williams  nico@cryptonector.com\n\n\tMake Oniguruma/regexp optional\n\n2015-02-01  Nicolas Williams  nico@cryptonector.com\n\n\tRefactor moar: move parts of main.c into libjq\n\n2014-12-27  Nicolas Williams  nico@cryptonector.com\n\n\tRefactor handling of inputs in main() (fix #667)\n\n2015-02-10  Kim Toms  kim.toms@bplglobal.net\n\n\tEnhance from_entries to better deal with Amazon AWS Tags\n\n2015-01-26  Nicolas Williams  nico@cryptonector.com\n\n\tUsage message for -h should go to stdout\n\n2015-01-27  i  isomorphisms@sdf.org\n\n\treadability\n\n2015-01-14  Joel Purra  code+github@joelpurra.com\n\n\tEmpty arrays join/1 to an empty string, fixes #668 bug introduced by 9760245\n\n2014-12-27  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `debug` and `stderr` builtins\n\n2015-01-13  Nicolas Williams  nico@cryptonector.com\n\n\tjoin/1: respect empty strings (fix #668)\n\n2015-01-13  Nicolas Williams  nico@cryptonector.com\n\n\tSplit on empty sep: fix #552 moar\n\n2015-01-12  Nicolas Williams  nico@cryptonector.com\n\n\tFix docs for `split/0`\n\n2015-01-12  Nicolas Williams  nico@cryptonector.com\n\n\tFix #552\n\n2015-01-02  Nicolas Williams  nico@cryptonector.com\n\n\tLook for jq/main.jq for imports\n\n2015-01-01  Nicolas Williams  nico@cryptonector.com\n\n\tAdd static build instructions (fix #294)\n\n2014-12-30  Nicolas Williams  nico@cryptonector.com\n\n\tFurther module system revamp (fix #659)\n\n2014-12-28  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `label $name | EXP`; fix `break`\n\n2014-12-30  Nicolas Williams  nico@cryptonector.com\n\n\tRemove string indexing by string (fix #454)\n\n2014-12-30  Nicolas Williams  nico@cryptonector.com\n\n\tAdd support for testing erroneous programs\n\n2014-12-30  Nicolas Williams  nico@cryptonector.com\n\n\tMake --run-tests more informative\n\n2014-10-06  pkoppstein  pkoppstein@gmail.com\n\n\ttranspose/0 for possibly jagged matrices\n\n2014-10-07  pkoppstein  pkoppstein@gmail.com\n\n\tbsearch(x) (binary search): builtin.c (tested), with documentation and test case. Always yields an integer (even if input is unsorted); returns (-1 - ix) if x is not in input array.\n\n2014-10-06  pkoppstein  pkoppstein@gmail.com\n\n\tascii_upcase/0 and ascii_downcase/0\n\n2014-12-27  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `debug` builtin\n\n\tDon't force C API users to set input cb\n\n2014-12-26  Nicolas Williams  nico@cryptonector.com\n\n\tMake jq --run-tests show test line numbers\n\n\tStreaming parser torture tests\n\n\tFuzz JSON parser\n\n2014-12-22  Nicolas Williams  nico@cryptonector.com\n\n\tAdd Streaming parser (--stream)\n\n2014-12-26  Nicolas Williams  nico@cryptonector.com\n\n\tAllow C-coded functions to `empty`\n\n\tAdd BLOCK_8() macro\n\n\tFix `foreach` non-propagation of errors\n\n\tAllow zero-length buffers in jv_parser_set_buf()\n\n2014-12-24  Nicolas Williams  nico@cryptonector.com\n\n\tAdd @tsv; fix #645\n\n\tModule search revamp for pkg managers\n\n\tFix #348: reject unescaped control chars\n\n2014-12-23  Nicolas Williams  nico@cryptonector.com\n\n\tUse __attribute__ __printf__ with GCC\n\n\tMake `values` faster (fix #652)\n\n2014-12-22  Marc Abramowitz  marc@marc-abramowitz.com\n\n\t.travis.yml: Set sudo false; use containers\n\n2014-12-22  Santiago Lapresta  santiago.lapresta@gmail.com\n\n\tDefine `map_values`\n\n2014-05-21  Santiago Lapresta  santiago.lapresta@gmail.com\n\n\t`in` is now `inside`, added `in` as inverse of `has`\n\n2014-05-20  Santiago Lapresta  santiago.lapresta@gmail.com\n\n\tAdded `in` command\n\n2014-12-21  Eiichi Sato  sato.eiichi@gmail.com\n\n\tFix examples in manual\n\n\tFix indents in manual.yml\n\n\tHTML-escape jq programs in manual\n\n\tFix examples in manual\n\n2014-12-12  Nicolas Williams  nico@cryptonector.com\n\n\tAdd until(cond; next); fix #639\n\n\tAdd --argjson, fix #648\n\n2014-11-29  Nicolas Williams  nico@cryptonector.com\n\n\tFix refcount leak, fix #618\n\n2014-11-28  Nicolas Williams  nico@cryptonector.com\n\n\tSTOREV/LOADV* should also print refcnts\n\n\tEnable printing of stack val refcnts\n\n\tPrint stack value refcounts when tracing (#636)\n\n2014-11-23  Colin von Heuring  colin@janrain.com\n\n\tDoc correction\n\n2014-11-11  Ian Miell  ian.miell@gmail.com\n\n\tRequirements made slightly more complete: cf https://github.com/ianmiell/shutit/blob/master/library/jq/jq.py\n\n2014-11-05  Steven Maude  StevenMaude@users.noreply.github.com\n\n\tFix typos in tutorial\n\n2014-10-21  Santiago Lapresta  santiago.lapresta@gmail.com\n\n\tDefine {any,all}/2 independently from {any,all}/0\n\n2014-10-20  Santiago Lapresta  santiago.lapresta@gmail.com\n\n\tDefine {any,all}/{0,1} in terms of {any,all}/2\n\n2014-10-10  Nicolas Williams  nico@cryptonector.com\n\n\tAdd support for JSON sequence MIME type\n\n2014-10-06  William Langford  wlangfor@gmail.com\n\n\tProperly call onig_error_code_to_str\n\n2014-10-06  pkoppstein  pkoppstein@gmail.com\n\n\tfix sub (#586); add gsub/3; add transpose/0.\n\n2014-10-03  Nicolas Williams  nico@cryptonector.com\n\n\tUpdate docs about sort/group/min/max/unique\n\n\tfrom-entries should work with EC2 (fix #592)\n\n\tRemove sort/1 and group/1\n\n2014-09-30  Nicolas Williams  nico@cryptonector.com\n\n\tto_entries should not sort keys (fix #561)\n\n2014-09-22  William Langford  wlangfor@gmail.com\n\n\tProperly handle when objects cannot be folded\n\n2014-08-30  Nicolas Williams  nico@cryptonector.com\n\n\tDrop the jq version directory from search path\n\n\tNever close stdin; allow multiple `-` arguments\n\n\tHandle invalid inputs in argument files (fix #562)\n\n2014-08-28  William Langford  wlangfor@gmail.com\n\n\tProperly handle incomplete json when input is file\n\n2014-08-10  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `module` directive, `modulemeta` builtin\n\n2014-08-09  Nicolas Williams  nico@cryptonector.com\n\n\tConstant fold objects\n\n\tFold constant arrays\n\n\tMore constant folding: null, true, and false\n\n\t`.foo[-1] = ...` trips assertion (fix #490)\n\n\tAllow any number of jq-coded function arguments\n\n2014-08-08  Nicolas Williams  nico@cryptonector.com\n\n\tMake regexp builtins and range/3 use #524 too\n\n\tUse `def f($a): ...;` syntax for builtins\n\n\tAdd `def f($arg):` syntax (fix #524)\n\n2014-07-31  pkoppstein  pkoppstein@gmail.com\n\n\tregex filters (#432): scan, splits, split, sub, gsub\n\n2014-08-06  Nicolas Williams  nico@cryptonector.com\n\n\tBetter error msg for bad shell quoting (fix #538)\n\n2014-08-04  William Langford  wlangfor@gmail.com\n\n\tActually check version for bison.\n\n2014-08-03  pkoppstein  pkoppstein@gmail.com\n\n\tApply TCO to recurse/1, add recurse/2; tweak docs\n\n2014-08-01  Adam Lindberg  hello@alind.io\n\n\tAdd example of selecting object with keys\n\n2014-07-19  pkoppstein  pkoppstein@gmail.com\n\n\tAdd capture; document regular expression filters\n\n2014-07-28  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `first`, `nth`, `last` (fix #510)\n\n2014-07-27  Nicolas Williams  nico@cryptonector.com\n\n\tFold constants (fix #504)\n\n2014-07-21  William Langford  wlangfor@gmail.com\n\n\tChanging color codes to fix #495\n\n2014-07-09  William Langford  wlangfor@gmail.com\n\n\tAdded library system with -l, -L, and JQ_LIBRARY_PATH\n\n2014-07-14  Simon Elsbrock  simon@iodev.org\n\n\tjq 1.4 is in Debian\n\n2014-07-13  Marc Bruggmann  marcbr@spotify.com\n\n\tFix manual example for `endswith`.\n\n2014-07-09  Hanfei Shen  qqshfox@gmail.com\n\n\tFix examples for `del` in manual\n\n2014-07-08  Zhiming Wang  zmwangx@gmail.com\n\n\tFix invalid YAML in manual.yml\n\n\tAdd tests/all.trs to .gitignore\n\n2014-07-09  Nicolas Williams  nico@cryptonector.com\n\n\tBetter document `path()`'s power; also `|=`\n\n\tAdd `foreach EXP as $var (INIT; UPDATE)` form\n\n\tMake `while()` handle `break`\n\n2014-07-07  Nicolas Williams  nico@cryptonector.com\n\n\tMake C-coded built-ins take `jq_state *` argument\n\n\t`error(x)` should not `tostring` its arg; fix #466\n\n\t`limit` should use `break`\n\n\tMake `any/2` and `all/2` efficient using `foreach`\n\n2013-12-24  Nicolas Williams  nico@cryptonector.com\n\n\tjv_invalid() shouldn't allocate\n\n2013-12-31  Nicolas Williams  nico@cryptonector.com\n\n\tjv_show() should be able to display invalid values\n\n2014-07-07  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `break` builtin for `foreach`\n\n\tExplain `foreach`'s powers a bit more\n\n\tDocument `path(path_expression)` builtin\n\n\t$var[\"foo\"]=1 can't work as expected; doc fix #236\n\n\tBetter check for lib has only functions (fix #138)\n\n2014-07-06  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `any/N` and `all/N` x N in (1, 2) (fix #455)\n\n\tAdd `foreach` and `limit`\n\n2014-07-04  William Langford  wlangfor@gmail.com\n\n\tAdd support for negative indices for .[]; fix #462\n\n2014-07-06  Nicolas Williams  nico@cryptonector.com\n\n\tAdd general `?` operator\n\n2014-07-05  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `try EXP catch EXP`\n\n2014-07-06  Nicolas Williams  nico@cryptonector.com\n\n\tDocument `error/1`\n\n2014-07-02  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `while(cond; update)` (fix #314)\n\n\tAdd `range(init;upto;by)` (fix #317)\n\n2014-07-01  Nicolas Williams  nico@cryptonector.com\n\n\tDescribe generators, range() with by to manual\n\n2014-07-01  William Langford  wlangfor@gmail.com\n\n\tFixed base64 issue with UTF-8 strings\n\n2014-06-30  Nicolas Williams  nico@cryptonector.com\n\n\tTCO to the max!\n\n2014-06-25  William Langford  wlangfor@gmail.com\n\n\tAdded cross-compilation script to build libjq for iOS.\n\n2014-06-29  Zhiming Wang  zmwangx@gmail.com\n\n\tLet @uri produce uppercase hexadecimal digits...\n\n2014-06-24  Nicolas Williams  nico@cryptonector.com\n\n\tGet \"Try Online\" button working (fix #440)\n\n2014-06-22  Nicolas Williams  nico@cryptonector.com\n\n\tTail call optimization (close #437)\n\n2014-06-20  Nicolas Williams  nico@cryptonector.com\n\n\tAllow stacking of short options (fix #346)\n\n2014-06-18  William Langford  wlangfor@gmail.com\n\n\tAdded regex support as per issue #164.\n\n2014-06-17  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `-j` / `--join-output` option, similar to `-r`\n\n2014-06-18  Santiago Lapresta  santiago.lapresta@gmail.com\n\n\tSimplified standard library\n\n2014-06-16  Nicolas Williams  nico@cryptonector.com\n\n\tFix #280: from_entries of [] is null, should be {}\n\n2014-06-16  Nicolas Williams  nico@cryptonector.com\n\n\tNo args default w/ tty stdout, not tty stdin #220\n\n2014-06-16  Santiago Lapresta  santiago.lapresta@gmail.com\n\n\tAdded `flatten` and `flatten(x)` functions\n\n2014-06-16  Nicolas Williams  nico@cryptonector.com\n\n\tAdd ChangeLog and NEWS files\n\n2014-06-14  Nicolas Williams  nico@cryptonector.com\n\n\tAllow multiple functions with different arities\n\n2014-06-13  Nicolas Williams  nico@cryptonector.com\n\n\tAdd `env` builtin\n\n2014-06-13  Nicolas Williams  nico@cryptonector.com\n\n\tDocument the lambda nature of function args #391\n\n2014-06-13  Nicolas Williams  nico@cryptonector.com\n\n\tAdd jqplay link to the site\n\n2014-06-12  Jingwen Owen Ou  jingweno@gmail.com\n\n\tjqplay has a domain now\n\n2014-06-12  Nicolas Williams  nico@cryptonector.com\n\n\tMake a better jq.1 when Ruby deps missing\n\n2014-06-11  Kim De Mey  kim.demey@gmail.com\n\n\tDetect endianness at configuration with Autoconf AC_C_BIGENDIAN feature\n\n2014-06-09  Nicolas Williams  <nico@cryptonector.com>\n\n\tAdd libm.h to dist file list\n\n\tAdd note about cmd.exe quoting\n\n\tBuilding docs fails on powerpc (#349)\n\n2014-06-08  Nicolas Williams  <nico@cryptonector.com>\n\n\tUpdate site news\n\n\tAlso fix configure.ac to use git describe --tags\n\n\tFix scripts/version: use git describe --tags ...\n\tAfter tagging as 1.4 scripts/version was still producing jq-1.3-....\n\n\tAdd `indices(s)`, improve `index(s)`, `rindex(s)`\n\tNow these deal with arrays as input and `s` being an array or a scalar.\n\n\tImprove `index` and `rindex` examples\n\n\tRemove reference to `getpath` from docs\n\n\tDocument `index` and `rindex` (#389)\n\n2014-06-07  Santiago Lapresta  <santiago.lapresta@gmail.com>\n\n\tAdded `join` function\n\n2014-06-07  Nicolas Williams  <nico@cryptonector.com>\n\n\tString * number should be commutative\n\n2014-06-04  Nicolas Williams  <nico@cryptonector.com>\n\n\tAdd cross-compilation notes to README\n\tA detailed set of instruction as to how to setup a cross-compilation\n\tenvironment for OS X and Win32/64 would be nice.\n\n\tAdd -j option to scripts/crosscompile\n\n\tAdd flags argument to jv_parser_new()\n\tFor extensibility.  We might add streaming parser options, even binary\n\tJSON encoding options.\n\n2014-06-02  Nicolas Williams  <nico@cryptonector.com>\n\n\tFix tests failures on Windows\n\tAnd Solaris 8 and 9 too, no doubt.  The problem was that non-standard\n\tvsnprintf()s that return -1 when the buffer is too small were not\n\tproperly supported.\n\n2014-05-20  Santiago Lapresta  <santiago.lapresta@gmail.com>\n\n\tDocumented `del` command\n\n2014-05-11  Santiago Lapresta  <santiago.lapresta@gmail.com>\n\n\tAdded texts/examples to unique_by function\n\n\tAdded unique_by function\n\n2014-04-17  Nicolas Williams  <nico@cryptonector.com>\n\n\tMake pthread tls configurable for Mingw build\n\tFor the Mingw build we don't want to pull in the pthread DLL just\n\tbecause we can autodetect pthread support.  That would make the jq.exe\n\tbinary not self-contained.\n\n2014-04-16  Nicolas Williams  <nico@cryptonector.com>\n\n\tAdd autoconf checks for pthreads; fix #340\n\n2014-03-20  Jingwen Owen Ou  <jingweno@gmail.com>\n\n\tAdd link to jqplay\n\n2014-03-13  Nicolas Williams  <nico@cryptonector.com>\n\n\tFix for #303 in the sources\n\n2014-03-13  Santiago Lapresta  <santiago.lapresta@gmail.com>\n\n\tAdded `arrays` and other filters\n\tArrays, objects, numbers, strings, booleans, nulls, values (non-nulls)\n\t-- these builtins filter out those inputs that don't match the name of\n\tthe builtin.\n\n\tThis fixes #322 and #324.\n\n2014-03-07  Filippo Valsorda  <filippo.valsorda@gmail.com>\n\n\tAdd a recursive object merge strategy and bind it to *\n\tThis commit adds a jv_object_merge_recursive function, that performs\n\trecursive object merging, and binds it to multiply when applied to\n\ttwo objects.\n\n\tCloses #320\n\n2014-03-06  Nicolas Williams  <nico@cryptonector.com>\n\n\tMake libm tests more portable\n\n2014-02-26  Andrew Rodland  <andrew@cleverdomain.org>\n\n\tRepair jv_show\n\n2014-02-26  Andrew Rodland  <andrew@cleverdomain.org>\n\n\tMake jq --raw-output --unbuffered work\n\t--unbuffered was only affecting the normal output case, not the --raw-output case. Make the two of them play together.\n\n\tThis also makes sure that the output is flushed *after* printing the newline, so a consumer doesn't lag a line behind.\n\n2014-02-21  Nicolas Williams  <nico@cryptonector.com>\n\n\tAdd cbrt (cube root)\n\n\tAdd missing trig functions and barebones test\n\n\tRemove non-standard exp10()\n\n2014-02-21  Mike McCabe  <mccabe@archive.org>\n\n\tInitial add of math functions.\n\n2014-02-20  Nicolas Williams  <nico@cryptonector.com>\n\n\tAdd `?`, `.[]?`, and `..` operators\n\tMake XPath-like `//a/b` recursive structure traversal easier in jq,\n\twhich then becomes:\n\n\t    ..|.a?.b?\n\n\tThe `?` operator suppresses errors about . not being an array or object.\n\tThe `..` operator is equivalent to calling the new `recurse_down`\n\tbuilt-in, which in turn is equivalent to\n\n\t    recurse(.[]?)\n\n\tNote that `..a` is not supported; neither is `...a`.  That could be add\n\tadded, but it doesn't seem worth the trouble of saving the need to type\n\ta '|'.\n\n2014-02-16  Santiago Lapresta  <santiago.lapresta@gmail.com>\n\n\tAdded `all` and `any` builtins\n\n2014-01-25  polyester  <paul@cleanclothes.org>\n\n\twork with newer versions of automake\n\twhen using a newer automake, the autoreconf step fails with warnings:\n\t\"linking libtool libraries using a non-POSIX archiver requires 'AM_PROG_AR' in 'configure.ac' \"\n\n\tThis happens for instance on ubuntu 13.10.\n\tDoing just that, adding 'AM_PROG_AR' to configure.ac fixes the problem.\n\n2014-01-01  Nicolas Williams  <nico@cryptonector.com>\n\n\tFix #201; check that bison accepts --warnings\n\n2013-12-27  Joe Littlejohn  <joe.littlejohn@nokia.com>\n\n\tFix rpm build (`make rpm`)\n\t* Re-add VERSION as it's required for `./setup superclean`\n\t  and `make rpm`.\n\t* Add *.rpm to git ignore, we never want them under version control.\n\n2013-12-27  Filippo Giunchedi  <fgiunchedi@gmail.com>\n\n\tinclude additional files in jq.spec\n\tthis will probably need changing upon SONAME bump\n\n\tfix rpm Makefile target and prerequisites\n\tdepend on dist and the specfile, plus use automake's variables\n\n2013-12-26  Nicolas Williams  <nico@cryptonector.com>\n\n\tDocument --version\n\n2013-12-26  Nicolas Williams  <nico@cryptonector.com>\n\n\tAdd jv_dumpf() and jv_show()\n\tjv_dumpf() takes a FILE *.\n\n\tjv_show() is intended for use in debuggers, so it dumps the jv to stderr\n\tand it does not jv_free() the jv, so it's safe to\n\t\"call jv_show(some_jv, -1)\" in a debugger.  If flags == -1 then the jv\n\twill be shown pretty-printed and in color.\n\n2013-12-26  Nicolas Williams  <nico@cryptonector.com>\n\n\tDocument .foo.bar in manual\n\n\tDocument exit numbers\n\n\tNormalize errors for -e\n\n2013-12-25  Nicolas Williams  <nico@cryptonector.com>\n\n\tFix doc typos (.[foo] wanted to be .[\"foo\"])\n\n\tAdd note to jq.1 about shell quoting\n\n2013-12-20  Philipp Hagemeister  <phihag@phihag.de>\n\n\tIgnore the config/test-driver file\n\tThis file is automatically generated and does not need to be committed.\n\n\tFix @uri example\n\tPreviously, the @uri example didn't match the actual behavior of the current jq, as exclamation marks do not need to be encoded in URIs.\n\tReplace the example with an input that needs encoding, and is encoded by jq.\n\n2013-12-17  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tAllow negated object values without parens. Fixes #247\n\n2013-12-17  Nicolas Williams  <nico@cryptonector.com>\n\n\tFix memmem() error\n\n2013-12-13  Rémy Léone  <remy.leone@gmail.com>\n\n\tAdding a .travis.yml file to use the travis-ci.org\n\tFrom wikipedia:\n\n\tTravis CI is a hosted, distributed continuous integration service used\n\tto build and test projects hosted at GitHub.\n\n\tTravis CI is configured by adding a file named .travis.yml, which is a\n\tYAML format text file, to the root directory of the GitHub repository.\n\n\tTravis CI automatically detects when a commit has been made and pushed\n\tto a GitHub repository that is using Travis CI, and each time this\n\thappens, it will try to build the project and run tests. This includes\n\tcommits to all branches, not just to the master branch. When that\n\tprocess has completed, it will notify a developer in the way it has been\n\tconfigured to do so — for example, by sending an email containing the\n\ttest results (showing success or failure), or by posting a message on an\n\tIRC channel. It can be configured to run the tests on a range of\n\tdifferent machines, with different software installed (such as older\n\tversions of a programming language, to test for compatibility).\n\n2013-12-13  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tMake the testsuite run on machines without valgrind\n\n\tFormat more integers as integers, not scientific notation.\n\tjq is now willing to put up to 15 zeros after an integer before\n\tmoving to scientific notation.\n\n2013-12-11  Nicolas Williams  <nico@cryptonector.com>\n\n\tComplete more-arity feature not complete\n\tAnd test\n\n2013-12-10  David R. MacIver  <david@drmaciver.com>\n\n\tconvert range bounds to integers in a way that avoids undefined behaviour\n\n\tadd checking of numeric indices to an array to see if they can reasonably be considered integers. Avoid undefined behaviour if out of bounds\n\n2013-12-09  David R. MacIver  <david@drmaciver.com>\n\n\tsome functions were missing prototypes. Add them\n\n2013-12-08  David R. MacIver  <david@drmaciver.com>\n\n\tThese vfprintfs are being used as if they were printfs. Fix that\n\n\tconsistent use of goto out in main\n\n2013-12-08  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tRefactor jv structure.\n\tNew structure layout is simpler and also faster.  In particular, it's\n\tnow small enough to be passed in registers on amd64.\n\n\tMake testsuite not leak when compiled with -DNDEBUG.\n\n2013-12-08  David R. MacIver  <david@drmaciver.com>\n\n\ttest for losing memory on compile errors\n\n\targs to jq_compile_args were not getting freed when there were errors in the compile\n\n2013-12-06  Nicolas Williams  <nico@cryptonector.com>\n\n\tFix double-free typo in print_error()\n\n\tFix manual.yml\n\n2013-12-04  Nicolas Williams  <nico@cryptonector.com>\n\n\tConditionally #define _GNU_SOURCE in compile.c\n\n\tAdd tests for string index by string and builtins\n\n\tAdd index and rindex builtins\n\n\tAdd index strings by string; return string indexes\n\t    % jq '.[\",\"]'\n\t    \"a,bc,def,ghij,klmno\"\n\t    [1,4,8,13]\n\t    %\n\n\tMake length return abs value of numeric inputs\n\n\tAdd callback interface for errors\n\tPrinting to stderr is not the right answer for a library.\n\n\tAdd jv_string_vfmt()\n\n\tDocument ltrimstr and rtrimstr\n\n\tTest ltrimstr and rtrimstr functions\n\n\tAdd ltrimstr and rtrimstr functions\n\n\tDocument -e / --exit-status argument\n\n\tAdd -e | --exit-status CLI option\n\n\tDocument tojson and fromjson builtins\n\n\tTest tojson and fromjson\n\n\tAdd tojson and fromjson builtins\n\n\tDocument split function\n\n\tDocument string multiplication and division\n\n\tDocument string functions and slicing\n\n\tTest string slicing\n\n\tAdd string slicing\n\n\tAdd tests for string division/splitting\n\n\tAdd string division by string (split on separator)\n\n\tTest starts/endswith and string multiplication\n\n\tAdd string multiplication by number\n\n\tAdd startswith/endswith\n\n\tAdd explode/implode jq functions to match jv API\n\n\tUse uint32_t for codepoint in  jv_string_append_codepoint()\n\n\tAdd jv string utility functions\n\t    jv_string_empty()\n\t        -> return an empty string with given allocated length (for fast\n\t           appends)\n\t    jv_string_append_codepoint\n\t        -> append a single codepoint (int) to the given string\n\t    jv_string_explode\n\t        -> return an array of codepoints making up a string\n\t    jv_string_implode\n\t        -> return the UTF-8 encoding of an array of codepoint numbers\n\n\tSupport more arguments for defs\n\n2013-12-04  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tPreserve insertion order in objects. Closes #169.\n\n2013-11-30  Nicolas Pouillard  <nicolas.pouillard@gmail.com>\n\n\tAdd a few more test cases (from the man page)\n\n2013-11-08  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tAdd a --unbuffered option. Closes #206\n\n2013-11-07  Peter van Dijk  <peter@7bits.nl>\n\n\tcount should be length\n\tExample refers to a count function, which does not exist. Replacing it with length works.\n\n2013-11-07  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tFix a crash on group_by of empty list. Fixes #208.\n\n2013-10-16  Ryoichi KATO  <ryo1kato@gmail.com>\n\n\tDocs: add description of --from-file option\n\n2013-10-06  Juan Guerrero  <juan.guerrero.lozano@gmail.com>\n\n\tFix typo on error message\n\n2013-09-19  Kenny Shen  <kenny.shen@zalora.com>\n\n\tAdd missing -i flag in build instructions\n\n2013-09-14  Michael Daines  <michael@mdaines.com>\n\n\tAdd test showing calculation of standard deviation\n\n2013-09-13  Mike Daines  <michael@mdaines.com>\n\n\tFix typo\n\n2013-09-11  Michael Daines  <michael@mdaines.com>\n\n\tAdd sqrt operator\n\n2013-09-04  Jack Pearkes  <jackpearkes@gmail.com>\n\n\tdocs: update the tutorial to use GitHub's API\n\n2013-09-01  Ankur  <ankz.kothari@gmail.com>\n\n\tCall AM_INIT_AUTOMAKE once only\n\tFixes build with automake-1.14\n\n2013-08-19  Joe Littlejohn  <joe.littlejohn@nokia.com>\n\n\tFix Makefile after refactoring of stacks in 05d90517b02\n\n2013-06-23  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tRemove #includes from jv.h\n\n\tFix the jv_parser interface.\n\n\tUse libtool's built-in symbol exporting rather than a mapfile.\n\n\tMove gen_utf8_tables to scripts\n\n\tMove libtool m4 junk to config/ and delete some autogenerated files.\n\n\tRemove Autoconf-generated config.h.\n\n2013-06-22  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tBuild libjq only once, and link it statically to ./jq\n\tThis means ./jq is a real binary rather than a libtool turd.\n\n\tFix distcheck.\n\tUpdate list of files to be distributed.\n\n\tUtf8 fixes. Closes #161\n\n\tReject all overlong UTF8 sequences.\n\n\tFix various UTF8 parsing bugs.\n\tIn particular, parse bad UTF8 by replacing the broken bits with U+FFFD\n\tand resynchronise correctly after broken sequences.\n\n\tFix example in manual for `floor`. See #155.\n\n2013-06-21  Nicolas Williams  <nico@cryptonector.com>\n\n\tDocument floor\n\n\tAdd floor operator\n\n\tDocument mod\n\n\tAdd mod (and setmod) operators\n\n\tUpdate .gitignore\n\n\tAdd libjq autoconf goo\n\n\tQuiet setup.sh re: tmp dir\n\n2013-06-21  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tMove cfunction invocation code to the interpreter loop.\n\n2013-06-18  Nicolas Williams  <nico@cryptonector.com>\n\n\tFix serious bug in handling of --argfile\n\n\tFix leaks in jv_load_file()\n\n2013-06-17  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tFold opcode.{c,h} into bytecode.{c,h}\n\n\tSimplify block functions for variables\n\n\tSaner build instructions in README.md\n\tCloses #144\n\n\tRemove some initialise-to-zero code.\n\tThis lets valgrind find more bugs - if a field isn't given a\n\twell-defined value valgrind will now find it instead of seeing it\n\tset to zero with memset.\n\n2013-06-17  Nicolas Williams  <nico@cryptonector.com>\n\n\tRemove accidentally introduced use of fopen \"e\"\n\n2013-06-16  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tMerge pull request #114 from nicowilliams/nomem_handler\n\tAdd jv_nomem_handler()\n\n2013-06-16  Nicolas Williams  <nico@cryptonector.com>\n\n\tRemove last remnant of main.h\n\n2013-06-15  Nicolas Williams  <nico@cryptonector.com>\n\n\tAllow --run-tests to take a file argument\n\n\tFixup API to get closer to a libjq\n\n2013-06-15  Nicolas Williams  <nico@cryptonector.com>\n\n\tMove slurp_file() into library as jv_load_file()\n\tNeeded as part of creating a libjq.\n\n2013-06-14  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tClean up lots of stack and frame logic.\n\tMove frame defs to execute.c\n\n2013-06-13  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tSimplify frame logic.\n\n\tUnify all stacks. Passes tests, but needs cleanup.\n\n2013-06-11  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tSupport .\"foo\" syntax for accessing fields. See #141.\n\n2013-06-09  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tUnify frame and data stacks\n\n2013-06-05  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tSpeed up cached configure (./configure -C)\n\n\tClean up flex lines in build\n\n\tLex and parse .foo better.\n\t'.as' is now valid, '. foo' is now invalid. See #141.\n\n2013-06-04  Markus Lanthaler  <mark_lanthaler@gmx.net>\n\n\tUpdate README.md\n\tUpdate the link to the documentation. All GitHub pages are now using the github.io domain.\n\n2013-06-03  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tMake jq --version print to stdout, not stderr\n\n\tBetter error handling for .foo case in parser. See #141.\n\n\tLet the parser rather than the lexer handle invalid characters.\n\n\tAdd command-line option to sort object keys.\n\tCloses #79.\n\n\tClean up Makefile.am (distcheck, rebuild version.h less often)\n\n2013-05-31  Brendan Macmillan  <melbourne.research@gmail.com>\n\n\tStop warning on fgets, simple version\n\n\tStop warning on fgets, complex version\n\n2013-05-31  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tSquash a warning on some GCC versions\n\n2013-05-29  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tSupport for printing object keys in sorted order.\n\tNo command-line option to enable this yet. See #79.\n\n2013-05-29  Brendan Macmillan  <melbourne.research@gmail.com>\n\n\tBugfix multiline off-by-one (locfile.c)\n\n\tlocfile.h -> locfile.h + locfile.c\n\tclean up includes of a few files\n\n\tHack bugfix for multiline off-by-one (locfile.c)\n\n\tLoad library from ~/.jq\n\n2013-05-24  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\tMake jq --version report an actual git revision.\n\tCloses #129.\n\n2013-05-23  Nicolas Williams  <nico@cryptonector.com>\n\n\tAdd --argfile variant of --arg (issue #117)\n\tThis is useful when one has a database (in JSON form) to query using jq\n\tinput data.\n\n\t    % echo '{\"a\":1, \"c\":5}' > db.json\n\t    % echo '\"c\"'|./jq --argfile f /tmp/a '$f[.]'\n\t    5\n\t    % echo '\"a\"'|./jq --argfile f /tmp/a '$f[.]'\n\t    1\n\t    % echo '\"b\"'|./jq --argfile f /tmp/a '$f[.]'\n\t    null\n\t    %\n\n2013-05-23  Stephen Dolan  <mu@netsoc.tcd.ie>\n\n\t'make clean' won't delete jq.1 if it can't be rebuilt.\n\tSee #131\n"
  },
  {
    "path": "Dockerfile",
    "content": "FROM debian:12-slim AS builder\n\nENV DEBIAN_FRONTEND=noninteractive \\\n    DEBCONF_NONINTERACTIVE_SEEN=true \\\n    LC_ALL=C.UTF-8 \\\n    LANG=C.UTF-8\n\nRUN apt-get update \\\n && apt-get install -y \\\n      build-essential \\\n      autoconf \\\n      libtool \\\n      git \\\n && apt-get clean \\\n && rm -rf /var/lib/apt/lists/*\n\nWORKDIR /app\nCOPY . /app\nRUN autoreconf -i \\\n && ./configure \\\n      --disable-docs \\\n      --with-oniguruma=builtin \\\n      --enable-static \\\n      --enable-all-static \\\n      --prefix=/usr/local \\\n && make -j$(nproc) \\\n && make check VERBOSE=yes \\\n && make install-strip\n\nFROM scratch\n\nCOPY --from=builder /app/AUTHORS /app/COPYING /usr/local/bin/jq /\nRUN [\"/jq\", \"--version\"]\nENTRYPOINT [\"/jq\"]\n"
  },
  {
    "path": "KEYS",
    "content": "pub   4096R/71523402 2015-10-11\n      Key fingerprint = 4FD7 01D6 FA9B 3D2D F5AC  935D AF19 040C 7152 3402\nuid                  jq Release Signing Key <jq@stedolan.github.io>\n\npub   2048R/D15684DB 2015-10-12 [expires: 2017-10-11]\n      Key fingerprint = 7F6C 7BD3 0412 AFD5 8C1A  5007 EB26 A4F8 D156 84DB\nuid                  Nicolas Williams <nico@cryptonector.com>\nsub   2048R/9C9CCD6A 2015-10-12 [expires: 2017-10-11]\n"
  },
  {
    "path": "Makefile.am",
    "content": "\n### C source files to be built and distributed.\n\nLIBJQ_INCS = src/builtin.h src/bytecode.h src/compile.h                 \\\n        src/exec_stack.h src/jq_parser.h src/jv_alloc.h src/jv_dtoa.h   \\\n        src/jv_unicode.h src/jv_utf8_tables.h src/lexer.l src/libm.h    \\\n        src/linker.h src/locfile.h src/opcode_list.h src/parser.y       \\\n        src/util.h src/jv_dtoa_tsd.h src/jv_thread.h src/jv_private.h   \\\n        vendor/decNumber/decContext.h vendor/decNumber/decNumber.h      \\\n        vendor/decNumber/decNumberLocal.h\n\nLIBJQ_SRC = src/builtin.c src/bytecode.c src/compile.c src/execute.c    \\\n        src/jq_test.c src/jv.c src/jv_alloc.c src/jv_aux.c              \\\n        src/jv_dtoa.c src/jv_file.c src/jv_parse.c src/jv_print.c       \\\n        src/jv_unicode.c src/linker.c src/locfile.c src/util.c          \\\n        src/jv_dtoa_tsd.c                                               \\\n        vendor/decNumber/decContext.c vendor/decNumber/decNumber.c      \\\n        ${LIBJQ_INCS}\n\n### C build options\n\nAM_CFLAGS = -Wextra -Wall -Wno-unused-parameter -Wno-unused-function \\\n            -Woverlength-strings -Wstrict-prototypes\n\nif WIN32\nAM_CFLAGS += -municode\nendif\n\nACLOCAL_AMFLAGS = -I config/m4\n\n### Generating the lexer and parser\n\n# While there is some autoconf macro support for lex/flex, it doesn't support\n# header file creation so we'll use good old make\nif MAINTAINER_MODE\nBUILT_SOURCES = src/lexer.h src/lexer.c src/parser.h src/parser.c \\\n                src/builtin.inc src/config_opts.inc src/version.h\nsrc/lexer.c: src/lexer.l\n\t$(AM_V_LEX) flex -o src/lexer.c --header-file=src/lexer.h $<\nsrc/lexer.h: src/lexer.c\nelse\nBUILT_SOURCES = src/builtin.inc src/config_opts.inc src/version.h\n.y.c:\n\t$(AM_V_YACC) echo \"NOT building parser.c!\"\n.l.c:\n\t$(AM_V_LEX) echo \"NOT building lexer.c!\"\nendif\n\n# Tell YACC (Bison) autoconf macros that you want a header file created.\n# If the --warnings=all fails, you probably have an old version of Bison\n# macOS ships an old Bison, so update with Homebrew or MacPorts.\nAM_YFLAGS = --warnings=all -Wno-yacc -d\n\n### libjq\n\nlib_LTLIBRARIES = libjq.la\nlibjq_la_SOURCES = ${LIBJQ_SRC}\nlibjq_la_LIBADD = -lm\nlibjq_la_LDFLAGS = $(onig_LDFLAGS) -export-symbols-regex '^j[qv]_' -version-info 1:4:0\n\nif WIN32\nlibjq_la_LIBADD += -lshlwapi\nlibjq_la_LDFLAGS += -no-undefined\nendif\n\ninclude_HEADERS = src/jv.h src/jq.h\n\nAM_CPPFLAGS = -I$(srcdir)/src -I$(srcdir)/vendor\n\n### Address sanitizer (ASan)\n\nif ENABLE_ASAN\nAM_CFLAGS += -fsanitize=address\nendif\n\n### Undefined Behavior Sanitizer\n\nif ENABLE_UBSAN\nAM_CFLAGS += -fsanitize=undefined\nendif\n\n### Code coverage with gcov\n\nif ENABLE_GCOV\nAM_CFLAGS += --coverage --no-inline\nendif\n\n### Error injection for testing\n\nif ENABLE_ERROR_INJECTION\nlib_LTLIBRARIES += libinject_errors.la\nlibinject_errors_la_SOURCES = src/inject_errors.c\nlibinject_errors_la_LIBADD = -ldl\nlibinject_errors_la_LDFLAGS = -module\nendif\n\n### Building the jq binary\n\n# Remake the version.h header file if, and only if, the git ID has changed\n.PHONY: .FORCE\n.FORCE:\ngenerate_ver = ver=\"`{ $(srcdir)/scripts/version || echo '$(VERSION)' ; } | xargs printf '\\043define JQ_VERSION \\\"%s\\\"\\n'`\"\n.remake-version-h: .FORCE\n\t@ $(generate_ver); test \"x`cat src/version.h 2>/dev/null`\" = \"x$$ver\" || touch .remake-version-h\nsrc/version.h: .remake-version-h\n\tmkdir -p src\n\t$(AM_V_GEN) $(generate_ver); echo \"$$ver\" > $@\nsrc/config_opts.inc:\n\tmkdir -p src\n\t$(AM_V_GEN) if test -x ./config.status; then \\\n\t  ./config.status --config; \\\n\telse echo \"(unknown)\"; \\\n\tfi | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\"/\\\\\"/g' -e 's/^/\"/' -e 's/$$/\"/' -e 's/^/#define JQ_CONFIG /' > $@\nsrc/main.c: src/version.h src/config_opts.inc\n\nsrc/builtin.inc: $(srcdir)/src/builtin.jq\n\tmkdir -p src\n\t$(AM_V_GEN) od -v -A n -t o1 -- $< | \\\n\tsed -e 's/$$/ /' \\\n\t    -e 's/\\([0123456789]\\) /\\1, /g' \\\n\t    -e 's/ $$//' \\\n\t    -e 's/ 0/  0/g' \\\n\t    -e 's/ \\([123456789]\\)/ 0\\1/g' > $@\nsrc/builtin.o: src/builtin.inc\n\nCLEANFILES = src/version.h .remake-version-h src/builtin.inc src/config_opts.inc\n\nbin_PROGRAMS = jq\njq_SOURCES = src/main.c\njq_LDADD = libjq.la -lm\n\nif ENABLE_ALL_STATIC\njq_LDFLAGS = -all-static\nendif\n\n### Tests (make check)\n\nTESTS = tests/mantest tests/jqtest tests/shtest tests/utf8test tests/base64test tests/uritest\nif !WIN32\nTESTS += tests/optionaltest\nendif\n\nAM_TESTS_ENVIRONMENT = JQ=$(abs_builddir)/jq\nif ENABLE_VALGRIND\nAM_TESTS_ENVIRONMENT += ENABLE_VALGRIND=1\nendif\n\n# This is a magic make variable that causes it to treat tests/man.test as a\n# DATA-type dependency for the check target. As a result, it will attempt to\n# run any defined targets for tests/man.test as a dependency for check. This\n# allows us to ensure that the tests are up-to-date if the manual has been updated\ncheck_DATA = tests/man.test\n\n### Building the man tests\n\n# We use the examples in the manual as additional tests, to ensure they always work.\n# As a result, we need to rebuild the tests if the manual has been updated.\n# Making changes to the manpage without having the python deps means your\n# tests won't run. If you aren't making changes to the examples, you probably\n# don't care. But if you are, then you need to run the tests anyway.\ntests/man.test tests/manonig.test: $(srcdir)/docs/content/manual/dev/manual.yml\nif ENABLE_DOCS\n\t$(AM_V_GEN) ( cd ${abs_srcdir}/docs && \\\n\t  $(PIPENV) run python validate_manual_schema.py content/manual/dev/manual.yml && \\\n\t  $(PIPENV) run python build_mantests.py )\nelse\n\t@echo Changes to the manual.yml require docs to be enabled to update the manual test.\n\t@echo As a result, the manual test is out of date.\nendif\n\n### Building the manpage\n\n# We build the docs from the manpage yml. If no changes have been made to the\n# manpage, then we'll end up using the cached version. Otherwise, we need to\n# rebuild it.\nman_MANS = jq.1\njq.1.prebuilt: $(srcdir)/docs/content/manual/dev/manual.yml\nif ENABLE_DOCS\n\t$(AM_V_GEN) ( cd ${abs_srcdir}/docs && \\\n\t  $(PIPENV) run python validate_manual_schema.py content/manual/dev/manual.yml && \\\n\t  $(PIPENV) run python build_manpage.py ) > $@\nelse\n\t@echo Changes to the manual.yml require docs to be enabled to update the manpage.\n\t@echo As a result, the manpage is out of date.\nendif\n\njq.1: jq.1.prebuilt\n\t$(AM_V_GEN) cp $(srcdir)/jq.1.prebuilt $@\n\nCLEANFILES += jq.1\n\n### Build oniguruma\n\nif BUILD_ONIGURUMA\nlibjq_la_LIBADD += vendor/oniguruma/src/.libs/libonig.la\njq_LDADD += vendor/oniguruma/src/.libs/libonig.la\nSUBDIRS = vendor/oniguruma\nendif\n\nAM_CFLAGS += $(onig_CFLAGS)\n\nif WITH_ONIGURUMA\nTESTS += tests/onigtest tests/manonigtest\nendif\n\n### Packaging\n\ninstall-binaries: $(BUILT_SOURCES)\n\t$(MAKE) $(AM_MAKEFLAGS) install-exec\n\nDOC_FILES = docs/content docs/public docs/templates                     \\\n        docs/Pipfile docs/Pipfile.lock docs/build_manpage.py            \\\n        docs/build_mantests.py docs/build_website.py docs/README.md     \\\n        docs/validate_manual_schema.py docs/manual_schema.yml\n\nEXTRA_DIST = $(DOC_FILES) $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER)     \\\n        jq.1.prebuilt jq.spec src/lexer.c src/lexer.h src/parser.c      \\\n        src/parser.h src/version.h src/builtin.jq scripts/version       \\\n        libjq.pc                                                        \\\n        tests/modules/a.jq tests/modules/b/b.jq tests/modules/c/c.jq    \\\n        tests/modules/c/d.jq tests/modules/data.json                    \\\n        tests/modules/home1/.jq tests/modules/home2/.jq/g.jq            \\\n        tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq           \\\n        tests/modules/shadow1.jq tests/modules/shadow2.jq               \\\n        tests/modules/syntaxerror/syntaxerror.jq                        \\\n        tests/modules/test_bind_order.jq                                \\\n        tests/modules/test_bind_order0.jq                               \\\n        tests/modules/test_bind_order1.jq                               \\\n        tests/modules/test_bind_order2.jq                               \\\n        tests/onig.supp tests/local.supp                                \\\n        tests/setup tests/torture/input0.json                           \\\n        tests/optional.test tests/man.test tests/manonig.test           \\\n        tests/jq.test tests/onig.test tests/base64.test tests/uri.test  \\\n        tests/jq-f-test.sh                                              \\\n        tests/no-main-program.jq tests/yes-main-program.jq\n\nAM_DISTCHECK_CONFIGURE_FLAGS=--with-oniguruma=builtin\n\n# README.md is expected in GitHub projects, good stuff in it, so we'll\n# distribute it and install it with the package in the doc directory.\ndist_doc_DATA = README.md NEWS.md COPYING AUTHORS\n\npkgconfigdir = $(libdir)/pkgconfig\npkgconfig_DATA = libjq.pc\n\nRELEASE ?= 1\nrpm: dist jq.spec\n\t@echo \"Packaging jq as an RPM ...\"\n\tmkdir -p rpm/SOURCES rpm/BUILD rpm/BUILDROOT rpm/RPMS rpm/SPECS\n\tcp jq-$(VERSION).tar.gz rpm/SOURCES/\n\trpmbuild -tb --define \"_topdir ${PWD}/rpm\" --define \"_prefix /usr\" --define \"myver $(VERSION)\" --define \"myrel ${RELEASE}\" rpm/SOURCES/jq-$(VERSION).tar.gz\n\tfind rpm/RPMS/ -name \"*.rpm\" -exec mv {} ./ \\;\n\trm -rf rpm\n"
  },
  {
    "path": "NEWS.md",
    "content": "# 1.8.1\n\nThis is a patch release to fix security, performance, and build issues found in 1.8.0.\nFull commit log can be found at <https://github.com/jqlang/jq/compare/jq-1.8.0...jq-1.8.1>.\n\n## Security fixes\n\n- CVE-2025-49014: Fix heap use after free in `f_strftime`, `f_strflocaltime`.\n  @wader 499c91bca9d4d027833bc62787d1bb075c03680e\n- GHSA-f946-j5j2-4w5m: Fix stack overflow in `node_min_byte_len` of oniguruma.\n  @wader 5e159b34b179417e3e0404108190a2ac7d65611c\n\n## CLI changes\n\n- Fix assertion failure when syntax error happens at the end of the query. @itchyny #3350\n\n## Changes to existing functions\n\n- Fix portability of `strptime/1` especially for Windows. @itchyny #3342\n\n## Language changes\n\n- Revert the change of `reduce`/`foreach` state variable in 1.8.0 (#3205).\n  This change was reverted due to serious performance regression. @itchyny #3349\n\n## Documentation changes\n\n- Add LICENSE notice of NetBSD's `strptime()` to COPYING. @itchyny #3344\n\n## Build improvements\n\n- Fix build on old Mac with old sed. @qianbinbin #3336\n\n# 1.8.0\n\nWe are pleased to announce the release of version 1.8.0.\nThis release includes a number of improvements since the last version.\nNote that some changes may introduce breaking changes to existing scripts,\nso be sure to read the following information carefully.\nFull commit log can be found at <https://github.com/jqlang/jq/compare/jq-1.7.1...jq-1.8.0>.\n\n## Releasing\n\n- Change the version number pattern to `1.X.Y` (`1.8.0` instead of `1.8`). @itchyny #2999\n- Generate provenance attestations for release artifacts and docker image. @lectrical #3225\n\n  ```sh\n  gh attestation verify --repo jqlang/jq jq-linux-amd64\n  gh attestation verify --repo jqlang/jq oci://ghcr.io/jqlang/jq:1.8.0\n  ```\n\n## Security fixes\n\n- CVE-2024-23337: Fix signed integer overflow in `jvp_array_write` and `jvp_object_rehash`.\n  @itchyny de21386681c0df0104a99d9d09db23a9b2a78b1e\n  - The fix for this issue now limits the maximum size of arrays and objects to 536870912 (`2^29`) elements.\n- CVE-2024-53427: Reject NaN with payload while parsing JSON.\n  @itchyny a09a4dfd55e6c24d04b35062ccfe4509748b1dd3\n  - The fix for this issue now drops support for NaN with payload in JSON (like `NaN123`).\n    Other JSON extensions like `NaN` and `Infinity` are still supported.\n- CVE-2025-48060: Fix heap buffer overflow in `jv_string_vfmt`.\n  @itchyny c6e041699d8cd31b97375a2596217aff2cfca85b\n- Fix use of uninitialized value in `check_literal`. @itchyny #3324\n- Fix segmentation fault on `strftime/1`, `strflocaltime/1`. @itchyny #3271\n- Fix unhandled overflow in `@base64d`. @emanuele6 #3080\n\n## CLI changes\n\n- Fix `--indent 0` implicitly enabling `--compact-output`. @amarshall @gbrlmarn @itchyny #3232\n\n  ```sh\n  $ jq --indent 0 . <<< '{ \"foo\": [\"hello\", \"world\"] }'\n  {\n  \"foo\": [\n  \"hello\",\n  \"world\"\n  ]\n  }\n  # Previously, this implied --compact-output, but now outputs with new lines.\n  ```\n\n- Improve error messages to show problematic position in the filter. @itchyny #3292\n\n  ```sh\n  $ jq -n '1 + $foo + 2'\n  jq: error: $foo is not defined at <top-level>, line 1, column 5:\n      1 + $foo + 2\n          ^^^^\n  jq: 1 compile error\n  ```\n\n- Include column number in parser and compiler error messages. @liviubobocu #3257\n- Fix error message for string literal beginning with single quote. @mattmeyers #2964\n\n  ```sh\n  $ jq .foo <<< \"{'foo':'bar'}\"\n  jq: parse error: Invalid string literal; expected \", but got ' at line 1, column 7\n  # Previously, the error message was Invalid numeric literal at line 1, column 7.\n  ```\n\n- Improve `JQ_COLORS` environment variable to support larger escapes like truecolor. @SArpnt #3282\n\n  ```sh\n  JQ_COLORS=\"38;2;255;173;173:38;2;255;214;165:38;2;253;255;182:38;2;202;255;191:38;2;155;246;255:38;2;160;196;255:38;2;189;178;255:38;2;255;198;255\" jq -nc '[null,false,true,42,{\"a\":\"bc\"}]'\n  ```\n\n- Add `--library-path` long option for `-L`. @thaliaarchi #3194\n- Fix `--slurp --stream` when input has no trailing newline character. @itchyny #3279\n- Fix `--indent` option to error for malformed values. @thaliaarchi #3195\n- Fix option parsing of `--binary` on non-Windows platforms. @calestyo #3131\n- Fix issue with `~/.jq` on Windows where `$HOME` is not set. @kirkoman #3114\n- Fix broken non-Latin output in the command help on Windows. @itchyny #3299\n- Increase the maximum parsing depth for JSON to 10000. @itchyny #3328\n- Parse short options in order given. @thaliaarchi #3194\n- Consistently reset color formatting. @thaliaarchi #3034\n\n## New functions\n\n- Add `trim/0`, `ltrim/0` and `rtrim/0` to trim leading and trailing white spaces. @wader #3056\n\n  ```sh\n  $ jq -n '\" hello \" | trim, ltrim, rtrim'\n  \"hello\"\n  \"hello \"\n  \" hello\"\n  ```\n\n- Add `trimstr/1` to trim string from both ends. @gbrlmarn #3319\n\n  ```sh\n  $ jq -n '\"foobarfoo\" | trimstr(\"foo\")'\n  \"bar\"\n  ```\n\n- Add `add/1`. Generator variant of `add/0`. @myaaaaaaaaa #3144\n\n  ```sh\n  $ jq -c '.sum = add(.xs[])' <<< '{\"xs\":[1,2,3]}'\n  {\"xs\":[1,2,3],\"sum\":6}\n  ```\n\n- Add `skip/2` as the counterpart to `limit/2`. @itchyny #3181\n\n  ```sh\n  $ jq -nc '[1,2,3,4,5] | [skip(2; .[])]'\n  [3,4,5]\n  ```\n\n- Add `toboolean/0` to convert strings to booleans. @brahmlower @itchyny #2098\n\n  ```sh\n  $ jq -n '\"true\", \"false\" | toboolean'\n  true\n  false\n  ```\n\n- Add `@urid` format. Reverse of `@uri`. @fmgornick #3161\n\n  ```sh\n  $ jq -Rr '@urid' <<< '%6a%71'\n  jq\n  ```\n\n## Changes to existing functions\n\n- Use code point index for `indices/1`, `index/1` and `rindex/1`. @wader #3065\n  - This is a breaking change. Use `utf8bytelength/0` to get byte index.\n- Improve `tonumber/0` performance and rejects numbers with leading or trailing\n  white spaces. @itchyny @thaliaarchi #3055 #3195\n  - This is a breaking change. Use `trim/0` to remove leading and trailing white spaces.\n- Populate timezone data when formatting time. This fixes timezone name in\n  `strftime/1`, `strflocaltime/1` for DST. @marcin-serwin @sihde #3203 #3264 #3323\n- Preserve numerical precision on unary negation, `abs/0`, `length/0`. @itchyny #3242 #3275\n- Make `last(empty)` yield no output values like `first(empty)`. @itchyny #3179\n- Make `ltrimstr/1` and `rtrimstr/1` error for non-string inputs. @emanuele6 #2969\n- Make `limit/2` error for negative count. @itchyny #3181\n- Fix `mktime/0` overflow and allow fewer elements in date-time representation array. @emanuele6 #3070 #3162\n- Fix non-matched optional capture group. @wader #3238\n- Provide `strptime/1` on all systems. @george-hopkins @fdellwing  #3008 #3094\n- Fix `_WIN32` port of `strptime`. @emanuele6 #3071\n- Improve `bsearch/1` performance by implementing in C. @eloycoto #2945\n- Improve `unique/0` and `unique_by/1` performance. @itchyny @emanuele6 #3254 #3304\n- Fix error messages including long string literal not to break Unicode characters. @itchyny #3249\n- Remove `pow10/0` as it has been deprecated in glibc 2.27. Use `exp10/0` instead. @itchyny #3059\n- Remove private (and undocumented) `_nwise` filter. @itchyny #3260\n\n## Language changes\n\n- Fix precedence of binding syntax against unary and binary operators.\n  Also, allow some expressions as object values. @itchyny #3053 #3326\n  - This is a breaking change that may change the output of filters with binding syntax as follows.\n\n  ```sh\n  $ jq -nc '[-1 as $x | 1,$x]'\n  [1,-1]    # previously, [-1,-1]\n  $ jq -nc '1 | . + 2 as $x | -$x'\n  -3        # previously, -1\n  $ jq -nc '{x: 1 + 2, y: false or true, z: null // 3}'\n  {\"x\":3,\"y\":true,\"z\":3}    # previously, syntax error\n  ```\n\n- Support Tcl-style multiline comments. @emanuele6 #2989\n\n  ```sh\n  #!/bin/sh --\n  # Can be use to do shebang scripts.\n  # Next line will be seen as a comment be of the trailing backslash. \\\n  exec jq ...\n  # this jq expression will result in [1]\n  [\n    1,\n    # \\\n    2\n  ]\n  ```\n\n- Fix `foreach` not to break init backtracking with `DUPN`. @kanwren #3266\n\n  ```sh\n  $ jq -n '[1, 2] | foreach .[] as $x (0, 1; . + $x)'\n  1\n  3\n  2\n  4\n  ```\n\n- Fix `reduce`/`foreach` state variable should not be reset each iteration. @itchyny #3205\n\n  ```sh\n  $ jq -n 'reduce range(5) as $x (0; .+$x | select($x!=2))'\n  8\n  $ jq -nc '[foreach range(5) as $x (0; .+$x | select($x!=2); [$x,.])]'\n  [[0,0],[1,1],[3,4],[4,8]]\n  ```\n\n- Support CRLF line breaks in filters. @itchyny #3274\n- Improve performance of repeating strings. @itchyny #3272\n\n## Documentation changes\n\n- Switch the homepage to custom domain [jqlang.org](https://jqlang.org). @itchyny @owenthereal #3243\n- Make latest release instead of development version the default manual. @wader #3130\n- Add opengraph meta tags. @wader #3247\n- Replace jqplay.org with play.jqlang.org @owenthereal #3265\n- Add missing line from decNumber's licence to `COPYING`. @emanuele6 #3106\n- Various document improvements. @tsibley #3322, @itchyny #3240, @jhcarl0814 #3239,\n  @01mf02 #3184, @thaliaarchi #3199, @NathanBaulch #3173, @cjlarose #3164,\n  @sheepster1 #3105, #3103, @kishoreinvits #3042, @jbrains #3035, @thalman #3033,\n  @SOF3 #3017, @wader #3015, @wllm-rbnt #3002\n\n## Build improvements\n\n- Fix build with GCC 15 (C23). @emanuele6 #3209\n- Fix build with `-Woverlength-strings` @emanuele6 #3019\n- Fix compiler warning `type-limits` in `found_string`. @itchyny #3263\n- Fix compiler error in `jv_dtoa.c` and `builtin.c`. @UlrichEckhardt #3036\n- Fix warning: a function definition without a prototype is deprecated. @itchyny #3259\n- Define `_BSD_SOURCE` in `builtin.c` for OpenBSD support. @itchyny #3278\n- Define empty `JV_{,V}PRINTF_LIKE` macros if `__GNUC__` is not defined. @emanuele6 #3160\n- Avoid `ctype.h` abuse: cast `char` to `unsigned char` first. @riastradh #3152\n- Remove multiple calls to free when successively calling `jq_reset`. @Sameesunkaria #3134\n- Enable IBM z/OS support. @sachintu47 #3277\n- Fix insecure `RUNPATH`. @orbea #3212\n- Avoid zero-length `calloc`. @itchyny #3280\n- Move oniguruma and decNumber to vendor directory. @itchyny #3234\n\n## Test improvements\n\n- Run tests in C locale. @emanuele6 #3039\n- Improve reliability of `NO_COLOR` tests. @dag-erling #3188\n- Improve `shtest` not to fail if `JQ_COLORS` and `NO_COLOR` are already set. @SArpnt #3283\n- Refactor constant folding tests. @itchyny #3233\n- Make tests pass when `--disable-decnum`. @nicowilliams 6d02d53f515bf1314d644eee93ba30b0d11c7d2b\n- Disable Valgrind by default during testing. @itchyny #3269\n\n# 1.7.1\n\n## Security\n\n- CVE-2023-50246: Fix heap buffer overflow in jvp\\_literal\\_number\\_literal\n- CVE-2023-50268: fix stack-buffer-overflow if comparing nan with payload\n\n## CLI changes\n\n- Make the default background color more suitable for bright backgrounds. @mjarosie @taoky @nicowilliams @itchyny #2904\n- Allow passing the inline jq script after `--`. @emanuele6 #2919\n- Restrict systems operations on OpenBSD and remove unused `mkstemp`. @klemensn #2934\n- Fix possible uninitialised value dereference if `jq_init()` fails. @emanuele6 @nicowilliams #2935\n\n## Language changes\n\n- Simplify `paths/0` and `paths/1`. @asheiduk @emanuele6 #2946\n- Reject `U+001F` in string literals. @torsten-schenk @itchyny @wader #2911\n- Remove unused nref accumulator in `block_bind_library`. @emanuele6 #2914\n- Remove a bunch of unused variables, and useless assignments. @emanuele6 #2914\n- main.c: Remove unused EXIT\\_STATUS\\_EXACT option. @emanuele6 #2915\n- Actually use the number correctly casted from double to int as index. @emanuele6 #2916\n- src/builtin.c: remove unnecessary jv\\_copy-s in type\\_error/type\\_error2. @emanuele6 #2937\n- Remove undefined behavior caught by LLVM 10 UBSAN. @Gaelan @emanuele6 #2926\n- Convert decnum to binary64 (double) instead of decimal64. This makes jq behave like the JSON specification suggests and more similar to other languages. @wader @leonid-s-usov #2949\n- Fix memory leaks on invalid input for `ltrimstr/1` and `rtrimstr/1`. @emanuele6 #2977\n- Fix memory leak on failed get for `setpath/2`. @emanuele6 #2970\n- Fix nan from json parsing also for nans with payload that start with 'n'. @emanuele6 #2985\n- Allow carriage return characters in comments. @emanuele6 #2942 #2984\n\n## Documentation changes\n\n- Generate links in the man page. @emanuele6 #2931\n- Standardize arch types to AMD64 & ARM64 from index page download dropdown. @owenthereal #2884\n\n## libjq\n\n- Add extern C for C++. @rockwotj #2953\n\n## Build and test changes\n\n- Fix incorrect syntax for checksum file. @kamontat @wader #2899\n- Remove `-dirty` version suffix for windows release build. @itchyny #2888\n- Make use of `od` in tests more compatible. @nabijaczleweli @emanuele6 @nicowilliams #2922\n- Add dependabot. @yeikel #2889\n- Extend fuzzing setup to fuzz parser and JSON serializer. @DavidKorczynski @emanuele6 #2952\n- Keep releasing executables with legacy names. @itchyny #2951\n\n# 1.7\n\nAfter a five year hiatus we're back with a GitHub organization, with new admins and new maintainers who have brought a great deal of energy to make a long-awaited and long-needed new release.  We're very grateful for all the new owners, admins, and maintainers.  Special thanks go to Owen Ou (@owenthereal) for pushing to set up a new GitHub organization for jq, Stephen Dolan (@stedolan) for transferring the jq repository to the new organization, @itchyny for doing a great deal of work to get the release done, Mattias Wadman (@wader) and Emanuele Torre (@emanuele6) for many PRs and code reviews.  Many others also contributed PRs, issues, and code reviews as well, and you can find their contributions in the Git log and on the [closed issues and PRs page](https://github.com/jqlang/jq/issues?q=is%3Aclosed+sort%3Aupdated-desc).\n\nSince the last stable release many things have happened:\n\n- jq now lives at <https://github.com/jqlang>\n- New maintainers, admins, and owners have been recruited.\n  - A list of [current maintainers](https://github.com/jqlang/jq/blob/jq-1.7/AUTHORS#L4-L14)\n- NEWS file is replaced by NEWS.md with Markdown format. @wader #2599\n- CI, scan builds, release, website builds etc now use GitHub actions. @owenthereal @wader @itchyny #2596 #2603 #2620 #2723\n- Lots of documentation improvements and fixes.\n- Website updated with new section search box, better section ids for linking, dark mode, etc. @itchyny #2628\n- Release builds for:\n  - Linux `amd64`, `arm64`, `armel`, `armhf`, `i386`, `mips`, `mips64`, `mips64el`, `mips64r6`, `mips64r6el`, `mipsel`, `mipsr6`, `mipsr6el`, `powerpc`, `ppc64el`, `riscv64` and `s390x`\n  - macOS `amd64` and `arm64`\n  - Windows `i386` and `amd64`\n  - Docker `linux/386`, `linux/amd64`, `linux/arm64`, `linux/mips64le`, `linux/ppc64le`, `linux/riscv64` and `linux/s390x`\n  - More details see @owenthereal #2665\n- Docker images are now available from `ghcr.io/jqlang/jq` instead of Docker Hub. @itchyny #2652 #2686\n- OSS-fuzz. @DavidKorczynski #2760 #2762\n\nFull commit log can be found at <https://github.com/jqlang/jq/compare/jq-1.6...jq-1.7> but here are some highlights:\n\n## CLI changes\n\n- Make object key color configurable using `JQ_COLORS` environment variable. @itchyny @haguenau @ericpruitt #2703\n\n  ```sh\n  # this would make \"field\" bold yellow (`1;33`, the last value)\n  $ JQ_COLORS=\"0;90:0;37:0;37:0;37:0;32:1;37:1;37:1;33\" ./jq -n '{field: 123}'\n  {\n    \"field\": 123\n  }\n  ```\n\n- Change the default color of null to Bright Black. @itchyny #2824\n- Respect `NO_COLOR` environment variable to disable color output. See <https://no-color.org> for details. @itchyny #2728\n- Improved `--help` output. Now mentions all options and nicer order. @itchyny @wader #2747 #2766 #2799\n- Fix multiple issues of exit code using `--exit-code`/`-e` option. @ryo1kato #1697\n\n  ```sh\n  # true-ish last output value exits with zero\n  $ jq -ne true ; echo $?\n  true\n  0\n  # false-ish last output value (false and null) exits with 1\n  $ jq -ne false ; echo $?\n  false\n  1\n  # no output value exists with 4\n  $ jq -ne empty ; echo $?\n  4\n  ```\n\n- Add `--binary`/`-b` on Windows for binary output. To get `\\n` instead of `\\r\\n` line endings. @nicowilliams 0dab2b1\n- Add `--raw-output0` for NUL (zero byte) separated output. @asottile @pabs3 @itchyny #1990 #2235 #2684\n\n  ```sh\n  # will output a zero byte after each output\n  $ jq -n --raw-output0 '1,2,3' | xxd\n  00000000: 3100 3200 3300                           1.2.3.\n  # can be used with xargs -0\n  $ jq -n --raw-output0 '\"a\",\"b\",\"c\"' | xargs -0 -n1\n  a\n  b\n  c\n  $ jq -n --raw-output0 '\"a b c\", \"d\\ne\\nf\"' | xargs -0 printf '[%s]\\n'\n  [a b c]\n  [d\n  e\n  f]\n  # can be used with read -d ''\n  $ while IFS= read -r -d '' json; do\n  >   jq '.name' <<< \"$json\"\n  > done < <(jq -n --raw-output0 '{name:\"a b c\"},{name:\"d\\ne\\nf\"}')\n  \"a b c\"\n  \"d\\ne\\nf\"\n  # also it's an error to output a string containing a NUL when using NUL separator\n  $ jq -n --raw-output0 '\"\\u0000\"'\n  jq: error (at <unknown>): Cannot dump a string containing NUL with --raw-output0 option\n  ```\n\n- Fix assert crash and validate JSON for `--jsonarg`. @wader #2658\n- Remove deprecated `--argfile` option. @itchyny #2768\n- Enable stack protection. @nicowilliams #2801\n\n## Language changes\n\n- Use decimal number literals to preserve precision. Comparison operations respects precision but arithmetic operations might truncate. @leonid-s-usov #1752\n\n  ```sh\n  # precision is preserved\n  $ echo '100000000000000000' | jq .\n  100000000000000000\n  # comparison respects precision (this is false in JavaScript)\n  $ jq -n '100000000000000000 < 100000000000000001'\n  true\n  # sort/0 works\n  $ jq -n -c '[100000000000000001, 100000000000000003, 100000000000000004, 100000000000000002] | sort'\n  [100000000000000001,100000000000000002,100000000000000003,100000000000000004]\n  # arithmetic operations might truncate (same as JavaScript)\n  $ jq -n '100000000000000000 + 10'\n  100000000000000020\n  ```\n\n- Adds new builtin `pick(stream)` to emit a projection of the input object or array. @pkoppstein #2656 #2779\n\n  ```sh\n  $ jq -n '{\"a\": 1, \"b\": {\"c\": 2, \"d\": 3}, \"e\": 4} | pick(.a, .b.c, .x)'\n  {\n    \"a\": 1,\n    \"b\": {\n      \"c\": 2\n    },\n    \"x\": null\n  }\n  ```\n\n- Adds new builtin `debug(msgs)` that works like `debug` but applies a filter on the input before writing to stderr. @pkoppstein #2710\n\n  ```sh\n  $ jq -n '1 as $x | 2 | debug(\"Entering function foo with $x == \\($x)\", .) | (.+1)'\n  [\"DEBUG:\",\"Entering function foo with $x == 1\"]\n  [\"DEBUG:\",2]\n  3\n  $ jq -n '{a: 1, b: 2, c: 3} | debug({a, b, sum: (.a+.b)})'\n  [\"DEBUG:\",{\"a\":1,\"b\":2,\"sum\":3}]\n  {\n    \"a\": 1,\n    \"b\": 2,\n    \"c\": 3\n  }\n  ```\n\n- Adds new builtin `scan($re; $flags)`. Was documented but not implemented. @itchyny #1961\n\n  ```sh\n  # look for pattern \"ab\" in \"abAB\" ignoring casing\n  $ jq -n '\"abAB\" | scan(\"ab\"; \"i\")'\n  \"ab\"\n  \"AB\"\n  ```\n\n- Adds new builtin `abs` to get absolute value. This potentially allows the literal value of numbers to be preserved as `length` and `fabs` convert to float. @pkoppstein #2767\n- Allow `if` without `else`-branch. When skipped the `else`-branch will be `.` (identity). @chancez @wader #1825 #2481\n\n  ```sh\n  # convert 1 to \"one\" otherwise keep as is\n  $ jq -n '1,2 | if . == 1 then \"one\" end'\n  \"one\"\n  2\n  # behaves the same as\n  $ jq -n '1,2 | if . == 1 then \"one\" else . end'\n  \"one\"\n  2\n  # also works with elif\n  $ jq -n '1,2,3 | if . == 1 then \"one\" elif . == 2 then \"two\" end\n  \"one\"\n  \"two\"\n  3\n  ```\n\n- Allow use of `$binding` as key in object literals. @nicowilliams 8ea4a55\n\n  ```sh\n  $ jq -n '\"a\" as $key | {$key: 123}'\n  {\n    \"a\": 123\n  }\n  # previously parentheses were needed\n  $ jq -n '\"a\" as $key | {($key): 123}'\n  {\n    \"a\": 123\n  }\n  ```\n\n- Allow dot between chained indexes when using `.[\"index\"]` @nicowilliams #1168\n\n  ```sh\n  $ jq -n '{\"a\": {\"b\": 123}} | .a[\"b\"]'\n  123\n  # now this also works\n  $ jq -n '{\"a\": {\"b\": 123}} | .a.[\"b\"]'\n  123\n  ```\n\n- Allow dot for chained value iterator `.[]`, `.[]?` @wader #2650\n\n  ```sh\n  $ jq -n '{\"a\": [123]} | .a[]'\n  123\n  # now this also works\n  $ jq -n '{\"a\": [123]} | .a.[]'\n  123\n  ```\n\n- Fix try/catch catches more than it should. @nicowilliams #2750\n- Speed up and refactor some builtins, also remove `scalars_or_empty/0`. @muhmuhten #1845\n- Now `halt` and `halt_error` exit immediately instead of continuing to the next input. @emanuele6 #2667\n- Fix issue converting string to number after previous convert error. @thalman #2400\n- Fix issue representing large numbers on some platforms causing invalid JSON output. @itchyny #2661\n- Fix deletion using assigning empty against arrays. @itchyny #2133\n\n  ```sh\n  # now this works as expected, filter out all values over 2 by assigning empty\n  $ jq -c '(.[] | select(. >= 2)) |= empty' <<< '[1,5,3,0,7]'\n  [1,0]\n  ```\n\n- Allow keywords to be used as binding name in more places. @emanuele6 #2681\n- Allow using `nan` as NaN in JSON. @emanuele6 #2712\n- Expose a module's function names in `modulemeta`. @mrwilson #2837\n- Fix `contains/1` to handle strings with NUL. @nicowilliams 61cd6db\n- Fix `stderr/0` to output raw text without any decoration. @itchyny #2751\n- Fix `nth/2` to emit empty on index out of range. @itchyny #2674\n- Fix `implode` to not assert and instead replace invalid Unicode codepoints. @wader #2646\n- Fix `indices/1` and `rindex/1` in case of overlapping matches in strings. @emanuele6 #2718\n- Fix `sub/3` to resolve issues involving global search-and-replace (gsub) operations. @pkoppstein #2641\n- Fix `significand/0`, `gamma/0` and `drem/2` to be available on macOS. @itchyny #2756 #2775\n- Fix empty regular expression matches. @itchyny #2677\n- Fix overflow exception of the modulo operator. @itchyny #2629\n- Fix string multiplication by 0 (and less than 1) to emit empty string. @itchyny #2142\n- Fix segfault when using libjq and threads. @thalman #2546\n- Fix constant folding of division and reminder with zero divisor. @itchyny #2797\n- Fix `error/0`, `error/1` to throw null error. @emanuele6 #2823\n- Simpler and faster `transpose`. @pkoppstein #2758\n- Simple and efficient implementation of `walk/1`. @pkoppstein #2795\n- Remove deprecated filters `leaf_paths`, `recurse_down`. @itchyny #2666\n\n# Previous releases\n\nRelease history\n\n- jq version 1.6 was released on Fri Nov 2 2018\n- jq version 1.5 was released on Sat Aug 15 2015\n- jq version 1.4 was released on Mon Jun 9 2014\n- jq version 1.3 was released on Sun May 19 2013\n- jq version 1.2 was released on Thu Dec 20 2012\n- jq version 1.1 was released on Sun Oct 21 2012\n- jq version 1.0 was released on Sun Oct 21 2012\n\nNew features in 1.6 since 1.5:\n\n- Destructuring Alternation\n\n- New Builtins:\n  - builtins/0\n  - stderr/0\n  - halt/0, halt_error/1\n  - isempty/1\n  - walk/1\n  - utf8bytelength/1\n  - localtime/0, strflocaltime/1\n  - SQL-style builtins\n  - and more!\n\n- Add support for ASAN and UBSAN\n\n- Make it easier to use jq with shebangs (8f6f28c)\n\n- Add $ENV builtin variable to access environment\n\n- Add JQ_COLORS env var for configuring the output colors\n\nNew features in 1.5 since 1.4:\n\n- regular expressions (with Oniguruma)\n\n- a library/module system\n\n- many new builtins\n\n  - datetime builtins\n  - math builtins\n  - regexp-related builtins\n  - stream-related builtins (e.g., all/1, any/1)\n  - minimal I/O builtins (`inputs`, `debug`)\n\n- new syntactic features, including:\n\n  - destructuring (`. as [$first, $second] | ...`)\n  - try/catch, generalized `?` operator, and label/break\n  - `foreach`\n  - multiple definitions of a function with different numbers of\n      arguments\n\n- command-line arguments\n\n  - --join-lines / -j for raw output\n  - --argjson and --slurpfile\n  - --tab and --indent\n  - --stream (streaming JSON parser)\n  - --seq (RFC7464 JSON text sequence)\n  - --run-tests improvements\n\n- optimizations:\n\n  - tail-call optimization\n  - reduce and foreach no longer leak a reference to .\n\nNew features in 1.4 since 1.3:\n\n- command-line arguments\n\n  - jq --arg-file variable file\n  - jq --unbuffered\n  - jq -e / --exit-status (set exit status based on outputs)\n  - jq -S / --sort-keys (now jq no longer sorts object keys by\n      default\n\n- syntax\n\n  - .. -> like // in XPath (recursive traversal)\n  - question mark (e.g., .a?) to suppress errors\n  - .\"foo\" syntax (equivalent to .[\"foo\"])\n  - better error handling for .foo\n  - added % operator (modulo)\n  - allow negation without requiring extra parenthesis\n  - more function arguments (up to six)\n\n- filters:\n\n  - any, all\n  - iterables, arrays, objects, scalars, nulls, booleans, numbers,\n      strings, values\n\n- string built-ins:\n\n  - split\n  - join (join an array of strings with a given separator string)\n  - ltrimstr, rtrimstr\n  - startswith, endswith\n  - explode, implode\n  - fromjson, tojson\n  - index, rindex, indices\n\n- math functions\n\n  - floor, sqrt, cbrt, etcetera (depends on what's available from libm)\n\n- libjq -- a C API interface to jq's JSON representation and for\n   running jq programs from C applications\n"
  },
  {
    "path": "README.md",
    "content": "# jq\n\n`jq` is a lightweight and flexible command-line JSON processor akin to `sed`,`awk`,`grep`, and friends for JSON data. It's written in portable C and has zero runtime dependencies, allowing you to easily slice, filter, map, and transform structured data.\n\n## Documentation\n\n- **Official Documentation**: [jqlang.org](https://jqlang.org)\n- **Try jq Online**: [play.jqlang.org](https://play.jqlang.org)\n\n## Installation\n\n### Prebuilt Binaries\n\nDownload the latest releases from the [GitHub release page](https://github.com/jqlang/jq/releases).\n\n### Docker Image\n\nPull the [jq image](https://github.com/jqlang/jq/pkgs/container/jq) to start quickly with Docker.\n\n#### Run with Docker\n\n##### Example: Extracting the version from a `package.json` file\n\n```bash\ndocker run --rm -i ghcr.io/jqlang/jq:latest < package.json '.version'\n```\n\n##### Example: Extracting the version from a `package.json` file with a mounted volume\n\n```bash\ndocker run --rm -i -v \"$PWD:$PWD\" -w \"$PWD\" ghcr.io/jqlang/jq:latest '.version' package.json\n```\n\n### Building from source\n\n#### Dependencies\n\n- libtool\n- make\n- automake\n- autoconf\n\n#### Instructions\n\n```console\ngit submodule update --init    # if building from git to get oniguruma\nautoreconf -i                  # if building from git\n./configure --with-oniguruma=builtin\nmake clean                     # if upgrading from a version previously built from source\nmake -j8\nmake check\nsudo make install\n```\n\nBuild a statically linked version:\n\n```console\nmake LDFLAGS=-all-static\n```\n\nIf you're not using the latest git version but instead building a released tarball (available on the release page), skip the `autoreconf` step, and flex or bison won't be needed.\n\n##### Cross-Compilation\n\nFor details on cross-compilation, check out the [GitHub Actions file](.github/workflows/ci.yml) and the [cross-compilation wiki page](https://github.com/jqlang/jq/wiki/Cross-compilation).\n\n## Community & Support\n\n- Questions & Help: [Stack Overflow (jq tag)](https://stackoverflow.com/questions/tagged/jq)\n- Chat & Community: [Join us on Discord](https://discord.gg/yg6yjNmgAC)\n- Wiki & Advanced Topics: [Explore the Wiki](https://github.com/jqlang/jq/wiki)\n\n## License\n\n`jq` is released under the [MIT License](COPYING). `jq`'s documentation is\nlicensed under the [Creative Commons CC BY 3.0](COPYING).\n`jq` uses parts of the open source C library \"decNumber\", which is distributed\nunder [ICU License](COPYING)\n"
  },
  {
    "path": "SECURITY.md",
    "content": "# How to report security vulnerabilities in `jq`\n\nGitHub has a [mechanism for private disclosure of vulnerabilities](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability) to repository owners and authorized persons such as maintainers.  The `jqlang/jq` repository now has this feature enabled.\n\n## Reporting a Vulnerability\n\nSee [Privately Reporting a Security Vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability).  Click on [`jqlang/jq`](https://github.com/jqlang/jq)'s [Security page](https://github.com/jqlang/jq/security) and click on [Report a vulnerability](https://github.com/jqlang/jq/security/advisories/new).  This will notify the owners and maintainers.  After submitting you'll get an option to start a private clone of `jqlang/jq` for collaboration with the maintainers.\n"
  },
  {
    "path": "compile-ios.sh",
    "content": "#!/usr/bin/env bash\n# Mac C. compile-ios.sh for JQ.\n\n# Defaults\nset -e\noniguruma='6.9.10'\n\nunset CFLAGS\nunset CXXFLAGS\nunset LDFLAGS\n\n# Parse args. \nusage(){\ncat << EOF\n${0##*/}: usage\n\n    Description:\n       This simple script builds oniguruma and jq for all *-apple-darwin devices.\n\n    Arguments:\n    --extra-cflags <arg>: Pass defines or includes to clang.\n    --extra-ldflags <arg>: Pass libs or includes to ld64.\n\n    --with-oniguruma <arg>: Change default version of onigurma from ${oniguruma}.\nEOF\nexit 1\n}\n\nwhile (( $# )); do\n   case \"$1\" in\n      --with-oniguruma) shift; oniguruma=\"${1}\" ;;\n\n      --extra-cflags) shift; export CFLAGS_=\"${1}\" ;;\n      --extra-ldflags) shift; export LDFLAGS_=\"${1}\" ;;\n\n      --help) usage ;;\n      *) echo -e \"Unknown option: ${1}\\n\"; usage ;;\n   esac\n   shift\ndone \n\n# Start building.\necho \"Building...\"\nMAKEJOBS=\"$(sysctl -n hw.ncpu || echo 1)\"\nCC_=\"$(xcrun -f clang || echo clang)\"\n\nonig_url=\"https://github.com/kkos/oniguruma/releases/download/v${oniguruma}/onig-${oniguruma}.tar.gz\"\nbuilddir=\"${TMPDIR:-/tmp}/${RANDOM:-'xxxxx'}-compile-ios-build\"\ncwd=\"$(realpath ${PWD} 2>/dev/null || echo ${PWD})\"\n\nt_exit() {\ncat << EOF\n\nA error as occurred.\n    oniguruma location: ${builddir}/onig/onig-${oniguruma}\n    jq location: ${cwd}\n\n    Provide config.log and console logs when posting a issue.\n\nEOF\n}\ntrap t_exit ERR\n\n#  Onig.\nmkdir -p \"${builddir}/onig\"\ncd \"${builddir}/\"\n curl -L ${onig_url} | tar xz\n for arch in i386 x86_64 armv7 armv7s arm64; do\n     if [[ \"$arch\" = \"i386\" || \"$arch\" = \"x86_64\" ]]; then\n         SYSROOT=$(xcrun -f --sdk iphonesimulator --show-sdk-path)\n     else\n         SYSROOT=$(xcrun -f --sdk iphoneos --show-sdk-path)\n     fi\n     HOST=\"${arch}-apple-darwin\"\n     [[ \"${arch}\" = \"arm64\" ]] && HOST=\"aarch64-apple-darwin\"\n\n     CFLAGS=\"-arch ${arch} -miphoneos-version-min=9.0 -isysroot ${SYSROOT} ${CFLAGS_} -D_REENTRANT\"\n     LDFLAGS=\"-arch ${arch} -miphoneos-version-min=9.0 -isysroot ${SYSROOT} ${LDFLAGS_}\"\n     CC=\"${CC_} ${CFLAGS}\"\n\n     # ./configure; make install\n     cd \"${builddir}/onig-${oniguruma}\"\n     CC=${CC} LDFLAGS=${LDFLAGS} \\\n     ./configure --host=${HOST} --build=$(./config.guess) --enable-shared=no --enable-static=yes --prefix=/\n     make -j${MAKEJOBS} install DESTDIR=\"${cwd}/ios/onig/${arch}\"\n     make clean\n     \n     # Jump back to JQ.\n     cd ${cwd}\n     [[ ! -f ./configure ]] && autoreconf -ivf\n     CC=${CC} LDFLAGS=${LDFLAGS} \\\n     ./configure --host=${HOST} --build=$(./config/config.guess) --enable-docs=no --enable-shared=no --enable-static=yes --prefix=/ --with-oniguruma=${cwd}/ios/onig/${arch} $(test -z ${BISON+x} || echo '--enable-maintainer-mode')\n     make -j${MAKEJOBS} install DESTDIR=\"${cwd}/ios/jq/${arch}\"\n     make clean\n done\n\nmkdir -p \"${cwd}/ios/dest/lib\"\n# lipo, make a static lib.\nlipo -create -output ${cwd}/ios/dest/lib/libonig.a ${cwd}/ios/onig/{i386,x86_64,armv7,armv7s,arm64}/lib/libonig.a\nlipo -create -output ${cwd}/ios/dest/lib/libjq.a ${cwd}/ios/jq/{i386,x86_64,armv7,armv7s,arm64}/lib/libjq.a\n\n# Take the arm64 headers- the most common target.\ncp -r ${cwd}/ios/jq/arm64/include ${cwd}/ios/dest/\nrm -rf ${cwd}/build/ios/{i386,x86_64,armv7,armv7s,arm64}\n\necho \"Output to ${cwd}/ios/dest\"\n"
  },
  {
    "path": "config/.gitignore",
    "content": "config.guess\nconfig.sub\ncompile\ndepcomp\ninstall-sh\nltmain.sh\nmissing\nylwrap\ntest-driver\nar-lib\n"
  },
  {
    "path": "config/m4/.gitignore",
    "content": "libtool.m4\nlt*.m4"
  },
  {
    "path": "config/m4/check-math-func.m4",
    "content": "dnl AC_CHECK_MATH_FUNC(func)\nAC_DEFUN([AC_CHECK_MATH_FUNC], [\n  AC_LANG(C)\n  AC_CHECK_LIB([m],[$1],[\n    m4_define([ac_tr_func], [HAVE_]m4_toupper($1))\n    AC_DEFINE(ac_tr_func, 1, [Define if you have the $1 math function.])\n  ],[\n  ])\n])\n"
  },
  {
    "path": "config/m4/find-func-no-libs.m4",
    "content": "dnl Shamelessly stolen from Heimdal\ndnl\ndnl Look for function in any of the specified libraries\ndnl\n\ndnl AC_FIND_FUNC_NO_LIBS(func, libraries, includes, arguments, extra libs, extra args)\nAC_DEFUN([AC_FIND_FUNC_NO_LIBS], [\nAC_FIND_FUNC_NO_LIBS2([$1], [\"\" $2], [$3], [$4], [$5], [$6])])\n"
  },
  {
    "path": "config/m4/find-func-no-libs2.m4",
    "content": "dnl Shamelessly stolen from Heimdal\ndnl\ndnl Look for function in any of the specified libraries\ndnl\n\ndnl AC_FIND_FUNC_NO_LIBS2(func, libraries, includes, arguments, extra libs, extra args)\nAC_DEFUN([AC_FIND_FUNC_NO_LIBS2], [\n\nAC_MSG_CHECKING([for $1])\nAC_CACHE_VAL(ac_cv_funclib_$1,\n[\nif eval \"test \\\"\\$ac_cv_func_$1\\\" != yes\" ; then\n\tac_save_LIBS=\"$LIBS\"\n\tfor ac_lib in $2; do\n\t\tcase \"$ac_lib\" in\n\t\t\"\") ;;\n\t\tyes) ac_lib=\"\" ;;\n\t\tno) continue ;;\n\t\t-l*) ;;\n\t\t*) ac_lib=\"-l$ac_lib\" ;;\n\t\tesac\n\t\tLIBS=\"$6 $ac_lib $5 $ac_save_LIBS\"\n\t\tAC_LINK_IFELSE([AC_LANG_PROGRAM([[$3]],[[$1($4)]])],[eval \"if test -n \\\"$ac_lib\\\";then ac_cv_funclib_$1=$ac_lib; else ac_cv_funclib_$1=yes; fi\";break])\n\tdone\n\teval \"ac_cv_funclib_$1=\\${ac_cv_funclib_$1-no}\"\n\tLIBS=\"$ac_save_LIBS\"\nfi\n])\n\neval \"ac_res=\\$ac_cv_funclib_$1\"\n\nif false; then\n\tAC_CHECK_FUNCS($1)\ndnl\tAC_CHECK_LIBS($2, foo)\nfi\n# $1\neval \"ac_tr_func=HAVE_[]upcase($1)\"\neval \"ac_tr_lib=HAVE_LIB[]upcase($ac_res | sed -e 's/-l//')\"\neval \"LIB_$1=$ac_res\"\n\ncase \"$ac_res\" in\n\tyes)\n\teval \"ac_cv_func_$1=yes\"\n\teval \"LIB_$1=\"\n\tAC_DEFINE_UNQUOTED($ac_tr_func, 1, [Define if the $1 function is available.])\n\tAC_MSG_RESULT([yes])\n\t;;\n\tno)\n\teval \"ac_cv_func_$1=no\"\n\teval \"LIB_$1=\"\n\tAC_MSG_RESULT([no])\n\t;;\n\t*)\n\teval \"ac_cv_func_$1=yes\"\n\teval \"ac_cv_lib_`echo \"$ac_res\" | sed 's/-l//'`=yes\"\n\tAC_DEFINE_UNQUOTED($ac_tr_func, 1, [Define if you have the $1 function.])\n\tAC_DEFINE_UNQUOTED($ac_tr_lib, 1, [Define if you have the $2 library.])\n\tAC_MSG_RESULT([yes, in $ac_res])\n\t;;\nesac\nAC_SUBST(LIB_$1)\n])\n"
  },
  {
    "path": "config/m4/find-func.m4",
    "content": "dnl Shamelessly stolen from Heimdal\ndnl\ndnl AC_FIND_FUNC(func, libraries, includes, arguments)\nAC_DEFUN([AC_FIND_FUNC], [\nAC_FIND_FUNC_NO_LIBS([$1], [$2], [$3], [$4])\nif test -n \"$LIB_$1\"; then\n\tLIBS=\"$LIB_$1 $LIBS\"\nfi\n])\n"
  },
  {
    "path": "config/m4/misc.m4",
    "content": "\ndnl Shamelessly stolen from Heimdal\nAC_DEFUN([upcase],[`echo $1 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`])dnl\n"
  },
  {
    "path": "configure.ac",
    "content": "m4_define([jq_version], m4_esyscmd_s([scripts/version])))\n\nAC_INIT([jq],[jq_version],[https://github.com/jqlang/jq/issues],[jq],[https://jqlang.org])\n\ndnl Created autoconf implementation thompson@dtosolutions, 26NOV12\nAC_PREREQ([2.65])\nAC_CONFIG_AUX_DIR([config])\nAC_USE_SYSTEM_EXTENSIONS\nAM_INIT_AUTOMAKE([1.11.2 subdir-objects parallel-tests foreign -Wall])\nAM_SILENT_RULES([yes])\nAM_PROG_AR\nAM_MAINTAINER_MODE([disable])\nAC_PROG_CC\nm4_version_prereq([2.70], [], [AC_PROG_CC_STDC])\nAC_PROG_CPP_WERROR\nAC_PROG_YACC\nAC_OBJEXT\nAC_EXEEXT\nLT_INIT([shared static win32-dll])\nAM_PROG_CC_C_O\n\nAC_SYS_LARGEFILE # issue 2167\n\ndnl couldn't use AM_PROG_LEX as it doesn't support header files like the\ndnl AC_PROG_YACC macros...\n\ndnl check bison version\n\nif test \"$USE_MAINTAINER_MODE\" = yes; then\n  if test \"$YACC\" != \"bison -y\"; then\n    AC_MSG_CHECKING([bison version])\n    AC_MSG_RESULT([not bison])\n  else\n    AX_PROG_BISON_VERSION([3],\n      [],\n      [AC_MSG_ERROR([You need bison version 3.0 or greater])])\n  fi\n\n  AC_CHECK_PROGS(LEX, flex lex)\nfi\n\nAC_CHECK_FUNCS(memmem)\n\nAC_CHECK_HEADER(\"sys/cygwin.h\", [have_cygwin=1;])\nAC_CHECK_HEADER(\"shlwapi.h\",[have_shlwapi=1;])\nAM_CONDITIONAL([WIN32], [test \"x$have_shlwapi\" = x1 && test ! \"x$have_cygwin\" = x1])\n\ndnl Running tests with Valgrind is slow. It is faster to iterate on\ndnl code without Valgrind until tests pass, then enable Valgrind and\ndnl fix leaks.\nAC_ARG_ENABLE([valgrind],\n   AS_HELP_STRING([--enable-valgrind],[enable Valgrind during testing]))\n\ndnl Address sanitizer (ASan)\nAC_ARG_ENABLE([asan],\n   AS_HELP_STRING([--enable-asan],[enable address sanitizer]))\n\ndnl Undefined Behavior Sanitizer\nAC_ARG_ENABLE([ubsan],\n   AS_HELP_STRING([--enable-ubsan],[enable undefined behavior sanitizer]))\n\ndnl Code coverage\nAC_ARG_ENABLE([gcov],\n   AS_HELP_STRING([--enable-gcov],[enable gcov code coverage tool]))\n\ndnl Don't attempt to build docs if python deps aren't installed\nAC_ARG_ENABLE([docs],\n   AS_HELP_STRING([--disable-docs],[do not build docs]), [], [enable_docs=yes])\n\ndnl Don't attempt to build the error injection object (if there is no LD_PRELOAD support)\nAC_ARG_ENABLE([error-injection],\n   AS_HELP_STRING([--enable-error-injection],[build and test with error injection]))\n\ndnl Enable building all static\nAC_ARG_ENABLE([all-static],\n   AS_HELP_STRING([--enable-all-static],[link jq with static libraries only]))\n\ndnl find pipenv\nAC_ARG_VAR([PIPENV], [pipenv command])\nAC_CHECK_PROGS([PIPENV], pipenv)\n\nAS_IF([test \"x$enable_docs\" != \"xno\"],[\n   AC_CACHE_CHECK([for Python dependencies], [jq_cv_python_deps],[\n      jq_cv_python_deps=yes\n      AS_IF([test \"x$PIPENV\" = \"x\" || \\\n      ! bmsg=\"`cd ${srcdir}/docs; LC_ALL=$LANG \"$PIPENV\" --venv`\"],[\n         jq_cv_python_deps=no\n      ])\n   ])\n\n   AS_IF([test \"x$jq_cv_python_deps\" != \"xyes\"], [\n      AC_MSG_WARN([Error checking python dependencies: $bmsg\n*****************************************************************\n*  Python dependencies for building jq documentation not found. *\n*  You can still build, install and hack on jq, but the manpage *\n*  will not be rebuilt and new manpage tests will not be run.   *\n*  See docs/README.md for how to install the docs dependencies. *\n*****************************************************************])\n      enable_docs=no\n   ])\n])\n\ndnl Disable decNumber support\nAC_ARG_ENABLE([decnum],\n   AS_HELP_STRING([--disable-decnum],[disable decnum support]))\n\nAS_IF([test \"x$enable_decnum\" != \"xno\"],[\n   AC_DEFINE([USE_DECNUM], 1, [Define to enable decnum support.])\n])\n\nAM_CONDITIONAL([ENABLE_VALGRIND], [test \"x$enable_valgrind\" = xyes])\nAM_CONDITIONAL([ENABLE_ASAN], [test \"x$enable_asan\" = xyes])\nAM_CONDITIONAL([ENABLE_UBSAN], [test \"x$enable_ubsan\" = xyes])\nAM_CONDITIONAL([ENABLE_GCOV], [test \"x$enable_gcov\" = xyes])\nAM_CONDITIONAL([ENABLE_DOCS], [test \"x$enable_docs\" != xno])\nAM_CONDITIONAL([ENABLE_ERROR_INJECTION], [test \"x$enable_error_injection\" = xyes])\nAM_CONDITIONAL([ENABLE_ALL_STATIC], [test \"x$enable_all_static\" = xyes])\n\ndnl Find pthread, if we have it. We do this first because we may set -pthread on CFLAGS\ndnl which can cause various macros to be defined (__REENTRANT on Darwin, for example)\nAX_PTHREAD([\n   AC_DEFINE([HAVE_PTHREAD], [1], [Define to enable POSIX threads support.])\n   LIBS=\"$PTHREAD_LIBS $LIBS\"\n   CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n   CC=\"$PTHREAD_CC\"\n])\n\nAC_FUNC_ALLOCA\n\nAC_FIND_FUNC([isatty], [c], [#include <unistd.h>], [0])\nAC_FIND_FUNC([_isatty], [c], [#include <io.h>], [0])\nAC_FIND_FUNC([strptime], [c], [#include <time.h>], [0, 0, 0])\nAC_FIND_FUNC([strftime], [c], [#include <time.h>], [0, 0, 0, 0])\nAC_FIND_FUNC([setenv], [c], [#include <stdlib.h>], [0, 0, 0])\nAC_FIND_FUNC([timegm], [c], [#include <time.h>], [0])\nAC_FIND_FUNC([gmtime_r], [c], [#include <time.h>], [0, 0])\nAC_FIND_FUNC([gmtime], [c], [#include <time.h>], [0])\nAC_FIND_FUNC([localtime_r], [c], [#include <time.h>], [0, 0])\nAC_FIND_FUNC([localtime], [c], [#include <time.h>], [0])\nAC_FIND_FUNC([gettimeofday], [c], [#include <sys/time.h>], [0, 0])\nAC_CHECK_MEMBER([struct tm.tm_gmtoff], [AC_DEFINE([HAVE_TM_TM_GMT_OFF],1,[Define to 1 if the system has the tm_gmt_off field in struct tm])],\n                [], [[#include <time.h>]])\nAC_CHECK_MEMBER([struct tm.__tm_gmtoff], [AC_DEFINE([HAVE_TM___TM_GMT_OFF],1,[Define to 1 if the system has the __tm_gmt_off field in struct tm])],\n                [], [[#include <time.h>]])\nAC_FIND_FUNC([setlocale], [c], [#include <locale.h>], [0,0])\n\ndnl Figure out if we have the pthread functions we actually need\nAC_FIND_FUNC_NO_LIBS([pthread_key_create], [], [#include <pthread.h>], [NULL, NULL])\nAC_FIND_FUNC_NO_LIBS([pthread_once], [], [#include <pthread.h>], [NULL, NULL])\nAC_FIND_FUNC_NO_LIBS([atexit], [], [#include <stdlib.h>], [NULL])\n\ndnl libm math.h functions\nAC_CHECK_MATH_FUNC(acos)\nAC_CHECK_MATH_FUNC(acosh)\nAC_CHECK_MATH_FUNC(asin)\nAC_CHECK_MATH_FUNC(asinh)\nAC_CHECK_MATH_FUNC(atan2)\nAC_CHECK_MATH_FUNC(atan)\nAC_CHECK_MATH_FUNC(atanh)\nAC_CHECK_MATH_FUNC(cbrt)\nAC_CHECK_MATH_FUNC(ceil)\nAC_CHECK_MATH_FUNC(copysign)\nAC_CHECK_MATH_FUNC(cos)\nAC_CHECK_MATH_FUNC(cosh)\nAC_CHECK_MATH_FUNC(drem)\nAC_CHECK_MATH_FUNC(erf)\nAC_CHECK_MATH_FUNC(erfc)\nAC_CHECK_MATH_FUNC(exp10)\nAC_CHECK_MATH_FUNC(__exp10) dnl macOS has an __exp10\nAC_CHECK_MATH_FUNC(exp2)\nAC_CHECK_MATH_FUNC(exp)\nAC_CHECK_MATH_FUNC(expm1)\nAC_CHECK_MATH_FUNC(fabs)\nAC_CHECK_MATH_FUNC(fdim)\nAC_CHECK_MATH_FUNC(floor)\nAC_CHECK_MATH_FUNC(fma)\nAC_CHECK_MATH_FUNC(fmax)\nAC_CHECK_MATH_FUNC(fmin)\nAC_CHECK_MATH_FUNC(fmod)\nAC_CHECK_MATH_FUNC(frexp)\nAC_CHECK_MATH_FUNC(gamma)\nAC_CHECK_MATH_FUNC(hypot)\nAC_CHECK_MATH_FUNC(j0)\nAC_CHECK_MATH_FUNC(j1)\nAC_CHECK_MATH_FUNC(jn)\nAC_CHECK_MATH_FUNC(ldexp)\nAC_CHECK_MATH_FUNC(lgamma)\nAC_CHECK_MATH_FUNC(log10)\nAC_CHECK_MATH_FUNC(log1p)\nAC_CHECK_MATH_FUNC(log2)\nAC_CHECK_MATH_FUNC(log)\nAC_CHECK_MATH_FUNC(logb)\nAC_CHECK_MATH_FUNC(modf)\nAC_CHECK_MATH_FUNC(lgamma_r)\nAC_CHECK_MATH_FUNC(nearbyint)\nAC_CHECK_MATH_FUNC(nextafter)\nAC_CHECK_MATH_FUNC(nexttoward)\nAC_CHECK_MATH_FUNC(pow)\nAC_CHECK_MATH_FUNC(remainder)\nAC_CHECK_MATH_FUNC(rint)\nAC_CHECK_MATH_FUNC(round)\nAC_CHECK_MATH_FUNC(scalb)\nAC_CHECK_MATH_FUNC(scalbln)\nAC_CHECK_MATH_FUNC(significand)\ndnl scalbn and ilogb are used on macos to replace significand if we don't have frexp\nAC_CHECK_MATH_FUNC(scalbn)\nAC_CHECK_MATH_FUNC(ilogb)\n\nAC_CHECK_MATH_FUNC(sin)\nAC_CHECK_MATH_FUNC(sinh)\nAC_CHECK_MATH_FUNC(sqrt)\nAC_CHECK_MATH_FUNC(tan)\nAC_CHECK_MATH_FUNC(tanh)\nAC_CHECK_MATH_FUNC(tgamma)\nAC_CHECK_MATH_FUNC(trunc)\nAC_CHECK_MATH_FUNC(y0)\nAC_CHECK_MATH_FUNC(y1)\nAC_CHECK_MATH_FUNC(yn)\n\ndnl Thread local storage\nhave___thread=no\nAC_MSG_CHECKING(for thread-local storage)\nAC_LINK_IFELSE([AC_LANG_SOURCE([\nstatic __thread int x ;\nint main () { x = 123; return x; }\n])], have___thread=yes)\nif test $have___thread = yes; then\n   AC_DEFINE([HAVE___THREAD],1,[Define to 1 if the system supports __thread])\nfi\nAC_MSG_RESULT($have___thread)\n\nAC_C_BIGENDIAN(\n   AC_DEFINE([IEEE_MC68k], 1, [machine is bigendian]),\n   AC_DEFINE([IEEE_8087], 1, [machine is littleendian]),\n   AC_MSG_ERROR(unknown endianness),\n   AC_MSG_ERROR(universal endianness not supported)\n)\n\ndnl Oniguruma\nAC_ARG_WITH([oniguruma],\n   [AS_HELP_STRING([--with-oniguruma=prefix],\n      [try this for a non-standard install prefix of the oniguruma library])], ,\n   [with_oniguruma=yes])\n\nonig_CFLAGS=\nonig_LDFLAGS=\nbuild_oniguruma=no\nAS_IF([test \"x$with_oniguruma\" != xno], [\n   save_CFLAGS=\"$CFLAGS\"\n   save_LDFLAGS=\"$LDFLAGS\"\n   AS_IF([test \"x$with_oniguruma\" != xyes], [\n      AS_IF([test \"x$with_oniguruma\" = xbuiltin], [\n          build_oniguruma=yes\n      ], [\n          onig_CFLAGS=\"-I${with_oniguruma}/include\"\n          onig_LDFLAGS=\"-L${with_oniguruma}/lib\"\n      ])\n   ])\n   AS_IF([test \"x$build_oniguruma\" = xno], [\n       # check for ONIGURUMA library, either in /usr or where requested\n       CFLAGS=\"$CFLAGS $onig_CFLAGS\"\n       LDFLAGS=\"$LDFLAGS $onig_LDFLAGS\"\n       AC_CHECK_HEADER(\"oniguruma.h\",\n          AC_CHECK_LIB([onig],[onig_version]))\n       # handle check results\n       AS_IF([test \"x$ac_cv_lib_onig_onig_version\" != \"xyes\"], [\n          build_oniguruma=yes\n          AC_MSG_NOTICE([Oniguruma was not found. Will use the packaged oniguruma.])\n       ])\n   ])\n   AS_IF([test \"x$build_oniguruma\" = xyes && test -f \"${srcdir}/vendor/oniguruma/configure.ac\" ], [\n       onig_CFLAGS=\"-I${srcdir}/vendor/oniguruma/src\"\n       onig_LDFLAGS=\"-L${srcdir}/vendor/oniguruma/src -Wl,-rpath,${libdir}\"\n       AC_CONFIG_SUBDIRS([vendor/oniguruma])\n       AC_DEFINE([HAVE_LIBONIG],1,[Define to 1 if the system includes libonig])\n   ])\n   CFLAGS=\"$save_CFLAGS\"\n   LDFLAGS=\"$save_LDFLAGS\"\n])\nAC_SUBST(onig_CFLAGS)\nAC_SUBST(onig_LDFLAGS)\n\nAM_CONDITIONAL([BUILD_ONIGURUMA], [test \"x$build_oniguruma\" = xyes])\nAM_CONDITIONAL([WITH_ONIGURUMA], [test \"x$with_oniguruma\" != xno])\n\nAC_CONFIG_MACRO_DIRS([config/m4 m4])\nAC_CONFIG_FILES([Makefile libjq.pc])\nAC_OUTPUT\n\n"
  },
  {
    "path": "docs/Pipfile",
    "content": "[[source]]\nname = \"pypi\"\nurl = \"https://pypi.org/simple\"\nverify_ssl = true\n\n[dev-packages]\n\n[packages]\njinja2 = \"*\"\npyyaml = \"*\"\nmarkdown = \"*\"\nlxml = \"*\"\njsonschema = \"*\"\nimportlib_resources = \"*\"\n"
  },
  {
    "path": "docs/README.md",
    "content": "Documentation\n=============\n\nThe jq website, manpages and some of the tests are generated from this\ndirectory. The manual is a YAML file in `content/manual`.\n\nTo build the documentation (including building the jq manpage), you'll\nneed `python3` and `pipenv`. You can install `pipenv` like so:\n\n    pip install pipenv\n\nThough, you may need to say `pip3` instead, depending on your system. Once\nyou have `pipenv` installed, you can install the dependencies by running\n`pipenv sync` from the `docs/` directory.\n\nAlso, you may need to run `virtualenv -p /usr/bin/python3 venv/` and\nthen `source venv/bin/activate`, and only then `pipenv sync`.\n\nOnce this is done, rerun `./configure --enable-docs` in the jq root directory and then\nthe `Makefile` will be able to generate the jq manpage.  You can just run\n`make jq.1` to build the manpage manually, and `make tests/man.test` to\nupdate the manual tests.\n\nTo build the website, run `pipenv run python3 build_website.py` in the `docs/` directory.\nTo serve them locally, you can run `python3 -m http.server -d output`.\n"
  },
  {
    "path": "docs/build_manpage.py",
    "content": "#!/usr/bin/env python3\nfrom datetime import date\nfrom io import StringIO\nfrom lxml import etree\nimport markdown\nfrom markdown.extensions import Extension\nimport re\nimport sys\nimport yaml\n\n\n# Prevent our markdown parser from trying to help by interpreting things in angle brackets as HTML tags.\nclass EscapeHtml(Extension):\n\n    def extendMarkdown(self, md):\n        md.preprocessors.deregister('html_block')\n        md.inlinePatterns.deregister('html')\n\n\nclass RoffWalker(object):\n\n    def __init__(self, tree, output=sys.stdout):\n        self.tree = tree\n        self.target = output\n        self.f = StringIO()\n\n    def walk(self):\n        self._walk(self.tree, parent_tag=None)\n        # We don't want to start lines with \\. because that can confuse man\n        # For lines that start with \\., we need to prefix them with \\& so it\n        # knows not to treat that line as a directive\n        data = re.sub(r'^\\\\\\.', r'\\&.', self.f.getvalue(), flags=re.MULTILINE)\n        self.target.write(data)\n\n    def _ul_is_special(self, root):\n        if len(root) != 1:\n            return False\n        child = root[0]\n        if child.tag != 'li':\n            return False\n        msg = ''.join(child.itertext()).strip()\n        return msg.endswith(':')\n\n    def _walk_child(self, root):\n        if len(root) > 0:\n            self._walk(root[0], parent_tag=root.tag)\n\n    def _write_element(self, root, ensure_newline=True):\n        if root.text is not None:\n            text = self._sanitize(root.text)\n            self.__write_raw(text)\n        self._walk_child(root)\n        self._write_tail(root, ensure_newline=ensure_newline)\n\n    def _write_tail(self, root, ensure_newline=False, inline=False):\n        if root.tail is not None:\n            if inline or root.tail != '\\n':\n                text = self._sanitize(root.tail)\n                if text.endswith('\\n'):\n                    ensure_newline = False\n                self.__write_raw(text)\n        if ensure_newline:\n            self.__write_raw('\\n')\n\n    def _walk(self, root, parent_tag=None):\n        last_tag = None\n        while root is not None:\n            if root.tag == 'h1':\n                self.__write_cmd('.TH \"JQ\" \"1\" \"{}\" \"\" \"\"'.format(\n                    date.today().strftime('%B %Y')))\n                self.__write_cmd('.SH \"NAME\"')\n                # TODO: properly parse this\n                self.__write_raw(r'\\fBjq\\fR \\- Command\\-line JSON processor' +\n                                 \"\\n\")\n\n            elif root.tag == 'h2':\n                self.__write_cmd('.SH \"{}\"'.format(''.join(\n                    root.itertext()).strip()))\n\n            elif root.tag == 'h3':\n                text = ''.join(root.itertext()).strip()\n                self.__write_cmd('.SS \"{}\"'.format(self._h3_sanitize(text)))\n\n            elif root.tag == 'p':\n                if last_tag not in ['h2', 'h3'] and parent_tag not in ['li']:\n                    self.__write_cmd('.P')\n                self._write_element(root, ensure_newline=(parent_tag != 'li'))\n\n            elif root.tag == 'a':\n                self._write_element(root, ensure_newline=(parent_tag != 'li'))\n\n            elif root.tag == 'ul':\n                if self._ul_is_special(root):\n                    li = root[0]\n                    self.__write_cmd('.TP')\n                    self._write_element(li)\n                    next = root.getnext()\n                    while next is not None and next.tag == 'p':\n                        if next.getnext() is not None and next.getnext(\n                        ).tag == 'pre':\n                            # we don't want to .IP these, because it'll look funny with the code indent\n                            break\n                        self.__write_cmd('.IP')\n                        self._write_element(next)\n                        root = next\n                        next = root.getnext()\n                else:\n                    self._walk_child(root)\n                    self._write_tail(root)\n                    # A pre tag after the end of a list doesn't want two of the indentation commands\n                    if root.getnext() is None or root.getnext().tag != 'pre':\n                        self.__write_cmd('.IP \"\" 0')\n\n            elif root.tag == 'li':\n                self.__write_cmd(r'.IP \"\\(bu\" 4')\n                if root.text is not None and root.text.strip() != '':\n                    text = self._sanitize(root.text)\n                    self.__write_raw(text)\n                self._walk_child(root)\n                self._write_tail(root, ensure_newline=True)\n\n            elif root.tag == 'strong':\n                if root.text is not None:\n                    text = self._sanitize(root.text)\n                    self.__write_raw('\\\\fB{}\\\\fR'.format(text))\n\n                self._write_tail(root, inline=True)\n\n            elif root.tag == 'em':\n                if root.text is not None:\n                    text = self._sanitize(root.text)\n                    self.__write_raw('\\\\fI{}\\\\fR'.format(text))\n                self._write_tail(root, inline=True)\n\n            elif root.tag == 'code':\n                if root.text is not None:\n                    text = self._code_sanitize(root.text)\n                    self.__write_raw('\\\\fB{}\\\\fR'.format(text))\n                self._write_tail(root, inline=True)\n\n            elif root.tag == 'pre':\n                self.__write_cmd('.IP \"\" 4')\n                self.__write_cmd('.nf\\n')  # extra newline for spacing reasons\n                next = root\n                first = True\n                while next is not None and next.tag == 'pre':\n                    if not first:\n                        self.__write_raw('\\n')\n                    text = ''.join(next.itertext(with_tail=False))\n                    self.__write_raw(self._pre_sanitize(text))\n                    first = False\n                    root = next\n                    next = next.getnext()\n                self.__write_cmd('.fi')\n                self.__write_cmd('.IP \"\" 0')\n\n            else:\n                self._walk_child(root)\n\n            last_tag = root.tag\n            root = root.getnext()\n\n    def _base_sanitize(self, text):\n        text = re.sub(r'\\\\', r'\\\\e', text)\n        text = re.sub(r'\\.', r'\\\\.', text)\n        text = re.sub(\"'\", r\"\\'\", text)\n        text = re.sub('-', r'\\-', text)\n        return text\n\n    def _pre_sanitize(self, text):\n        return self._base_sanitize(text)\n\n    def _code_sanitize(self, text):\n        text = self._base_sanitize(text)\n        text = re.sub(r'\\s', ' ', text)\n        return text\n\n    def _h3_sanitize(self, text):\n        text = self._base_sanitize(text)\n        text = re.sub(' \\n|\\n ', ' ', text)\n        text = re.sub('\\n', ' ', text)\n        return text\n\n    def _sanitize(self, text):\n        text = self._base_sanitize(text)\n        text = re.sub(r'<([^>]+)>', r'\\\\fI\\1\\\\fR', text)\n        text = re.sub(r' +', ' ', text)\n        text = re.sub('\\n', ' ', text)\n        return text\n\n    def __write_cmd(self, dat):\n        print('.', dat, sep='\\n', file=self.f)\n        pass\n\n    def __write_raw(self, dat):\n        print(dat, sep='', end='', file=self.f)\n        pass\n\n\ndef load_yml_file(fn):\n    with open(fn) as f:\n        return yaml.safe_load(f)\n\n\ndef dedent_body(body):\n    lines = [re.sub(r'^  (\\S)', r'\\1', l) for l in body.split('\\n')]\n    return '\\n'.join(lines)\n\n\ndef convert_manual_to_markdown():\n    f = StringIO()\n    manual = load_yml_file(\"content/manual/dev/manual.yml\")\n    f.write(manual.get('manpage_intro', '\\n'))\n    f.write(dedent_body(manual.get('body', '\\n')))\n    for section in manual.get('sections', []):\n        f.write('## {}\\n'.format(section.get('title', '').upper()))\n        f.write(dedent_body(section.get('body', '\\n')))\n        f.write('\\n')\n        for entry in section.get('entries', []):\n            f.write('### {}\\n'.format(entry.get('title', '')))\n            f.write(dedent_body(entry.get('body', '\\n')))\n            f.write('\\n')\n            if entry.get('examples') is not None:\n                f.write(\"~~~~\\n\")\n                first = True\n                for example in entry.get('examples'):\n                    if not first:\n                        f.write('\\n')\n                    f.write(\"jq '{}'\\n\".format(example.get('program', '')))\n                    f.write(\"   {}\\n\".format(example.get('input', '')))\n                    output = [str(x) for x in example.get('output', [])]\n                    f.write(\"=> {}\\n\".format(', '.join(output)))\n                    first = False\n                f.write(\"~~~~\\n\")\n        f.write('\\n')\n    f.write(manual.get('manpage_epilogue', ''))\n    return f.getvalue()\n\n\n# Convert manual.yml to our special markdown format\nmarkdown_data = convert_manual_to_markdown()\n\n# Convert markdown to html\nhtml_data = markdown.markdown(markdown_data,\n                              extensions=[EscapeHtml(), 'fenced_code'])\n\n# Parse the html into a tree so we can walk it\ntr = etree.HTML(html_data, etree.HTMLParser())\n\n# Convert the markdown to ROFF\nRoffWalker(tr).walk()\n"
  },
  {
    "path": "docs/build_mantests.py",
    "content": "#!/usr/bin/env python3\nimport yaml\nimport re\n\nregex_program_pattern = re.compile(\n    r'\\b(?:test|match|capture|scan|split|splits|sub|gsub)\\s*\\(')\n\nwith open('content/manual/dev/manual.yml') as source, \\\n        open('../tests/man.test', 'w') as man, \\\n        open('../tests/manonig.test', 'w') as manonig:\n    manual = yaml.safe_load(source)\n    for section in manual.get('sections', []):\n        for entry in section.get('entries', []):\n            for example in entry.get('examples', []):\n                program = example.get('program', '').replace('\\n', ' ')\n                out = manonig if regex_program_pattern.search(program) else man\n                print(program, file=out)\n                print(example.get('input', ''), file=out)\n                for s in example.get('output', []):\n                    print(s, file=out)\n                print('', file=out)\n"
  },
  {
    "path": "docs/build_website.py",
    "content": "#!/usr/bin/env python3\nimport glob\nimport itertools\nfrom jinja2 import Environment, FileSystemLoader, select_autoescape, pass_context\nfrom markdown import markdown\nfrom markupsafe import Markup\nimport os\nimport os.path\nimport re\nimport shutil\nimport yaml\n\nenv = Environment(\n    loader=FileSystemLoader('templates'),\n    autoescape=select_autoescape(['html.j2']),\n)\n\n\ndef load_yml_file(fn):\n    with open(fn) as f:\n        return yaml.safe_load(f)\n\n\nenv.globals['url'] = 'https://jqlang.org'\nenv.filters['search_id'] = lambda input: input.replace(r'`', '')\nenv.filters['section_id'] = lambda input: re.sub(\n    r'[^-a-zA-Z0-9_]', '', input.replace(' ', '-')).lower()\nenv.filters['entry_id'] = lambda input: re.sub(\n    r'^(split|first-last-nth)$',\n    r'\\1' + ('-1' if ';' not in input else '-2'),  # avoid id conflict\n    re.sub(\n        r'\\b([^-]+)(?:-\\1)+\\b',\n        r'\\1',  # e.g. range-range-range -> range\n        re.sub(r' ?/ ?|,? ', '-',\n               re.sub(r'[`;]|: .*|\\(.*?\\)| \\[.+\\]', '', input)))).lower()\nenv.filters['markdownify'] = lambda input: Markup(markdown(input))\nenv.filters['no_paragraph'] = lambda input: Markup(re.sub(r'</?p>', '', input))\n\nenv.globals['unique_id'] = pass_context(\n    lambda ctx: str(next(ctx['unique_ctr'])))\n\n\ndef raise_handler(message):\n    raise Exception(message)\n\n\nenv.globals['raise'] = raise_handler\n\n\ndef generate_file(env, fname):\n    path, base = os.path.split(fname)\n    path = os.path.relpath(path, 'content')\n    if path == '.':\n        path = ''\n        permalink = ''\n    else:\n        permalink = path + '/'\n\n    output_dir = os.path.join('output', path)\n    output_path = os.path.join(output_dir, 'index.html')\n\n    template_name = re.sub(r'.yml$', '.html.j2', base)\n\n    ctx = load_yml_file(fname)\n    ctx.update(unique_ctr=itertools.count(1),\n               permalink=permalink,\n               navitem=path)\n    os.makedirs(output_dir, exist_ok=True)\n    env.get_template(template_name).stream(ctx).dump(output_path,\n                                                     encoding='utf-8')\n\n\ndef copy_public_files(root=''):\n    for f in os.scandir(os.path.join('public', root)):\n        src = os.path.join(root, f.name)\n        dst = os.path.join('output', src)\n        if f.is_dir():\n            os.makedirs(dst, exist_ok=True)\n            copy_public_files(src)\n        else:\n            shutil.copyfile(f.path, dst)\n\n\nos.makedirs('output', exist_ok=True)\ncopy_public_files()\n\nfor fn in glob.glob('content/**/*.yml', recursive=True):\n    generate_file(env, fn)\n"
  },
  {
    "path": "docs/content/download/default.yml",
    "content": "headline: Download jq\nbody:\n  - text: |\n\n      jq is written in C and has no runtime dependencies, so it should be\n      possible to build it for nearly any platform. Prebuilt binaries are\n      available for Linux, macOS and Windows.\n\n      The binaries should just run, but on macOS and Linux you may need\n      to make them executable first using `chmod +x jq`.\n\n      jq is licensed under the MIT license. For all of the gory\n      details, read the file `COPYING` in the source distribution.\n\n      jq uses a C library for decimal number support. This is an ICU 1.8.1\n      licensed code obtained from the ICU downloads archive.  \n      <https://download.icu-project.org/files/decNumber/decNumber-icu-368.zip>\n\n\n      ### Linux\n\n       * jq is in the official [Debian](https://packages.debian.org/jq) and\n         [Ubuntu](https://packages.ubuntu.com/jq) repositories. Install using\n         `sudo apt-get install jq`.\n\n       * jq is in the official [Fedora](https://src.fedoraproject.org/rpms/jq) repository.\n         Install using `sudo dnf install jq`.\n\n       * jq is in the official [openSUSE](https://software.opensuse.org/package/jq) repository.\n         Install using `sudo zypper install jq`.\n\n       * jq is in the official [Arch](https://archlinux.org/packages/?q=jq) repository.\n         Install using `sudo pacman -S jq`.\n\n       * jq 1.8.1 binaries for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-linux-amd64)\n         or\n         [ARM64](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-linux-arm64)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-linux-i386).\n\n       * jq 1.8.0 binaries for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-linux-amd64)\n         or\n         [ARM64](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-linux-arm64)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-linux-i386).\n\n       * jq 1.7.1 binaries for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64)\n         or\n         [ARM64](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-arm64)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-i386).\n\n       * jq 1.7 binaries for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-amd64)\n         or\n         [ARM64](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-arm64)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-i386).\n\n       * jq 1.6 binaries for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux32).\n\n       * jq 1.5 binaries for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-linux64)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-linux32).\n\n       * jq 1.4 binaries for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-linux-x86_64)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-linux-x86).\n\n       * jq 1.3 binaries for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-linux-x86_64)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-linux-x86).\n\n      ### macOS\n\n       * Use [Homebrew](https://brew.sh/) to install jq with `brew install jq`.\n\n       * Use [MacPorts](https://www.macports.org) to install jq with `port install jq`.\n\n       * Use [Fink](https://finkproject.org) to install jq with `fink install jq`.\n\n       * jq 1.8.1 binaries for\n         [Apple Silicon](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-macos-arm64)\n         or\n         [Intel Mac](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-macos-amd64).\n\n       * jq 1.8.0 binaries for\n         [Apple Silicon](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-macos-arm64)\n         or\n         [Intel Mac](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-macos-amd64).\n\n       * jq 1.7.1 binaries for\n         [Apple Silicon](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-macos-arm64)\n         or\n         [Intel Mac](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-macos-amd64).\n\n       * jq 1.7 binaries for\n         [Apple Silicon](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-macos-arm64)\n         or\n         [Intel Mac](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-macos-amd64).\n\n       * jq 1.6 binary for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-osx-amd64).\n\n       * jq 1.5 binary for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-osx-amd64).\n\n       * jq 1.4 binaries for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-osx-x86_64)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-osx-x86).\n\n       * jq 1.3 binaries for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-osx-x86_64)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-osx-x86).\n\n      ### FreeBSD\n\n       * `pkg install jq` as root installs a pre-built\n         [binary package](https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/pkgng-intro.html).\n\n       * `make -C /usr/ports/textproc/jq install clean` as root installs the\n         [jq](https://www.freshports.org/textproc/jq/)\n         [port](https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html)\n         from source.\n\n      ### Solaris\n\n       * `pkgutil -i jq` in [OpenCSW](https://www.opencsw.org/p/jq) for Solaris\n         10+, Sparc and x86.\n\n       * jq 1.4 binaries for Solaris 11\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-solaris11-64)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-solaris11-32).\n\n      ### Windows\n\n       * Use [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/)\n         to install jq with `winget install jqlang.jq`.\n\n       * Use [scoop](https://scoop.sh/) to install jq with `scoop install jq`.\n\n       * Use [Chocolatey NuGet](https://chocolatey.org/) to install jq with\n         `choco install jq`.\n\n       * jq 1.8.1 executables for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-windows-amd64.exe)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-windows-i386.exe).\n\n       * jq 1.8.0 executables for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-windows-amd64.exe)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-windows-i386.exe).\n\n       * jq 1.7.1 executables for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-windows-amd64.exe)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-windows-i386.exe).\n\n       * jq 1.7 executables for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-windows-amd64.exe)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-windows-i386.exe).\n\n       * jq 1.6 executables for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-win64.exe)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-win32.exe).\n\n       * jq 1.5 executables for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-win64.exe)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-win32.exe).\n\n       * jq 1.4 executables for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-win64.exe)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-win32.exe).\n\n       * jq 1.3 executables for\n         [AMD64](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-win64.exe)\n         or\n         [i386](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-win32.exe).\n\n      ### Checksums and signatures\n\n      SHA-256 checksums are provided for all release and pre-release binaries.\n      The checksums for jq 1.8.1 are in\n      [sig/v1.8.1/sha256sum.txt](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.8.1/sha256sum.txt).\n      The checksums for jq 1.8.0 are in\n      [sig/v1.8.0/sha256sum.txt](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.8.0/sha256sum.txt).\n      The checksums for jq 1.7.1 are in\n      [sig/v1.7.1/sha256sum.txt](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.7.1/sha256sum.txt).\n      The checksums for jq 1.7 are in\n      [sig/v1.7/sha256sum.txt](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.7/sha256sum.txt).\n      The checksums for jq 1.6 are in\n      [sig/v1.6/sha256sum.txt](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.6/sha256sum.txt).\n      The checksums for jq 1.5 are in\n      [sig/v1.5/sha256sum.txt](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.5/sha256sum.txt).\n\n      Additionally, all release artifacts are signed by a jq release key.  We have two release keys, [one for 1.6 and older releases](https://raw.githubusercontent.com/jqlang/jq/master/sig/jq-release-old.key), and [one for 1.7 and newer releases](https://raw.githubusercontent.com/jqlang/jq/master/sig/jq-release-new.key).\n      The signatures for jq 1.8.1 are in\n      [sig/v1.8.1/\\*.asc](https://github.com/jqlang/jq/tree/master/sig/v1.8.1).\n      The signatures for jq 1.8.0 are in\n      [sig/v1.8.0/\\*.asc](https://github.com/jqlang/jq/tree/master/sig/v1.8.0).\n      The signatures for jq 1.7.1 are in\n      [sig/v1.7.1/\\*.asc](https://github.com/jqlang/jq/tree/master/sig/v1.7.1).\n      The signatures for jq 1.7 are in\n      [sig/v1.7/\\*.asc](https://github.com/jqlang/jq/tree/master/sig/v1.7).\n      The signatures for jq 1.6 are in\n      [sig/v1.6/\\*.asc](https://github.com/jqlang/jq/tree/master/sig/v1.6).\n      The signatures for jq 1.5 are in\n      [sig/v1.5/\\*.asc](https://github.com/jqlang/jq/tree/master/sig/v1.5).\n      You can use [GnuPG](https://gnupg.org/) to verify a signature by downloading\n      the signature and running `gpg --verify signature.asc`.\n\n      ### From source on Linux, macOS, Cygwin, and other POSIX-like operating systems\n\n       * [Source tarball for jq 1.8.1](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-1.8.1.tar.gz)\n       * [Source tarball for jq 1.8.0](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-1.8.0.tar.gz)\n       * [Source tarball for jq 1.7.1](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-1.7.1.tar.gz)\n       * [Source tarball for jq 1.7](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-1.7.tar.gz)\n       * [Source tarball for jq 1.6](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-1.6.tar.gz)\n       * [Source tarball for jq 1.5](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-1.5.tar.gz)\n\n      You can build it using the usual `./configure && make && sudo\n      make install` rigmarole.\n\n      If you're interested in using the latest development version, try:\n\n          git clone --recursive https://github.com/jqlang/jq.git\n          cd jq\n          autoreconf -i\n          ./configure\n          make\n          sudo make install\n\n      To build it from a git clone, you'll need to install a few\n      packages first:\n\n       * [GCC](https://gcc.gnu.org)\n       * [Make](https://www.gnu.org/software/make/)\n       * [Autotools](https://www.gnu.org/software/automake/)\n\n      For Linux systems, these will all be in your system's package\n      manager, and if you do development on the machine they're most\n      likely already installed.\n\n      On macOS, these are all included in Apple's command line tools, which can\n      be installed from [Xcode](https://developer.apple.com/xcode/). However,\n      you may find that you need a newer version of Bison than the one provided\n      by Apple. This can be found in [Homebrew](https://brew.sh/) or\n      [MacPorts](https://macports.org/).\n\n      If you want to generate the lexer and parser from source you can use the\n      `--enable-maintainer-mode` configure flag. This requires bison to be installed.\n      [Flex](https://github.com/westes/flex) and\n      [Bison](https://www.gnu.org/software/bison/).\n\n      ### Docker\n\n      Docker image is available from\n      [GitHub Container Registry](https://github.com/jqlang/jq/pkgs/container/jq).\n\n          docker run -i --rm ghcr.io/jqlang/jq -n 'range(3)'\n\n      #### Building the documentation\n\n      jq's documentation is compiled into static HTML using Python.\n      To build the docs, run `pipenv run python3 build_website.py`\n      in the `docs/` directory. To serve them locally, you can run\n      `python3 -m http.server -d output`. You'll need a few Python dependencies,\n      which can be installed by following the instructions in `docs/README.md`.\n\n      The man page is built by `make jq.1`, or just `make`, also from\n      the YAML docs, and you'll still need the Python dependencies to\n      build the manpage.\n"
  },
  {
    "path": "docs/content/index.yml",
    "content": "headline: jq\n\nblurb: |\n\n  jq is a lightweight and flexible command-line JSON processor.\n\nbody1: |\n\n  jq is like `sed` for JSON data - you can use it to slice and filter\n  and map and transform structured data with the same ease that `sed`,\n  `awk`, `grep` and friends let you play with text.\n\nbody2: |\n\n  jq is written in portable C, and it has zero runtime\n  dependencies. You can download a single binary, `scp` it to a far away\n  machine of the same type, and expect it to work.\n\nbody3: |\n\n  jq can mangle the data format that you have into the one that you\n  want with very little effort, and the program to do so is often\n  shorter and simpler than you'd expect.\n\ntail: |\n\n  Go read the [tutorial](./tutorial/) for more, or the [manual](./manual/)\n  for *way* more.\n\n  Have a question related to jq? You can seek answers on [Stack Overflow](https://stackoverflow.com/)\n  by using the [jq tag](https://stackoverflow.com/questions/tagged/jq), or in the [#jq channel](https://web.libera.chat/#jq)\n  on [Libera.Chat](https://libera.chat/). For more interactive discussions, feel free to join our [Discord server](https://discord.gg/yg6yjNmgAC).\n\nnews:\n  - date: 1 July 2025\n    body: |\n      jq 1.8.1 released. See [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.8.1) for details.\n\n  - date: 1 June 2025\n    body: |\n      jq 1.8.0 released. See [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.8.0) for details.\n\n  - date: 13 December 2023\n    body: |\n      jq 1.7.1 released. Security (CVE-2023-50246, CVE-2023-50268) and bug fixes.\n      See [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.7.1) for details.\n\n  - date: 7 September 2023\n    body: |\n      After a five-year hiatus, we've returned with a revitalized [GitHub organization](https://github.com/jqlang)\n      and a much-anticipated 1.7 release, thanks to our new admins and maintainers.\n      Check out the [download](./download/) page for installation options and see the\n      [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.7) for details.\n\n  - date: 1 November 2018\n    body: |\n      jq 1.6 released. See installation options on the [download](./download/)\n      page, and the [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.6)\n      for details.\n\n  - date: 15 August 2015\n    body: |\n\n      jq 1.5 released, including new datetime, math, and regexp functions,\n      try/catch syntax, array and object destructuring, a streaming parser,\n      and a module system. See installation options on the\n      [download](./download/) page, and the\n      [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.5)\n      for details.\n\n  - date: 26 July 2015\n    body: |\n\n      jq 1.5rc2 is available. Get it on the\n      [releases](https://github.com/jqlang/jq/releases) page.\n\n  - date: 01 January 2015\n    body: |\n\n      jq 1.5rc1 is available. Get it on the\n      [releases](https://github.com/jqlang/jq/releases) page.\n\n  - date: 09 June 2014\n    body: |\n\n      jq 1.4 (finally) released! Get it on the [download](./download/) page.\n\n  - date: 19 May 2013\n    body: |\n\n      jq 1.3 released.\n"
  },
  {
    "path": "docs/content/manual/dev/manual.yml",
    "content": "---\nheadline: jq Manual (development version)\n\nbody: |\n\n  A jq program is a \"filter\": it takes an input, and produces an\n  output. There are a lot of builtin filters for extracting a\n  particular field of an object, or converting a number to a string,\n  or various other standard tasks.\n\n  Filters can be combined in various ways - you can pipe the output of\n  one filter into another filter, or collect the output of a filter\n  into an array.\n\n  Some filters produce multiple results, for instance there's one that\n  produces all the elements of its input array. Piping that filter\n  into a second runs the second filter for each element of the\n  array. Generally, things that would be done with loops and iteration\n  in other languages are just done by gluing filters together in jq.\n\n  It's important to remember that every filter has an input and an\n  output. Even literals like \"hello\" or 42 are filters - they take an\n  input but always produce the same literal as output. Operations that\n  combine two filters, like addition, generally feed the same input to\n  both and combine the results. So, you can implement an averaging\n  filter as `add / length` - feeding the input array both to the `add`\n  filter and the `length` filter and then performing the division.\n\n  But that's getting ahead of ourselves. :) Let's start with something\n  simpler:\n\nmanpage_intro: |\n  jq(1) -- Command-line JSON processor\n  ====================================\n\n  ## SYNOPSIS\n\n  `jq` [<options>...] <filter> [<files>...]\n\n  `jq` can transform JSON in various ways, by selecting, iterating,\n  reducing and otherwise mangling JSON documents. For instance,\n  running the command `jq 'map(.price) | add'` will take an array of\n  JSON objects as input and return the sum of their \"price\" fields.\n\n  `jq` can accept text input as well, but by default, `jq` reads a\n  stream of JSON entities (including numbers and other literals) from\n  `stdin`. Whitespace is only needed to separate entities such as 1\n  and 2, and true and false.  One or more <files> may be specified, in\n  which case `jq` will read input from those instead.\n\n  The <options> are described in the [INVOKING JQ] section; they\n  mostly concern input and output formatting. The <filter> is written\n  in the jq language and specifies how to transform the input\n  file or document.\n\n  ## FILTERS\n\nmanpage_epilogue: |\n  ## BUGS\n\n  Presumably. Report them or discuss them at:\n\n      https://github.com/jqlang/jq/issues\n\n  ## AUTHOR\n\n  Stephen Dolan `<mu@netsoc.tcd.ie>`\n\nsections:\n  - title: Invoking jq\n    body: |\n\n      jq filters run on a stream of JSON data. The input to jq is\n      parsed as a sequence of whitespace-separated JSON values which\n      are passed through the provided filter one at a time. The\n      output(s) of the filter are written to standard output, as a\n      sequence of newline-separated JSON data.\n\n      The simplest and most common filter (or jq program) is `.`,\n      which is the identity operator, copying the inputs of the jq\n      processor to the output stream.  Because the default behavior of\n      the jq processor is to read JSON texts from the input stream,\n      and to pretty-print outputs, the `.` program's main use is to\n      validate and pretty-print the inputs.  The jq programming\n      language is quite rich and allows for much more than just\n      validation and pretty-printing.\n\n      Note: it is important to mind the shell's quoting rules.  As a\n      general rule it's best to always quote (with single-quote\n      characters on Unix shells) the jq program, as too many characters with special\n      meaning to jq are also shell meta-characters.  For example, `jq\n      \"foo\"` will fail on most Unix shells because that will be the same\n      as `jq foo`, which will generally fail because `foo is not\n      defined`.  When using the Windows command shell (cmd.exe) it's\n      best to use double quotes around your jq program when given on the\n      command-line (instead of the `-f program-file` option), but then\n      double-quotes in the jq program need backslash escaping. When using\n      the Powershell (`powershell.exe`) or the Powershell Core\n      (`pwsh`/`pwsh.exe`), use single-quote characters around the jq\n      program and backslash-escaped double-quotes (`\\\"`) inside the jq\n      program.\n\n      * Unix shells: `jq '.[\"foo\"]'`\n      * Powershell: `jq '.[\\\"foo\\\"]'`\n      * Windows command shell: `jq \".[\\\"foo\\\"]\"`\n\n      Note: jq allows user-defined functions, but every jq program\n      must have a top-level expression.\n\n      You can affect how jq reads and writes its input and output\n      using some command-line options:\n\n      * `--null-input` / `-n`:\n\n        Don't read any input at all. Instead, the filter is run once\n        using `null` as the input. This is useful when using jq as a\n        simple calculator or to construct JSON data from scratch.\n\n      * `--raw-input` / `-R`:\n\n        Don't parse the input as JSON. Instead, each line of text is\n        passed to the filter as a string. If combined with `--slurp`,\n        then the entire input is passed to the filter as a single long\n        string.\n\n      * `--slurp` / `-s`:\n\n        Instead of running the filter for each JSON object in the\n        input, read the entire input stream into a large array and run\n        the filter just once.\n\n      * `--compact-output` / `-c`:\n\n        By default, jq pretty-prints JSON output. Using this option\n        will result in more compact output by instead putting each\n        JSON object on a single line.\n\n      * `--raw-output` / `-r`:\n\n        With this option, if the filter's result is a string then it\n        will be written directly to standard output rather than being\n        formatted as a JSON string with quotes. This can be useful for\n        making jq filters talk to non-JSON-based systems.\n\n      * `--raw-output0`:\n\n        Like `-r` but jq will print NUL instead of newline after each output.\n        This can be useful when the values being output can contain newlines.\n        When the output value contains NUL, jq exits with non-zero code.\n\n      * `--join-output` / `-j`:\n\n        Like `-r` but jq won't print a newline after each output.\n\n      * `--ascii-output` / `-a`:\n\n        jq usually outputs non-ASCII Unicode codepoints as UTF-8, even\n        if the input specified them as escape sequences (like\n        \"\\u03bc\"). Using this option, you can force jq to produce pure\n        ASCII output with every non-ASCII character replaced with the\n        equivalent escape sequence.\n\n      * `--sort-keys` / `-S`:\n\n        Output the fields of each object with the keys in sorted order.\n\n      * `--color-output` / `-C` and `--monochrome-output` / `-M`:\n\n        By default, jq outputs colored JSON if writing to a\n        terminal. You can force it to produce color even if writing to\n        a pipe or a file using `-C`, and disable color with `-M`.\n        When the `NO_COLOR` environment variable is not empty, jq disables\n        colored output by default, but you can enable it by `-C`.\n\n        Colors can be configured with the `JQ_COLORS` environment\n        variable (see below).\n\n      * `--tab`:\n\n        Use a tab for each indentation level instead of two spaces.\n\n      * `--indent n`:\n\n        Use the given number of spaces (no more than 7) for indentation.\n\n      * `--unbuffered`:\n\n        Flush the output after each JSON object is printed (useful if\n        you're piping a slow data source into jq and piping jq's\n        output elsewhere).\n\n      * `--stream`:\n\n        Parse the input in streaming fashion, outputting arrays of path\n        and leaf values (scalars and empty arrays or empty objects).\n        For example, `\"a\"` becomes `[[],\"a\"]`, and `[[],\"a\",[\"b\"]]`\n        becomes `[[0],[]]`, `[[1],\"a\"]`, and `[[2,0],\"b\"]`.\n\n        This is useful for processing very large inputs.  Use this in\n        conjunction with filtering and the `reduce` and `foreach` syntax\n        to reduce large inputs incrementally.\n\n      * `--stream-errors`:\n\n        Like `--stream`, but invalid JSON inputs yield array values\n        where the first element is the error and the second is a path.\n        For example, `[\"a\",n]` produces `[\"Invalid literal at line 1,\n        column 7\",[1]]`.\n\n        Implies `--stream`.  Invalid JSON inputs produce no error values\n        when `--stream` without `--stream-errors`.\n\n      * `--seq`:\n\n        Use the `application/json-seq` MIME type scheme for separating\n        JSON texts in jq's input and output.  This means that an ASCII\n        RS (record separator) character is printed before each value on\n        output and an ASCII LF (line feed) is printed after every\n        output.  Input JSON texts that fail to parse are ignored (but\n        warned about), discarding all subsequent input until the next\n        RS.  This mode also parses the output of jq without the `--seq`\n        option.\n\n      * `-f` / `--from-file`:\n\n        Read the filter from a file rather than from a command line,\n        like awk's -f option. This changes the filter argument to be\n        interpreted as a filename, instead of the source of a program.\n\n      * `-L directory` / `--library-path directory`:\n\n        Prepend `directory` to the search list for modules.  If this\n        option is used then no builtin search list is used.  See the\n        section on modules below.\n\n      * `--arg name value`:\n\n        This option passes a value to the jq program as a predefined\n        variable. If you run jq with `--arg foo bar`, then `$foo` is\n        available in the program and has the value `\"bar\"`. Note that\n        `value` will be treated as a string, so `--arg foo 123` will\n        bind `$foo` to `\"123\"`.\n\n        Named arguments are also available to the jq program as\n        `$ARGS.named`. When the name is not a valid identifier, this is\n        the only way to access it.\n\n      * `--argjson name JSON-text`:\n\n        This option passes a JSON-encoded value to the jq program as a\n        predefined variable. If you run jq with `--argjson foo 123`, then\n        `$foo` is available in the program and has the value `123`.\n\n      * `--slurpfile variable-name filename`:\n\n        This option reads all the JSON texts in the named file and binds\n        an array of the parsed JSON values to the given global variable.\n        If you run jq with `--slurpfile foo bar`, then `$foo` is available\n        in the program and has an array whose elements correspond to the\n        texts in the file named `bar`.\n\n      * `--rawfile variable-name filename`:\n\n        This option reads in the named file and binds its content to the given\n        global variable.  If you run jq with `--rawfile foo bar`, then `$foo` is\n        available in the program and has a string whose content is set to the text\n        in the file named `bar`.\n\n      * `--args`:\n\n        Remaining arguments are positional string arguments.  These are\n        available to the jq program as `$ARGS.positional[]`.\n\n      * `--jsonargs`:\n\n        Remaining arguments are positional JSON text arguments.  These\n        are available to the jq program as `$ARGS.positional[]`.\n\n      * `--exit-status` / `-e`:\n\n        Sets the exit status of jq to 0 if the last output value was\n        neither `false` nor `null`, 1 if the last output value was\n        either `false` or `null`, or 4 if no valid result was ever\n        produced.  Normally jq exits with 2 if there was any usage\n        problem or system error, 3 if there was a jq program compile\n        error, or 0 if the jq program ran.\n\n        Another way to set the exit status is with the `halt_error`\n        builtin function.\n\n      * `--binary` / `-b`:\n\n        Windows users using WSL, MSYS2, or Cygwin, should use this option\n        when using a native jq.exe, otherwise jq will turn newlines (LFs)\n        into carriage-return-then-newline (CRLF).\n\n      * `--version` / `-V`:\n\n        Output the jq version and exit with zero.\n\n      * `--build-configuration`:\n\n        Output the build configuration of jq and exit with zero.\n        This output has no supported format or structure and may change\n        without notice in future releases.\n\n      * `--help` / `-h`:\n\n        Output the jq help and exit with zero.\n\n      * `--`:\n\n        Terminates argument processing.  Remaining arguments are not\n        interpreted as options.\n\n      * `--run-tests [filename]`:\n\n        Runs the tests in the given file or standard input.  This must\n        be the last option given and does not honor all preceding\n        options.  The input consists of comment lines, empty lines, and\n        program lines followed by one input line, as many lines of\n        output as are expected (one per output), and a terminating empty\n        line.  Compilation failure tests start with a line containing\n        only `%%FAIL`, then a line containing the program to compile,\n        then a line containing an error message to compare to the\n        actual.\n\n        Be warned that this option can change backwards-incompatibly.\n\n  - title: Basic filters\n    entries:\n      - title: \"Identity: `.`\"\n        body: |\n\n          The absolute simplest filter is `.` .  This filter takes its\n          input and produces the same value as output.  That is, this\n          is the identity operator.\n\n          Since jq by default pretty-prints all output, a trivial\n          program consisting of nothing but `.` can be used to format\n          JSON output from, say, `curl`.\n\n          Although the identity filter never modifies the value of its\n          input, jq processing can sometimes make it appear as though\n          it does.  For example, using the current implementation of\n          jq, we would see that the expression:\n\n              1E1234567890 | .\n\n          produces `1.7976931348623157e+308` on at least one platform.\n          This is because, in the process of parsing the number, this\n          particular version of jq has converted it to an IEEE754\n          double-precision representation, losing precision.\n\n          The way in which jq handles numbers has changed over time\n          and further changes are likely within the parameters set by\n          the relevant JSON standards.  Moreover, build configuration\n          options can alter how jq processes numbers.\n\n          The following remarks are therefore offered with the\n          understanding that they are intended to be descriptive of the\n          current version of jq and should not be interpreted as being\n          prescriptive:\n\n          (1) Any arithmetic operation on a number that has not\n          already been converted to an IEEE754 double precision\n          representation will trigger a conversion to the IEEE754\n          representation.\n\n          (2) jq will attempt to maintain the original decimal\n          precision of number literals (if the `--disable-decnum`\n          build configuration option was not used), but in expressions\n          such `1E1234567890`, precision will be lost if the exponent\n          is too large.\n\n          (3) Comparisons are carried out using the untruncated\n          big decimal representation of numbers if available, as\n          illustrated in one of the following examples.\n\n          The examples below use the builtin function `have_decnum` in\n          order to demonstrate the expected effects of using / not\n          using the `--disable-decnum` build configuration option, and\n          also to allow automated tests derived from these examples to\n          pass regardless of whether that option is used.\n\n        examples:\n          - program: '.'\n            input: '\"Hello, world!\"'\n            output: ['\"Hello, world!\"']\n\n          - program: '.'\n            input: '0.12345678901234567890123456789'\n            output: ['0.12345678901234567890123456789']\n\n          - program: '[., tojson] == if have_decnum then [12345678909876543212345,\"12345678909876543212345\"] else [12345678909876543000000,\"12345678909876543000000\"] end'\n            input: '12345678909876543212345'\n            output: ['true']\n\n          - program: '[1234567890987654321,-1234567890987654321 | tojson] == if have_decnum then [\"1234567890987654321\",\"-1234567890987654321\"] else [\"1234567890987654400\",\"-1234567890987654400\"] end'\n            input: 'null'\n            output: ['true']\n\n          - program: '. < 0.12345678901234567890123456788'\n            input: '0.12345678901234567890123456789'\n            output: ['false']\n\n          - program: 'map([., . == 1]) | tojson == if have_decnum then \"[[1,true],[1.000,true],[1.0,true],[1.00,true]]\" else \"[[1,true],[1,true],[1,true],[1,true]]\" end'\n            input: '[1, 1.000, 1.0, 100e-2]'\n            output: ['true']\n\n          - program: '. as $big | [$big, $big + 1] | map(. > 10000000000000000000000000000000) | . == if have_decnum then [true, false] else [false, false] end'\n            input: '10000000000000000000000000000001'\n            output: ['true']\n\n      - title: \"Object Identifier-Index: `.foo`, `.foo.bar`\"\n        body: |\n\n          The simplest *useful* filter has the form `.foo`. When given a\n          JSON object (aka dictionary or hash) as input, `.foo` produces\n          the value at the key \"foo\" if the key is present, or null otherwise.\n\n          A filter of the form `.foo.bar` is equivalent to `.foo | .bar`.\n\n          The `.foo` syntax only works for simple, identifier-like keys, that\n          is, keys that are all made of alphanumeric characters and\n          underscore, and which do not start with a digit.\n\n          If the key contains special characters or starts with a digit,\n          you need to surround it with double quotes like this:\n          `.\"foo$\"`, or else `.[\"foo$\"]`.\n\n          For example `.[\"foo::bar\"]` and `.[\"foo.bar\"]` work while\n          `.foo::bar` does not.\n\n        examples:\n          - program: '.foo'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n\n          - program: '.foo'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n\n          - program: '.[\"foo\"]'\n            input: '{\"foo\": 42}'\n            output: ['42']\n\n      - title: \"Optional Object Identifier-Index: `.foo?`\"\n        body: |\n\n          Just like `.foo`, but does not output an error when `.` is not an\n          object.\n\n        examples:\n          - program: '.foo?'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n          - program: '.foo?'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n          - program: '.[\"foo\"]?'\n            input: '{\"foo\": 42}'\n            output: ['42']\n          - program: '[.foo?]'\n            input: '[1,2]'\n            output: ['[]']\n\n      - title: \"Object Index: `.[<string>]`\"\n        body: |\n\n          You can also look up fields of an object using syntax like\n          `.[\"foo\"]` (`.foo` above is a shorthand version of this, but\n          only for identifier-like strings).\n\n      - title: \"Array Index: `.[<number>]`\"\n        body: |\n\n          When the index value is an integer, `.[<number>]` can index\n          arrays.  Arrays are zero-based, so `.[2]` returns the third\n          element.\n\n          Negative indices are allowed, with -1 referring to the last\n          element, -2 referring to the next to last element, and so on.\n\n        examples:\n          - program: '.[0]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['{\"name\":\"JSON\", \"good\":true}']\n\n          - program: '.[2]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['null']\n\n          - program: '.[-2]'\n            input: '[1,2,3]'\n            output: ['2']\n\n      - title: \"Array/String Slice: `.[<number>:<number>]`\"\n        body: |\n\n          The `.[<number>:<number>]` syntax can be used to return a\n          subarray of an array or substring of a string. The array\n          returned by `.[10:15]` will be of length 5, containing the\n          elements from index 10 (inclusive) to index 15 (exclusive).\n          Either index may be negative (in which case it counts\n          backwards from the end of the array), or omitted (in which\n          case it refers to the start or end of the array).\n          Indices are zero-based.\n\n        examples:\n          - program: '.[2:4]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"c\", \"d\"]']\n\n          - program: '.[2:4]'\n            input: '\"abcdefghi\"'\n            output: ['\"cd\"']\n\n          - program: '.[:3]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"a\", \"b\", \"c\"]']\n\n          - program: '.[-2:]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"d\", \"e\"]']\n\n      - title: \"Array/Object Value Iterator: `.[]`\"\n        body: |\n\n          If you use the `.[index]` syntax, but omit the index\n          entirely, it will return *all* of the elements of an\n          array. Running `.[]` with the input `[1,2,3]` will produce the\n          numbers as three separate results, rather than as a single\n          array. A filter of the form `.foo[]` is equivalent to\n          `.foo | .[]`.\n\n          You can also use this on an object, and it will return all\n          the values of the object.\n\n          Note that the iterator operator is a generator of values.\n\n        examples:\n          - program: '.[]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output:\n              - '{\"name\":\"JSON\", \"good\":true}'\n              - '{\"name\":\"XML\", \"good\":false}'\n\n          - program: '.[]'\n            input: '[]'\n            output: []\n\n          - program: '.foo[]'\n            input: '{\"foo\":[1,2,3]}'\n            output: ['1','2','3']\n\n          - program: '.[]'\n            input: '{\"a\": 1, \"b\": 1}'\n            output: ['1', '1']\n\n      - title: \"`.[]?`\"\n        body: |\n\n          Like `.[]`, but no errors will be output if . is not an array\n          or object. A filter of the form `.foo[]?` is equivalent to\n          `.foo | .[]?`.\n\n      - title: \"Comma: `,`\"\n        body: |\n\n          If two filters are separated by a comma, then the\n          same input will be fed into both and the two filters' output\n          value streams will be concatenated in order: first, all of the\n          outputs produced by the left expression, and then all of the\n          outputs produced by the right. For instance, filter `.foo,\n          .bar`, produces both the \"foo\" fields and \"bar\" fields as\n          separate outputs.\n\n          The `,` operator is one way to construct generators.\n\n        examples:\n          - program: '.foo, .bar'\n            input: '{\"foo\": 42, \"bar\": \"something else\", \"baz\": true}'\n            output: ['42', '\"something else\"']\n\n          - program: \".user, .projects[]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['\"stedolan\"', '\"jq\"', '\"wikiflow\"']\n\n          - program: '.[4,2]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['\"e\"', '\"c\"']\n\n      - title: \"Pipe: `|`\"\n        body: |\n\n          The | operator combines two filters by feeding the output(s) of\n          the one on the left into the input of the one on the right. It's\n          similar to the Unix shell's pipe, if you're used to that.\n\n          If the one on the left produces multiple results, the one on\n          the right will be run for each of those results. So, the\n          expression `.[] | .foo` retrieves the \"foo\" field of each\n          element of the input array.  This is a cartesian product,\n          which can be surprising.\n\n          Note that `.a.b.c` is the same as `.a | .b | .c`.\n\n          Note too that `.` is the input value at the particular stage\n          in a \"pipeline\", specifically: where the `.` expression appears.\n          Thus `.a | . | .b` is the same as `.a.b`, as the `.` in the\n          middle refers to whatever value `.a` produced.\n\n        examples:\n          - program: '.[] | .name'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['\"JSON\"', '\"XML\"']\n\n      - title: \"Parenthesis\"\n        body: |\n\n          Parenthesis work as a grouping operator just as in any typical\n          programming language.\n\n        examples:\n          - program: '(. + 2) * 5'\n            input: '1'\n            output: ['15']\n\n  - title: Types and Values\n    body: |\n\n      jq supports the same set of datatypes as JSON - numbers,\n      strings, booleans, arrays, objects (which in JSON-speak are\n      hashes with only string keys), and \"null\".\n\n      Booleans, null, strings and numbers are written the same way as\n      in JSON. Just like everything else in jq, these simple\n      values take an input and produce an output - `42` is a valid jq\n      expression that takes an input, ignores it, and returns 42\n      instead.\n\n      Numbers in jq are internally represented by their IEEE754 double\n      precision approximation. Any arithmetic operation with numbers,\n      whether they are literals or results of previous filters, will\n      produce a double precision floating point result.\n\n      However, when parsing a literal jq will store the original literal\n      string. If no mutation is applied to this value then it will make\n      to the output in its original form, even if conversion to double\n      would result in a loss.\n\n    entries:\n      - title: \"Array construction: `[]`\"\n        body: |\n\n          As in JSON, `[]` is used to construct arrays, as in\n          `[1,2,3]`. The elements of the arrays can be any jq\n          expression, including a pipeline. All of the results produced\n          by all of the expressions are collected into one big array.\n          You can use it to construct an array out of a known quantity\n          of values (as in `[.foo, .bar, .baz]`) or to \"collect\" all the\n          results of a filter into an array (as in `[.items[].name]`)\n\n          Once you understand the \",\" operator, you can look at jq's array\n          syntax in a different light: the expression `[1,2,3]` is not using a\n          built-in syntax for comma-separated arrays, but is instead applying\n          the `[]` operator (collect results) to the expression 1,2,3 (which\n          produces three different results).\n\n          If you have a filter `X` that produces four results,\n          then the expression `[X]` will produce a single result, an\n          array of four elements.\n\n        examples:\n          - program: \"[.user, .projects[]]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['[\"stedolan\", \"jq\", \"wikiflow\"]']\n          - program: \"[ .[] | . * 2]\"\n            input: '[1, 2, 3]'\n            output: ['[2, 4, 6]']\n\n      - title: \"Object Construction: `{}`\"\n        body: |\n\n          Like JSON, `{}` is for constructing objects (aka\n          dictionaries or hashes), as in: `{\"a\": 42, \"b\": 17}`.\n\n          If the keys are \"identifier-like\", then the quotes can be left\n          off, as in `{a:42, b:17}`.  Variable references as key\n          expressions use the value of the variable as the key.  Key\n          expressions other than constant literals, identifiers, or\n          variable references, need to be parenthesized, e.g.,\n          `{(\"a\"+\"b\"):59}`.\n\n          The value can be any expression (although you may need to wrap\n          it in parentheses if, for example, it contains colons), which\n          gets applied to the {} expression's input (remember, all\n          filters have an input and an output).\n\n              {foo: .bar}\n\n          will produce the JSON object `{\"foo\": 42}` if given the JSON\n          object `{\"bar\":42, \"baz\":43}` as its input. You can use this\n          to select particular fields of an object: if the input is an\n          object with \"user\", \"title\", \"id\", and \"content\" fields and\n          you just want \"user\" and \"title\", you can write\n\n              {user: .user, title: .title}\n\n          Because that is so common, there's a shortcut syntax for it:\n          `{user, title}`.\n\n          If one of the expressions produces multiple results,\n          multiple dictionaries will be produced. If the input's\n\n              {\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n\n          then the expression\n\n              {user, title: .titles[]}\n\n          will produce two outputs:\n\n              {\"user\":\"stedolan\", \"title\": \"JQ Primer\"}\n              {\"user\":\"stedolan\", \"title\": \"More JQ\"}\n\n          Putting parentheses around the key means it will be evaluated as an\n          expression. With the same input as above,\n\n              {(.user): .titles}\n\n          produces\n\n              {\"stedolan\": [\"JQ Primer\", \"More JQ\"]}\n\n          Variable references as keys use the value of the variable as\n          the key.  Without a value then the variable's name becomes the\n          key and its value becomes the value,\n\n              \"f o o\" as $foo | \"b a r\" as $bar | {$foo, $bar:$foo}\n\n          produces\n\n              {\"foo\":\"f o o\",\"b a r\":\"f o o\"}\n\n        examples:\n          - program: '{user, title: .titles[]}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output:\n              - '{\"user\":\"stedolan\", \"title\": \"JQ Primer\"}'\n              - '{\"user\":\"stedolan\", \"title\": \"More JQ\"}'\n          - program: '{(.user): .titles}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output: ['{\"stedolan\": [\"JQ Primer\", \"More JQ\"]}']\n\n      - title: \"Recursive Descent: `..`\"\n        body: |\n\n          Recursively descends `.`, producing every value.  This is the\n          same as the zero-argument `recurse` builtin (see below).  This\n          is intended to resemble the XPath `//` operator.  Note that\n          `..a` does not work; use `.. | .a` instead.  In the example\n          below we use `.. | .a?` to find all the values of object keys\n          \"a\" in any object found \"below\" `.`.\n\n          This is particularly useful in conjunction with `path(EXP)`\n          (also see below) and the `?` operator.\n\n        examples:\n          - program: '.. | .a?'\n            input: '[[{\"a\":1}]]'\n            output: ['1']\n\n  - title: Builtin operators and functions\n    body: |\n\n      Some jq operators (for instance, `+`) do different things\n      depending on the type of their arguments (arrays, numbers,\n      etc.). However, jq never does implicit type conversions. If you\n      try to add a string to an object you'll get an error message and\n      no result.\n\n      Please note that all numbers are converted to IEEE754 double precision\n      floating point representation. Arithmetic and logical operators are working\n      with these converted doubles. Results of all such operations are also limited\n      to the double precision.\n\n      The only exception to this behaviour of number is a snapshot of original number\n      literal. When a number which originally was provided as a literal is never\n      mutated until the end of the program then it is printed to the output in its\n      original literal form. This also includes cases when the original literal\n      would be truncated when converted to the IEEE754 double precision floating point\n      number.\n\n    entries:\n      - title: \"Addition: `+`\"\n        body: |\n\n          The operator `+` takes two filters, applies them both\n          to the same input, and adds the results together. What\n          \"adding\" means depends on the types involved:\n\n          - **Numbers** are added by normal arithmetic.\n\n          - **Arrays** are added by being concatenated into a larger array.\n\n          - **Strings** are added by being joined into a larger string.\n\n          - **Objects** are added by merging, that is, inserting all\n            the key-value pairs from both objects into a single\n            combined object. If both objects contain a value for the\n            same key, the object on the right of the `+` wins. (For\n            recursive merge use the `*` operator.)\n\n          `null` can be added to any value, and returns the other\n          value unchanged.\n\n        examples:\n          - program: '.a + 1'\n            input: '{\"a\": 7}'\n            output: ['8']\n          - program: '.a + .b'\n            input: '{\"a\": [1,2], \"b\": [3,4]}'\n            output: ['[1,2,3,4]']\n          - program: '.a + null'\n            input: '{\"a\": 1}'\n            output: ['1']\n          - program: '.a + 1'\n            input: '{}'\n            output: ['1']\n          - program: '{a: 1} + {b: 2} + {c: 3} + {a: 42}'\n            input: 'null'\n            output: ['{\"a\": 42, \"b\": 2, \"c\": 3}']\n\n      - title: \"Subtraction: `-`\"\n        body: |\n\n          As well as normal arithmetic subtraction on numbers, the `-`\n          operator can be used on arrays to remove all occurrences of\n          the second array's elements from the first array.\n\n        examples:\n          - program: '4 - .a'\n            input: '{\"a\":3}'\n            output: ['1']\n          - program: . - [\"xml\", \"yaml\"]\n            input: '[\"xml\", \"yaml\", \"json\"]'\n            output: ['[\"json\"]']\n\n      - title: \"Multiplication, division, modulo: `*`, `/`, `%`\"\n        body: |\n\n          These infix operators behave as expected when given two numbers.\n          Division by zero raises an error. `x % y` computes x modulo y.\n\n          Multiplying a string by a number produces the concatenation of\n          that string that many times. `\"x\" * 0` produces `\"\"`.\n\n          Dividing a string by another splits the first using the second\n          as separators.\n\n          Multiplying two objects will merge them recursively: this works\n          like addition but if both objects contain a value for the\n          same key, and the values are objects, the two are merged with\n          the same strategy.\n\n        examples:\n          - program: '10 / . * 3'\n            input: '5'\n            output: ['6']\n          - program: '. / \", \"'\n            input: '\"a, b,c,d, e\"'\n            output: ['[\"a\",\"b,c,d\",\"e\"]']\n          - program: '{\"k\": {\"a\": 1, \"b\": 2}} * {\"k\": {\"a\": 0,\"c\": 3}}'\n            input: 'null'\n            output: ['{\"k\": {\"a\": 0, \"b\": 2, \"c\": 3}}']\n          - program: '.[] | (1 / .)?'\n            input: '[1,0,-1]'\n            output: ['1', '-1']\n\n      - title: \"`abs`\"\n        body: |\n\n          The builtin function `abs` is defined naively as: `if . < 0 then - . else . end`.\n\n          For numeric input, this is the absolute value.  See the\n          section on the identity filter for the implications of this\n          definition for numeric input.\n\n          To compute the absolute value of a number as a floating point number, you may wish use `fabs`.\n\n        examples:\n          - program: 'map(abs)'\n            input: '[-10, -1.1, -1e-1]'\n            output: ['[10,1.1,1e-1]']\n\n      - title: \"`length`\"\n        body: |\n\n          The builtin function `length` gets the length of various\n          different types of value:\n\n          - The length of a **string** is the number of Unicode\n            codepoints it contains (which will be the same as its\n            JSON-encoded length in bytes if it's pure ASCII).\n\n          - The length of a **number** is its absolute value.\n\n          - The length of an **array** is the number of elements.\n\n          - The length of an **object** is the number of key-value pairs.\n\n          - The length of **null** is zero.\n\n          - It is an error to use `length` on a **boolean**.\n\n        examples:\n          - program: '.[] | length'\n            input: '[[1,2], \"string\", {\"a\":2}, null, -5]'\n            output: ['2', '6', '1', '0', '5']\n\n\n      - title: \"`utf8bytelength`\"\n        body: |\n\n          The builtin function `utf8bytelength` outputs the number of\n          bytes used to encode a string in UTF-8.\n\n        examples:\n          - program: 'utf8bytelength'\n            input: '\"\\u03bc\"'\n            output: ['2']\n\n      - title: \"`keys`, `keys_unsorted`\"\n        body: |\n\n          The builtin function `keys`, when given an object, returns\n          its keys in an array.\n\n          The keys are sorted \"alphabetically\", by unicode codepoint\n          order. This is not an order that makes particular sense in\n          any particular language, but you can count on it being the\n          same for any two objects with the same set of keys,\n          regardless of locale settings.\n\n          When `keys` is given an array, it returns the valid indices\n          for that array: the integers from 0 to length-1.\n\n          The `keys_unsorted` function is just like `keys`, but if\n          the input is an object then the keys will not be sorted,\n          instead the keys will roughly be in insertion order.\n\n        examples:\n          - program: 'keys'\n            input: '{\"abc\": 1, \"abcd\": 2, \"Foo\": 3}'\n            output: ['[\"Foo\", \"abc\", \"abcd\"]']\n          - program: 'keys'\n            input: '[42,3,35]'\n            output: ['[0,1,2]']\n\n      - title: \"`has(key)`\"\n        body: |\n\n          The builtin function `has` returns whether the input object\n          has the given key, or the input array has an element at the\n          given index.\n\n          `has($key)` has the same effect as checking whether `$key`\n          is a member of the array returned by `keys`, although `has`\n          will be faster.\n\n        examples:\n          - program: 'map(has(\"foo\"))'\n            input: '[{\"foo\": 42}, {}]'\n            output: ['[true, false]']\n          - program: 'map(has(2))'\n            input: '[[0,1], [\"a\",\"b\",\"c\"]]'\n            output: ['[false, true]']\n\n      - title: \"`in`\"\n        body: |\n\n          The builtin function `in` returns whether or not the input key is in the\n          given object, or the input index corresponds to an element\n          in the given array. It is, essentially, an inversed version\n          of `has`.\n\n        examples:\n          - program: '.[] | in({\"foo\": 42})'\n            input: '[\"foo\", \"bar\"]'\n            output: ['true', 'false']\n          - program: 'map(in([0,1]))'\n            input: '[2, 0]'\n            output: ['[false, true]']\n\n      - title: \"`map(f)`, `map_values(f)`\"\n        body: |\n\n          For any filter `f`, `map(f)` and `map_values(f)` apply `f`\n          to each of the values in the input array or object, that is,\n          to the values of `.[]`.\n\n          In the absence of errors, `map(f)` always outputs an array\n          whereas `map_values(f)` outputs an array if given an array,\n          or an object if given an object.\n\n          When the input to `map_values(f)` is an object, the output\n          object has the same keys as the input object except for\n          those keys whose values when piped to `f` produce no values\n          at all.\n\n          The key difference between `map(f)` and `map_values(f)` is\n          that the former simply forms an array from all the values of\n          `($x|f)` for each value, `$x`, in the input array or object,\n          but `map_values(f)` only uses `first($x|f)`.\n\n          Specifically, for object inputs, `map_values(f)` constructs\n          the output object by examining in turn the value of\n          `first(.[$k]|f)` for each key, `$k`, of the input.  If this\n          expression produces no values, then the corresponding key\n          will be dropped; otherwise, the output object will have that\n          value at the key, `$k`.\n\n          Here are some examples to clarify the behavior of `map` and\n          `map_values` when applied to arrays. These examples assume the\n          input is `[1]` in all cases:\n\n              map(.+1)          #=>  [2]\n              map(., .)         #=>  [1,1]\n              map(empty)        #=>  []\n\n              map_values(.+1)   #=>  [2]\n              map_values(., .)  #=>  [1]\n              map_values(empty) #=>  []\n\n          `map(f)` is equivalent to `[.[] | f]` and\n          `map_values(f)` is equivalent to `.[] |= f`.\n\n          In fact, these are their implementations.\n\n\n        examples:\n          - program: 'map(.+1)'\n            input: '[1,2,3]'\n            output: ['[2,3,4]']\n\n          - program: 'map_values(.+1)'\n            input: '{\"a\": 1, \"b\": 2, \"c\": 3}'\n            output: ['{\"a\": 2, \"b\": 3, \"c\": 4}']\n\n          - program: 'map(., .)'\n            input: '[1,2]'\n            output: ['[1,1,2,2]']\n\n          - program: 'map_values(. // empty)'\n            input: '{\"a\": null, \"b\": true, \"c\": false}'\n            output: ['{\"b\":true}']\n\n\n      - title: \"`pick(pathexps)`\"\n        body: |\n\n          Emit the projection of the input object or array defined by the\n          specified sequence of path expressions, such that if `p` is any\n          one of these specifications, then `(. | p)` will evaluate to the\n          same value as `(. | pick(pathexps) | p)`. For arrays, negative\n          indices and `.[m:n]` specifications should not be used.\n\n        examples:\n          - program: 'pick(.a, .b.c, .x)'\n            input: '{\"a\": 1, \"b\": {\"c\": 2, \"d\": 3}, \"e\": 4}'\n            output: ['{\"a\":1,\"b\":{\"c\":2},\"x\":null}']\n\n          - program: 'pick(.[2], .[0], .[0])'\n            input: '[1,2,3,4]'\n            output: ['[1,null,3]']\n\n\n      - title: \"`path(path_expression)`\"\n        body: |\n\n          Outputs array representations of the given path expression\n          in `.`.  The outputs are arrays of strings (object keys)\n          and/or numbers (array indices).\n\n          Path expressions are jq expressions like `.a`, but also `.[]`.\n          There are two types of path expressions: ones that can match\n          exactly, and ones that cannot.  For example, `.a.b.c` is an\n          exact match path expression, while `.a[].b` is not.\n\n          `path(exact_path_expression)` will produce the array\n          representation of the path expression even if it does not\n          exist in `.`, if `.` is `null` or an array or an object.\n\n          `path(pattern)` will produce array representations of the\n          paths matching `pattern` if the paths exist in `.`.\n\n          Note that the path expressions are not different from normal\n          expressions.  The expression\n          `path(..|select(type==\"boolean\"))` outputs all the paths to\n          boolean values in `.`, and only those paths.\n\n        examples:\n          - program: 'path(.a[0].b)'\n            input: 'null'\n            output: ['[\"a\",0,\"b\"]']\n          - program: '[path(..)]'\n            input: '{\"a\":[{\"b\":1}]}'\n            output: ['[[],[\"a\"],[\"a\",0],[\"a\",0,\"b\"]]']\n\n      - title: \"`del(path_expression)`\"\n        body: |\n\n          The builtin function `del` removes a key and its corresponding\n          value from an object.\n\n        examples:\n          - program: 'del(.foo)'\n            input: '{\"foo\": 42, \"bar\": 9001, \"baz\": 42}'\n            output: ['{\"bar\": 9001, \"baz\": 42}']\n          - program: 'del(.[1, 2])'\n            input: '[\"foo\", \"bar\", \"baz\"]'\n            output: ['[\"foo\"]']\n\n      - title: \"`getpath(PATHS)`\"\n        body: |\n\n          The builtin function `getpath` outputs the values in `.` found\n          at each path in `PATHS`.\n\n        examples:\n          - program: 'getpath([\"a\",\"b\"])'\n            input: 'null'\n            output: ['null']\n          - program: '[getpath([\"a\",\"b\"], [\"a\",\"c\"])]'\n            input: '{\"a\":{\"b\":0, \"c\":1}}'\n            output: ['[0, 1]']\n\n      - title: \"`setpath(PATHS; VALUE)`\"\n        body: |\n\n          The builtin function `setpath` sets the `PATHS` in `.` to `VALUE`.\n\n        examples:\n          - program: 'setpath([\"a\",\"b\"]; 1)'\n            input: 'null'\n            output: ['{\"a\": {\"b\": 1}}']\n          - program: 'setpath([\"a\",\"b\"]; 1)'\n            input: '{\"a\":{\"b\":0}}'\n            output: ['{\"a\": {\"b\": 1}}']\n          - program: 'setpath([0,\"a\"]; 1)'\n            input: 'null'\n            output: ['[{\"a\":1}]']\n\n      - title: \"`delpaths(PATHS)`\"\n        body: |\n\n          The builtin function `delpaths` deletes the `PATHS` in `.`.\n          `PATHS` must be an array of paths, where each path is an array\n          of strings and numbers.\n\n        examples:\n          - program: 'delpaths([[\"a\",\"b\"]])'\n            input: '{\"a\":{\"b\":1},\"x\":{\"y\":2}}'\n            output: ['{\"a\":{},\"x\":{\"y\":2}}']\n\n      - title: \"`to_entries`, `from_entries`, `with_entries(f)`\"\n        body: |\n\n          These functions convert between an object and an array of\n          key-value pairs. If `to_entries` is passed an object, then\n          for each `k: v` entry in the input, the output array\n          includes `{\"key\": k, \"value\": v}`.\n\n          `from_entries` does the opposite conversion, and `with_entries(f)`\n          is a shorthand for `to_entries | map(f) | from_entries`, useful for\n          doing some operation to all keys and values of an object.\n          `from_entries` accepts `\"key\"`, `\"Key\"`, `\"name\"`, `\"Name\"`,\n          `\"value\"`, and `\"Value\"` as keys.\n\n        examples:\n          - program: 'to_entries'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]']\n          - program: 'from_entries'\n            input: '[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]'\n            output: ['{\"a\": 1, \"b\": 2}']\n          - program: 'with_entries(.key |= \"KEY_\" + .)'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['{\"KEY_a\": 1, \"KEY_b\": 2}']\n\n\n      - title: \"`select(boolean_expression)`\"\n        body: |\n\n          The function `select(f)` produces its input unchanged if\n          `f` returns true for that input, and produces no output\n          otherwise.\n\n          It's useful for filtering lists: `[1,2,3] | map(select(. >= 2))`\n          will give you `[2,3]`.\n\n        examples:\n          - program: 'map(select(. >= 2))'\n            input: '[1,5,3,0,7]'\n            output: ['[5,3,7]']\n          - program: '.[] | select(.id == \"second\")'\n            input: '[{\"id\": \"first\", \"val\": 1}, {\"id\": \"second\", \"val\": 2}]'\n            output: ['{\"id\": \"second\", \"val\": 2}']\n\n\n      - title: \"`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `normals`, `finites`, `strings`, `nulls`, `values`, `scalars`\"\n        body: |\n\n          These built-ins select only inputs that are arrays, objects,\n          iterables (arrays or objects), booleans, numbers, normal\n          numbers, finite numbers, strings, null, non-null values, and\n          non-iterables, respectively.\n\n        examples:\n          - program: '.[]|numbers'\n            input: '[[],{},1,\"foo\",null,true,false]'\n            output: ['1']\n\n      - title: \"`empty`\"\n        body: |\n\n          `empty` returns no results. None at all. Not even `null`.\n\n          It's useful on occasion. You'll know if you need it :)\n\n        examples:\n          - program: '1, empty, 2'\n            input: 'null'\n            output: ['1', '2']\n          - program: '[1,2,empty,3]'\n            input: 'null'\n            output: ['[1,2,3]']\n\n      - title: \"`error`, `error(message)`\"\n        body: |\n\n          Produces an error with the input value, or with the message\n          given as the argument. Errors can be caught with try/catch;\n          see below.\n\n        examples:\n          - program: 'try error catch .'\n            input: '\"error message\"'\n            output: ['\"error message\"']\n\n          - program: 'try error(\"invalid value: \\(.)\") catch .'\n            input: '42'\n            output: ['\"invalid value: 42\"']\n\n      - title: \"`halt`\"\n        body: |\n\n          Stops the jq program with no further outputs.  jq will exit\n          with exit status `0`.\n\n      - title: \"`halt_error`, `halt_error(exit_code)`\"\n        body: |\n\n          Stops the jq program with no further outputs.  The input will\n          be printed on `stderr` as raw output (i.e., strings will not\n          have double quotes) with no decoration, not even a newline.\n\n          The given `exit_code` (defaulting to `5`) will be jq's exit\n          status.\n\n          For example, `\"Error: something went wrong\\n\"|halt_error(1)`.\n\n      - title: \"`$__loc__`\"\n        body: |\n\n          Produces an object with a \"file\" key and a \"line\" key, with\n          the filename and line number where `$__loc__` occurs, as\n          values.\n\n        examples:\n          - program: 'try error(\"\\($__loc__)\") catch .'\n            input: 'null'\n            output: ['\"{\\\"file\\\":\\\"<top-level>\\\",\\\"line\\\":1}\"']\n\n      - title: \"`paths`, `paths(node_filter)`\"\n        body: |\n\n          `paths` outputs the paths to all the elements in its input\n          (except it does not output the empty list, representing .\n          itself).\n\n          `paths(f)` outputs the paths to any values for which `f` is `true`.\n          That is, `paths(type == \"number\")` outputs the paths to all numeric\n          values.\n\n        examples:\n          - program: '[paths]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1],[1,0],[1,1],[1,1,\"a\"]]']\n          - program: '[paths(type == \"number\")]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1,1,\"a\"]]']\n\n      - title: \"`add`, `add(generator)`\"\n        body: |\n\n          The filter `add` takes as input an array, and produces as\n          output the elements of the array added together. This might\n          mean summed, concatenated or merged depending on the types\n          of the elements of the input array - the rules are the same\n          as those for the `+` operator (described above).\n\n          If the input is an empty array, `add` returns `null`.\n\n          `add(generator)` operates on the given generator rather than\n          the input.\n\n        examples:\n          - program: add\n            input: '[\"a\",\"b\",\"c\"]'\n            output: ['\"abc\"']\n          - program: add\n            input: '[1, 2, 3]'\n            output: ['6']\n          - program: add\n            input: '[]'\n            output: [\"null\"]\n          - program: add(.[].a)\n            input: '[{\"a\":3}, {\"a\":5}, {\"b\":6}]'\n            output: ['8']\n\n      - title: \"`any`, `any(condition)`, `any(generator; condition)`\"\n        body: |\n\n          The filter `any` takes as input an array of boolean values,\n          and produces `true` as output if any of the elements of\n          the array are `true`.\n\n          If the input is an empty array, `any` returns `false`.\n\n          The `any(condition)` form applies the given condition to the\n          elements of the input array.\n\n          The `any(generator; condition)` form applies the given\n          condition to all the outputs of the given generator.\n\n        examples:\n          - program: any\n            input: '[true, false]'\n            output: [\"true\"]\n          - program: any\n            input: '[false, false]'\n            output: [\"false\"]\n          - program: any\n            input: '[]'\n            output: [\"false\"]\n\n      - title: \"`all`, `all(condition)`, `all(generator; condition)`\"\n        body: |\n\n          The filter `all` takes as input an array of boolean values,\n          and produces `true` as output if all of the elements of\n          the array are `true`.\n\n          The `all(condition)` form applies the given condition to the\n          elements of the input array.\n\n          The `all(generator; condition)` form applies the given\n          condition to all the outputs of the given generator.\n\n          If the input is an empty array, `all` returns `true`.\n\n        examples:\n          - program: all\n            input: '[true, false]'\n            output: [\"false\"]\n          - program: all\n            input: '[true, true]'\n            output: [\"true\"]\n          - program: all\n            input: '[]'\n            output: [\"true\"]\n\n      - title: \"`flatten`, `flatten(depth)`\"\n        body: |\n\n          The filter `flatten` takes as input an array of nested arrays,\n          and produces a flat array in which all arrays inside the original\n          array have been recursively replaced by their values. You can pass\n          an argument to it to specify how many levels of nesting to flatten.\n\n          `flatten(2)` is like `flatten`, but going only up to two\n          levels deep.\n\n        examples:\n          - program: flatten\n            input: '[1, [2], [[3]]]'\n            output: [\"[1, 2, 3]\"]\n          - program: flatten(1)\n            input: '[1, [2], [[3]]]'\n            output: [\"[1, 2, [3]]\"]\n          - program: flatten\n            input: '[[]]'\n            output: [\"[]\"]\n          - program: flatten\n            input: '[{\"foo\": \"bar\"}, [{\"foo\": \"baz\"}]]'\n            output: ['[{\"foo\": \"bar\"}, {\"foo\": \"baz\"}]']\n\n      - title: \"`range(upto)`, `range(from; upto)`, `range(from; upto; by)`\"\n        body: |\n\n          The `range` function produces a range of numbers. `range(4; 10)`\n          produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers\n          are produced as separate outputs. Use `[range(4; 10)]` to get a range as\n          an array.\n\n          The one argument form generates numbers from 0 to the given\n          number, with an increment of 1.\n\n          The two argument form generates numbers from `from` to `upto`\n          with an increment of 1.\n\n          The three argument form generates numbers `from` to `upto`\n          with an increment of `by`.\n\n        examples:\n          - program: 'range(2; 4)'\n            input: 'null'\n            output: ['2', '3']\n          - program: '[range(2; 4)]'\n            input: 'null'\n            output: ['[2,3]']\n          - program: '[range(4)]'\n            input: 'null'\n            output: ['[0,1,2,3]']\n          - program: '[range(0; 10; 3)]'\n            input: 'null'\n            output: ['[0,3,6,9]']\n          - program: '[range(0; 10; -1)]'\n            input: 'null'\n            output: ['[]']\n          - program: '[range(0; -5; -1)]'\n            input: 'null'\n            output: ['[0,-1,-2,-3,-4]']\n\n      - title: \"`floor`\"\n        body: |\n\n          The `floor` function returns the floor of its numeric input.\n\n        examples:\n          - program: 'floor'\n            input: '3.14159'\n            output: ['3']\n\n      - title: \"`sqrt`\"\n        body: |\n\n          The `sqrt` function returns the square root of its numeric input.\n\n        examples:\n          - program: 'sqrt'\n            input: '9'\n            output: ['3']\n\n      - title: \"`tonumber`\"\n        body: |\n\n          The `tonumber` function parses its input as a number. It\n          will convert correctly-formatted strings to their numeric\n          equivalent, leave numbers alone, and give an error on all other input.\n\n        examples:\n          - program: '.[] | tonumber'\n            input: '[1, \"1\"]'\n            output: ['1', '1']\n\n      - title: \"`toboolean`\"\n        body: |\n\n          The `toboolean` function parses its input as a boolean. It\n          will convert correctly-formatted strings to their boolean\n          equivalent, leave booleans alone, and give an error on all other input.\n\n        examples:\n          - program: '.[] | toboolean'\n            input: '[\"true\", \"false\", true, false]'\n            output: ['true', 'false', 'true', 'false']\n\n      - title: \"`tostring`\"\n        body: |\n\n          The `tostring` function prints its input as a\n          string. Strings are left unchanged, and all other values are\n          JSON-encoded.\n\n        examples:\n          - program: '.[] | tostring'\n            input: '[1, \"1\", [1]]'\n            output: ['\"1\"', '\"1\"', '\"[1]\"']\n\n      - title: \"`type`\"\n        body: |\n\n          The `type` function returns the type of its argument as a\n          string, which is one of null, boolean, number, string, array\n          or object.\n\n        examples:\n          - program: 'map(type)'\n            input: '[0, false, [], {}, null, \"hello\"]'\n            output: ['[\"number\", \"boolean\", \"array\", \"object\", \"null\", \"string\"]']\n\n      - title: \"`infinite`, `nan`, `isinfinite`, `isnan`, `isfinite`, `isnormal`\"\n        body: |\n\n          Some arithmetic operations can yield infinities and \"not a\n          number\" (NaN) values.  The `isinfinite` builtin returns `true`\n          if its input is infinite.  The `isnan` builtin returns `true`\n          if its input is a NaN.  The `infinite` builtin returns a\n          positive infinite value.  The `nan` builtin returns a NaN.\n          The `isnormal` builtin returns true if its input is a normal\n          number.\n\n          Note that division by zero raises an error.\n\n          Currently most arithmetic operations operating on infinities,\n          NaNs, and sub-normals do not raise errors.\n\n        examples:\n          - program: '.[] | (infinite * .) < 0'\n            input: '[-1, 1]'\n            output: ['true', 'false']\n          - program: 'infinite, nan | type'\n            input: 'null'\n            output: ['\"number\"', '\"number\"']\n\n      - title: \"`sort`, `sort_by(path_expression)`\"\n        body: |\n\n          The `sort` functions sorts its input, which must be an\n          array. Values are sorted in the following order:\n\n          * `null`\n          * `false`\n          * `true`\n          * numbers\n          * strings, in alphabetical order (by unicode codepoint value)\n          * arrays, in lexical order\n          * objects\n\n          The ordering for objects is a little complex: first they're\n          compared by comparing their sets of keys (as arrays in\n          sorted order), and if their keys are equal then the values\n          are compared key by key.\n\n          `sort_by` may be used to sort by a particular field of an\n          object, or by applying any jq filter. `sort_by(f)` compares\n          two elements by comparing the result of `f` on each element.\n          When `f` produces multiple values, it firstly compares the\n          first values, and the second values if the first values are\n          equal, and so on.\n\n        examples:\n          - program: 'sort'\n            input: '[8,3,null,6]'\n            output: ['[null,3,6,8]']\n\n          - program: 'sort_by(.foo)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":10}, {\"foo\":2, \"bar\":1}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":4, \"bar\":10}]']\n\n          - program: 'sort_by(.foo, .bar)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":4, \"bar\":10}]']\n\n      - title: \"`group_by(path_expression)`\"\n        body: |\n\n          `group_by(.foo)` takes as input an array, groups the\n          elements having the same `.foo` field into separate arrays,\n          and produces all of these arrays as elements of a larger\n          array, sorted by the value of the `.foo` field.\n\n          Any jq expression, not just a field access, may be used in\n          place of `.foo`. The sorting order is the same as described\n          in the `sort` function above.\n\n        examples:\n          - program: 'group_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":10}, {\"foo\":3, \"bar\":100}, {\"foo\":1, \"bar\":1}]'\n            output: ['[[{\"foo\":1, \"bar\":10}, {\"foo\":1, \"bar\":1}], [{\"foo\":3, \"bar\":100}]]']\n\n      - title: \"`min`, `max`, `min_by(path_exp)`, `max_by(path_exp)`\"\n        body: |\n\n          Find the minimum or maximum element of the input array.\n\n          The `min_by(path_exp)` and `max_by(path_exp)` functions allow\n          you to specify a particular field or property to examine, e.g.\n          `min_by(.foo)` finds the object with the smallest `foo` field.\n\n        examples:\n          - program: 'min'\n            input: '[5,4,2,7]'\n            output: ['2']\n          - program: 'max_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":14}, {\"foo\":2, \"bar\":3}]'\n            output: ['{\"foo\":2, \"bar\":3}']\n\n      - title: \"`unique`, `unique_by(path_exp)`\"\n        body: |\n\n          The `unique` function takes as input an array and produces\n          an array of the same elements, in sorted order, with\n          duplicates removed.\n\n          The `unique_by(path_exp)` function will keep only one element\n          for each value obtained by applying the argument. Think of it\n          as making an array by taking one element out of every group\n          produced by `group`.\n\n        examples:\n          - program: 'unique'\n            input: '[1,2,5,3,5,3,1,3]'\n            output: ['[1,2,3,5]']\n          - program: 'unique_by(.foo)'\n            input: '[{\"foo\": 1, \"bar\": 2}, {\"foo\": 1, \"bar\": 3}, {\"foo\": 4, \"bar\": 5}]'\n            output: ['[{\"foo\": 1, \"bar\": 2}, {\"foo\": 4, \"bar\": 5}]']\n          - program: 'unique_by(length)'\n            input: '[\"chunky\", \"bacon\", \"kitten\", \"cicada\", \"asparagus\"]'\n            output: ['[\"bacon\", \"chunky\", \"asparagus\"]']\n\n      - title: \"`reverse`\"\n        body: |\n\n          This function reverses an array.\n\n        examples:\n          - program: 'reverse'\n            input: '[1,2,3,4]'\n            output: ['[4,3,2,1]']\n\n      - title: \"`contains(element)`\"\n        body: |\n\n          The filter `contains(b)` will produce true if b is\n          completely contained within the input. A string B is\n          contained in a string A if B is a substring of A. An array B\n          is contained in an array A if all elements in B are\n          contained in any element in A. An object B is contained in\n          object A if all of the values in B are contained in the\n          value in A with the same key. All other types are assumed to\n          be contained in each other if they are equal.\n\n        examples:\n          - program: 'contains(\"bar\")'\n            input: '\"foobar\"'\n            output: ['true']\n          - program: 'contains([\"baz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['true']\n          - program: 'contains([\"bazzzzz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['false']\n          - program: 'contains({foo: 12, bar: [{barp: 12}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['true']\n          - program: 'contains({foo: 12, bar: [{barp: 15}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['false']\n\n      - title: \"`indices(s)`\"\n        body: |\n\n          Outputs an array containing the indices in `.` where `s`\n          occurs.  The input may be an array, in which case if `s` is an\n          array then the indices output will be those where all elements\n          in `.` match those of `s`.\n\n        examples:\n          - program: 'indices(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['[3,7,12]']\n          - program: 'indices(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['[1,3,5]']\n          - program: 'indices([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['[1,8]']\n\n      - title: \"`index(s)`, `rindex(s)`\"\n        body: |\n\n          Outputs the index of the first (`index`) or last (`rindex`)\n          occurrence of `s` in the input.\n\n        examples:\n          - program: 'index(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['3']\n          - program: 'index(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['1']\n          - program: 'index([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['1']\n          - program: 'rindex(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['12']\n          - program: 'rindex(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['5']\n          - program: 'rindex([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['8']\n\n      - title: \"`inside`\"\n        body: |\n\n          The filter `inside(b)` will produce true if the input is\n          completely contained within b. It is, essentially, an\n          inversed version of `contains`.\n\n        examples:\n          - program: 'inside(\"foobar\")'\n            input: '\"bar\"'\n            output: ['true']\n          - program: 'inside([\"foobar\", \"foobaz\", \"blarp\"])'\n            input: '[\"baz\", \"bar\"]'\n            output: ['true']\n          - program: 'inside([\"foobar\", \"foobaz\", \"blarp\"])'\n            input: '[\"bazzzzz\", \"bar\"]'\n            output: ['false']\n          - program: 'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})'\n            input: '{\"foo\": 12, \"bar\": [{\"barp\": 12}]}'\n            output: ['true']\n          - program: 'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})'\n            input: '{\"foo\": 12, \"bar\": [{\"barp\": 15}]}'\n            output: ['false']\n\n      - title: \"`startswith(str)`\"\n        body: |\n\n          Outputs `true` if . starts with the given string argument.\n\n        examples:\n          - program: '[.[]|startswith(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"barfoob\"]'\n            output: ['[false, true, false, true, false]']\n\n      - title: \"`endswith(str)`\"\n        body: |\n\n          Outputs `true` if . ends with the given string argument.\n\n        examples:\n          - program: '[.[]|endswith(\"foo\")]'\n            input: '[\"foobar\", \"barfoo\"]'\n            output: ['[false, true]']\n\n      - title: \"`combinations`, `combinations(n)`\"\n        body: |\n\n          Outputs all combinations of the elements of the arrays in the\n          input array. If given an argument `n`, it outputs all combinations\n          of `n` repetitions of the input array.\n\n        examples:\n          - program: 'combinations'\n            input: '[[1,2], [3, 4]]'\n            output: ['[1, 3]', '[1, 4]', '[2, 3]', '[2, 4]']\n          - program: 'combinations(2)'\n            input: '[0, 1]'\n            output: ['[0, 0]', '[0, 1]', '[1, 0]', '[1, 1]']\n\n      - title: \"`ltrimstr(str)`\"\n        body: |\n\n          Outputs its input with the given prefix string removed, if it\n          starts with it.\n\n        examples:\n          - program: '[.[]|ltrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"afoo\"]'\n            output: ['[\"fo\",\"\",\"barfoo\",\"bar\",\"afoo\"]']\n\n      - title: \"`rtrimstr(str)`\"\n        body: |\n\n          Outputs its input with the given suffix string removed, if it\n          ends with it.\n\n        examples:\n          - program: '[.[]|rtrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"foob\"]'\n            output: ['[\"fo\",\"\",\"bar\",\"foobar\",\"foob\"]']\n\n      - title: \"`trimstr(str)`\"\n        body: |\n\n          Outputs its input with the given string removed at both ends, if it\n          starts or ends with it.\n\n        examples:\n          - program: '[.[]|trimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobarfoo\", \"foob\"]'\n            output: ['[\"fo\",\"\",\"bar\",\"bar\",\"b\"]']\n\n      - title: \"`trim`, `ltrim`, `rtrim`\"\n        body: |\n\n          `trim` trims both leading and trailing whitespace.\n\n          `ltrim` trims only leading (left side) whitespace.\n\n          `rtrim` trims only trailing (right side) whitespace.\n\n          Whitespace characters are the usual `\" \"`, `\"\\n\"` `\"\\t\"`, `\"\\r\"`\n          and also all characters in the Unicode character database with the\n          whitespace property. Note that what considers whitespace might\n          change in the future.\n\n        examples:\n          - program: 'trim, ltrim, rtrim'\n            input: '\" abc \"'\n            output: ['\"abc\"', '\"abc \"', '\" abc\"']\n\n      - title: \"`explode`\"\n        body: |\n\n          Converts an input string into an array of the string's\n          codepoint numbers.\n\n        examples:\n          - program: 'explode'\n            input: '\"foobar\"'\n            output: ['[102,111,111,98,97,114]']\n\n      - title: \"`implode`\"\n        body: |\n\n          The inverse of explode.\n\n        examples:\n          - program: 'implode'\n            input: '[65, 66, 67]'\n            output: ['\"ABC\"']\n\n      - title: \"`split(str)`\"\n        body: |\n\n          Splits an input string on the separator argument.\n\n          `split` can also split on regex matches when called with\n          two arguments (see the regular expressions section below).\n\n        examples:\n          - program: 'split(\", \")'\n            input: '\"a, b,c,d, e, \"'\n            output: ['[\"a\",\"b,c,d\",\"e\",\"\"]']\n\n      - title: \"`join(str)`\"\n        body: |\n\n          Joins the array of elements given as input, using the\n          argument as separator. It is the inverse of `split`: that is,\n          running `split(\"foo\") | join(\"foo\")` over any input string\n          returns said input string.\n\n          Numbers and booleans in the input are converted to strings.\n          Null values are treated as empty strings. Arrays and objects\n          in the input are not supported.\n\n        examples:\n          - program: 'join(\", \")'\n            input: '[\"a\",\"b,c,d\",\"e\"]'\n            output: ['\"a, b,c,d, e\"']\n          - program: 'join(\" \")'\n            input: '[\"a\",1,2.3,true,null,false]'\n            output: ['\"a 1 2.3 true  false\"']\n\n      - title: \"`ascii_downcase`, `ascii_upcase`\"\n        body: |\n\n          Emit a copy of the input string with its alphabetic characters (a-z and A-Z)\n          converted to the specified case.\n\n        examples:\n          - program: 'ascii_upcase'\n            input: '\"useful but not for é\"'\n            output: ['\"USEFUL BUT NOT FOR é\"']\n\n      - title: \"`while(cond; update)`\"\n        body: |\n\n          The `while(cond; update)` function allows you to repeatedly\n          apply an update to `.` until `cond` is false.\n\n          Note that `while(cond; update)` is internally defined as a\n          recursive jq function.  Recursive calls within `while` will\n          not consume additional memory if `update` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[while(.<100; .*2)]'\n            input: '1'\n            output: ['[1,2,4,8,16,32,64]']\n\n      - title: \"`repeat(exp)`\"\n        body: |\n\n          The `repeat(exp)` function allows you to repeatedly\n          apply expression `exp` to `.` until an error is raised.\n\n          Note that `repeat(exp)` is internally defined as a\n          recursive jq function.  Recursive calls within `repeat` will\n          not consume additional memory if `exp` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[repeat(.*2, error)?]'\n            input: '1'\n            output: ['[2]']\n\n      - title: \"`until(cond; next)`\"\n        body: |\n\n          The `until(cond; next)` function allows you to repeatedly\n          apply the expression `next`, initially to `.` then to its own\n          output, until `cond` is true.  For example, this can be used\n          to implement a factorial function (see below).\n\n          Note that `until(cond; next)` is internally defined as a\n          recursive jq function.  Recursive calls within `until()` will\n          not consume additional memory if `next` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]'\n            input: '4'\n            output: ['24']\n\n\n      - title: \"`recurse(f)`, `recurse`, `recurse(f; condition)`\"\n        body: |\n\n          The `recurse(f)` function allows you to search through a\n          recursive structure, and extract interesting data from all\n          levels. Suppose your input represents a filesystem:\n\n              {\"name\": \"/\", \"children\": [\n                {\"name\": \"/bin\", \"children\": [\n                  {\"name\": \"/bin/ls\", \"children\": []},\n                  {\"name\": \"/bin/sh\", \"children\": []}]},\n                {\"name\": \"/home\", \"children\": [\n                  {\"name\": \"/home/stephen\", \"children\": [\n                    {\"name\": \"/home/stephen/jq\", \"children\": []}]}]}]}\n\n          Now suppose you want to extract all of the filenames\n          present. You need to retrieve `.name`, `.children[].name`,\n          `.children[].children[].name`, and so on. You can do this\n          with:\n\n              recurse(.children[]) | .name\n\n          When called without an argument, `recurse` is equivalent to\n          `recurse(.[]?)`.\n\n          `recurse(f)` is identical to `recurse(f; true)` and can be\n          used without concerns about recursion depth.\n\n          `recurse(f; condition)` is a generator which begins by\n          emitting . and then emits in turn .|f, .|f|f, .|f|f|f, ...  so long\n          as the computed value satisfies the condition. For example,\n          to generate all the integers, at least in principle, one\n          could write `recurse(.+1; true)`.\n\n          The recursive calls in `recurse` will not consume additional\n          memory whenever `f` produces at most a single output for each\n          input.\n\n        examples:\n          - program: 'recurse(.foo[])'\n            input: '{\"foo\":[{\"foo\": []}, {\"foo\":[{\"foo\":[]}]}]}'\n            output:\n              - '{\"foo\":[{\"foo\":[]},{\"foo\":[{\"foo\":[]}]}]}'\n              - '{\"foo\":[]}'\n              - '{\"foo\":[{\"foo\":[]}]}'\n              - '{\"foo\":[]}'\n\n          - program: 'recurse'\n            input: '{\"a\":0,\"b\":[1]}'\n            output:\n              - '{\"a\":0,\"b\":[1]}'\n              - '0'\n              - '[1]'\n              - '1'\n\n          - program: 'recurse(. * .; . < 20)'\n            input: '2'\n            output: ['2', '4', '16']\n\n      - title: \"`walk(f)`\"\n        body: |\n\n          The `walk(f)` function applies f recursively to every\n          component of the input entity.  When an array is\n          encountered, f is first applied to its elements and then to\n          the array itself; when an object is encountered, f is first\n          applied to all the values and then to the object.  In\n          practice, f will usually test the type of its input, as\n          illustrated in the following examples.  The first example\n          highlights the usefulness of processing the elements of an\n          array of arrays before processing the array itself.  The second\n          example shows how all the keys of all the objects within the\n          input can be considered for alteration.\n\n        examples:\n          - program: 'walk(if type == \"array\" then sort else . end)'\n            input: '[[4, 1, 7], [8, 5, 2], [3, 6, 9]]'\n            output:\n              - '[[1,4,7],[2,5,8],[3,6,9]]'\n\n          - program: 'walk( if type == \"object\" then with_entries( .key |= sub( \"^_+\"; \"\") ) else . end )'\n            input: '[ { \"_a\": { \"__b\": 2 } } ]'\n            output:\n              - '[{\"a\":{\"b\":2}}]'\n\n      - title: \"`have_literal_numbers`\"\n        body: |\n\n          This builtin returns true if jq's build configuration\n          includes support for preservation of input number literals.\n\n      - title: \"`have_decnum`\"\n        body: |\n\n          This builtin returns true if jq was built with \"decnum\",\n          which is the current literal number preserving numeric\n          backend implementation for jq.\n\n      - title: \"`$JQ_BUILD_CONFIGURATION`\"\n        body: |\n\n          This builtin binding shows the jq executable's build\n          configuration.  Its value has no particular format, but\n          it can be expected to be at least the `./configure`\n          command-line arguments, and may be enriched in the\n          future to include the version strings for the build\n          tooling used.\n\n          Note that this can be overridden in the command-line\n          with `--arg` and related options.\n\n      - title: \"`$ENV`, `env`\"\n        body: |\n\n          `$ENV` is an object representing the environment variables as\n          set when the jq program started.\n\n          `env` outputs an object representing jq's current environment.\n\n          At the moment there is no builtin for setting environment\n          variables.\n\n        examples:\n          - program: '$ENV.PAGER'\n            input: 'null'\n            output: ['\"less\"']\n\n          - program: 'env.PAGER'\n            input: 'null'\n            output: ['\"less\"']\n\n      - title: \"`transpose`\"\n        body: |\n\n          Transpose a possibly jagged matrix (an array of arrays).\n          Rows are padded with nulls so the result is always rectangular.\n\n        examples:\n          - program: 'transpose'\n            input: '[[1], [2,3]]'\n            output: ['[[1,2],[null,3]]']\n\n      - title: \"`bsearch(x)`\"\n        body: |\n\n          `bsearch(x)` conducts a binary search for x in the input\n          array.  If the input is sorted and contains x, then\n          `bsearch(x)` will return its index in the array; otherwise, if\n          the array is sorted, it will return (-1 - ix) where ix is an\n          insertion point such that the array would still be sorted\n          after the insertion of x at ix.  If the array is not sorted,\n          `bsearch(x)` will return an integer that is probably of no\n          interest.\n\n        examples:\n          - program: 'bsearch(0)'\n            input: '[0,1]'\n            output: ['0']\n          - program: 'bsearch(0)'\n            input: '[1,2,3]'\n            output: ['-1']\n          - program: 'bsearch(4) as $ix | if $ix < 0 then .[-(1+$ix)] = 4 else . end'\n            input: '[1,2,3]'\n            output: ['[1,2,3,4]']\n\n      - title: \"String interpolation: `\\\\(exp)`\"\n        body: |\n\n          Inside a string, you can put an expression inside parens\n          after a backslash. Whatever the expression returns will be\n          interpolated into the string.\n\n        examples:\n          - program: '\"The input was \\(.), which is one less than \\(.+1)\"'\n            input: '42'\n            output: ['\"The input was 42, which is one less than 43\"']\n\n      - title: \"Convert to/from JSON\"\n        body: |\n\n          The `tojson` and `fromjson` builtins dump values as JSON texts\n          or parse JSON texts into values, respectively.  The `tojson`\n          builtin differs from `tostring` in that `tostring` returns strings\n          unmodified, while `tojson` encodes strings as JSON strings.\n\n        examples:\n          - program: '[.[]|tostring]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"foo\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"\\\"foo\\\"\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson|fromjson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[1,\"foo\",[\"foo\"]]']\n\n      - title: \"Format strings and escaping\"\n        body: |\n\n          The `@foo` syntax is used to format and escape strings,\n          which is useful for building URLs, documents in a language\n          like HTML or XML, and so forth. `@foo` can be used as a\n          filter on its own, the possible escapings are:\n\n          * `@text`:\n\n            Calls `tostring`, see that function for details.\n\n          * `@json`:\n\n            Serializes the input as JSON.\n\n          * `@html`:\n\n            Applies HTML/XML escaping, by mapping the characters\n            `<>&'\"` to their entity equivalents `&lt;`, `&gt;`,\n            `&amp;`, `&apos;`, `&quot;`.\n\n          * `@uri`:\n\n            Applies percent-encoding, by mapping all reserved URI\n            characters to a `%XX` sequence.\n\n          * `@urid`:\n\n            The inverse of `@uri`, applies percent-decoding, by mapping\n            all `%XX` sequences to their corresponding URI characters.\n\n          * `@csv`:\n\n            The input must be an array, and it is rendered as CSV\n            with double quotes for strings, and quotes escaped by\n            repetition.\n\n          * `@tsv`:\n\n            The input must be an array, and it is rendered as TSV\n            (tab-separated values). Each input array will be printed as\n            a single line. Fields are separated by a single\n            tab (ascii `0x09`). Input characters line-feed (ascii `0x0a`),\n            carriage-return (ascii `0x0d`), tab (ascii `0x09`) and\n            backslash (ascii `0x5c`) will be output as escape sequences\n            `\\n`, `\\r`, `\\t`, `\\\\` respectively.\n\n          * `@sh`:\n\n            The input is escaped suitable for use in a command-line\n            for a POSIX shell. If the input is an array, the output\n            will be a series of space-separated strings.\n\n          * `@base64`:\n\n            The input is converted to base64 as specified by RFC 4648.\n\n          * `@base64d`:\n\n            The inverse of `@base64`, input is decoded as specified by RFC 4648.\n            Note\\: If the decoded string is not UTF-8, the results are undefined.\n\n          This syntax can be combined with string interpolation in a\n          useful way. You can follow a `@foo` token with a string\n          literal. The contents of the string literal will *not* be\n          escaped. However, all interpolations made inside that string\n          literal will be escaped. For instance,\n\n              @uri \"https://www.google.com/search?q=\\(.search)\"\n\n          will produce the following output for the input\n          `{\"search\":\"what is jq?\"}`:\n\n              \"https://www.google.com/search?q=what%20is%20jq%3F\"\n\n          Note that the slashes, question mark, etc. in the URL are\n          not escaped, as they were part of the string literal.\n\n        examples:\n          - program: '@html'\n            input: '\"This works if x < y\"'\n            output: ['\"This works if x &lt; y\"']\n\n          - program: '@sh \"echo \\(.)\"'\n            input: \"\\\"O'Hara's Ale\\\"\"\n            output: [\"\\\"echo 'O'\\\\\\\\''Hara'\\\\\\\\''s Ale'\\\"\"]\n\n          - program: '@base64'\n            input: '\"This is a message\"'\n            output: ['\"VGhpcyBpcyBhIG1lc3NhZ2U=\"']\n\n          - program: '@base64d'\n            input: '\"VGhpcyBpcyBhIG1lc3NhZ2U=\"'\n            output: ['\"This is a message\"']\n\n      - title: \"Dates\"\n        body: |\n\n          jq provides some basic date handling functionality, with some\n          high-level and low-level builtins.  In all cases these\n          builtins deal exclusively with time in UTC.\n\n          The `fromdateiso8601` builtin parses datetimes in the ISO 8601\n          format to a number of seconds since the Unix epoch\n          (1970-01-01T00:00:00Z).  The `todateiso8601` builtin does the\n          inverse.\n\n          The `fromdate` builtin parses datetime strings.  Currently\n          `fromdate` only supports ISO 8601 datetime strings, but in the\n          future it will attempt to parse datetime strings in more\n          formats.\n\n          The `todate` builtin is an alias for `todateiso8601`.\n\n          The `now` builtin outputs the current time, in seconds since\n          the Unix epoch.\n\n          Low-level jq interfaces to the C-library time functions are\n          also provided: `strptime`, `strftime`, `strflocaltime`,\n          `mktime`, `gmtime`, and `localtime`.  Refer to your host\n          operating system's documentation for the format strings used\n          by `strptime` and `strftime`.  Note: these are not necessarily\n          stable interfaces in jq, particularly as to their localization\n          functionality.\n\n          The `gmtime` builtin consumes a number of seconds since the\n          Unix epoch and outputs a \"broken down time\" representation of\n          Greenwich Mean Time as an array of numbers representing\n          (in this order): the year, the month (zero-based), the day of\n          the month (one-based), the hour of the day, the minute of the\n          hour, the second of the minute, the day of the week, and the\n          day of the year -- all one-based unless otherwise stated.  The\n          day of the week number may be wrong on some systems for dates\n          before March 1st 1900, or after December 31 2099.\n\n          The `localtime` builtin works like the `gmtime` builtin, but\n          using the local timezone setting.\n\n          The `mktime` builtin consumes \"broken down time\"\n          representations of time output by `gmtime` and `strptime`.\n\n          The `strptime(fmt)` builtin parses input strings matching the\n          `fmt` argument.  The output is in the \"broken down time\"\n          representation consumed by `mktime` and output by `gmtime`.\n\n          The `strftime(fmt)` builtin formats a time (GMT) with the\n          given format.  The `strflocaltime` does the same, but using\n          the local timezone setting.\n\n          The format strings for `strptime` and `strftime` are described\n          in typical C library documentation.  The format string for ISO\n          8601 datetime is `\"%Y-%m-%dT%H:%M:%SZ\"`.\n\n          jq may not support some or all of this date functionality on\n          some systems. In particular, the `%u` and `%j` specifiers for\n          `strptime(fmt)` are not supported on macOS.\n\n        examples:\n          - program: 'fromdate'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['1425599507']\n\n          - program: 'strptime(\"%Y-%m-%dT%H:%M:%SZ\")'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['[2015,2,5,23,51,47,4,63]']\n\n          - program: 'strptime(\"%Y-%m-%dT%H:%M:%SZ\")|mktime'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['1425599507']\n\n      - title: \"SQL-Style Operators\"\n        body: |\n\n          jq provides a few SQL-style operators.\n\n          * `INDEX(stream; index_expression)`:\n\n            This builtin produces an object whose keys are computed by\n            the given index expression applied to each value from the\n            given stream.\n\n          * `JOIN($idx; stream; idx_expr; join_expr)`:\n\n            This builtin joins the values from the given stream to the\n            given index.  The index's keys are computed by applying the\n            given index expression to each value from the given stream.\n            An array of the value in the stream and the corresponding\n            value from the index is fed to the given join expression to\n            produce each result.\n\n          * `JOIN($idx; stream; idx_expr)`:\n\n            Same as `JOIN($idx; stream; idx_expr; .)`.\n\n          * `JOIN($idx; idx_expr)`:\n\n            This builtin joins the input `.` to the given index, applying\n            the given index expression to `.` to compute the index key.\n            The join operation is as described above.\n\n          * `IN(s)`:\n\n            This builtin outputs `true` if `.` appears in the given\n            stream, otherwise it outputs `false`.\n\n          * `IN(source; s)`:\n\n            This builtin outputs `true` if any value in the source stream\n            appears in the second stream, otherwise it outputs `false`.\n\n      - title: \"`builtins`\"\n        body: |\n\n          Returns a list of all builtin functions in the format `name/arity`.\n          Since functions with the same name but different arities are considered\n          separate functions, `all/0`, `all/1`, and `all/2` would all be present\n          in the list.\n\n  - title: Conditionals and Comparisons\n    entries:\n      - title: \"`==`, `!=`\"\n        body: |\n\n          The expression 'a == b' will produce 'true' if the results of evaluating\n          a and b are equal (that is, if they represent equivalent JSON values) and\n          'false' otherwise. In particular, strings are never considered equal\n          to numbers.  In checking for the equality of JSON objects, the ordering of keys\n          is irrelevant.  If you're coming from JavaScript, please note that jq's `==` is like\n          JavaScript's `===`, the \"strict equality\" operator.\n\n          != is \"not equal\", and 'a != b' returns the opposite value of 'a == b'\n\n        examples:\n          - program: '. == false'\n            input: 'null'\n            output: ['false']\n\n          - program: '. == {\"b\": {\"d\": (4 + 1e-20), \"c\": 3}, \"a\":1}'\n            input: '{\"a\":1, \"b\": {\"c\": 3, \"d\": 4}}'\n            output: ['true']\n\n          - program: '.[] == 1'\n            input: '[1, 1.0, \"1\", \"banana\"]'\n            output: ['true', 'true', 'false', 'false']\n\n      - title: if-then-else-end\n        body: |\n\n          `if A then B else C end` will act the same as `B` if `A`\n          produces a value other than false or null, but act the same\n          as `C` otherwise.\n\n          `if A then B end` is the same as `if A then B else .  end`.\n          That is, the `else` branch is optional, and if absent is the\n          same as `.`. This also applies to `elif` with absent ending `else` branch.\n\n          Checking for false or null is a simpler notion of\n          \"truthiness\" than is found in JavaScript or Python, but it\n          means that you'll sometimes have to be more explicit about\n          the condition you want.  You can't test whether, e.g. a\n          string is empty using `if .name then A else B end`; you'll\n          need something like `if .name == \"\" then A else B end` instead.\n\n          If the condition `A` produces multiple results, then `B` is evaluated\n          once for each result that is not false or null, and `C` is evaluated\n          once for each false or null.\n\n          More cases can be added to an if using `elif A then B` syntax.\n\n        examples:\n          - program: |-\n              if . == 0 then\n                \"zero\"\n              elif . == 1 then\n                \"one\"\n              else\n                \"many\"\n              end\n            input: '2'\n            output: ['\"many\"']\n\n      - title: \"`>`, `>=`, `<=`, `<`\"\n        body: |\n\n          The comparison operators `>`, `>=`, `<=`, `<` return whether\n          their left argument is greater than, greater than or equal\n          to, less than or equal to or less than their right argument\n          (respectively).\n\n          The ordering is the same as that described for `sort`, above.\n\n        examples:\n          - program: '. < 5'\n            input: '2'\n            output: ['true']\n\n      - title: \"`and`, `or`, `not`\"\n        body: |\n\n          jq supports the normal Boolean operators `and`, `or`, `not`.\n          They have the same standard of truth as if expressions -\n          `false` and `null` are considered \"false values\", and\n          anything else is a \"true value\".\n\n          If an operand of one of these operators produces multiple\n          results, the operator itself will produce a result for each input.\n\n          `not` is in fact a builtin function rather than an operator,\n          so it is called as a filter to which things can be piped\n          rather than with special syntax, as in `.foo and .bar |\n          not`.\n\n          These three only produce the values `true` and `false`, and\n          so are only useful for genuine Boolean operations, rather\n          than the common Perl/Python/Ruby idiom of\n          \"value_that_may_be_null or default\". If you want to use this\n          form of \"or\", picking between two values rather than\n          evaluating a condition, see the `//` operator below.\n\n        examples:\n          - program: '42 and \"a string\"'\n            input: 'null'\n            output: ['true']\n          - program: '(true, false) or false'\n            input: 'null'\n            output: ['true', 'false']\n          - program: '(true, true) and (true, false)'\n            input: 'null'\n            output: ['true', 'false', 'true', 'false']\n          - program: '[true, false | not]'\n            input: 'null'\n            output: ['[false, true]']\n\n      - title: \"Alternative operator: `//`\"\n        body: |\n\n          The `//` operator produces all the values of its left-hand\n          side that are neither `false` nor `null`. If the\n          left-hand side produces no values other than `false` or\n          `null`, then `//` produces all the values of its right-hand\n          side.\n\n          A filter of the form `a // b` produces all the results of\n          `a` that are not `false` or `null`.  If `a` produces no\n          results, or no results other than `false` or `null`, then `a\n          // b` produces the results of `b`.\n\n          This is useful for providing defaults: `.foo // 1` will\n          evaluate to `1` if there's no `.foo` element in the\n          input. It's similar to how `or` is sometimes used in Python\n          (jq's `or` operator is reserved for strictly Boolean\n          operations).\n\n          Note: `some_generator // defaults_here` is not the same\n          as `some_generator | . // defaults_here`.  The latter will\n          produce default values for all non-`false`, non-`null`\n          values of the left-hand side, while the former will not.\n          Precedence rules can make this confusing.  For example, in\n          `false, 1 // 2` the left-hand side of `//` is `1`, not\n          `false, 1` -- `false, 1 // 2` parses the same way as `false,\n          (1 // 2)`.  In `(false, null, 1) | . // 42` the left-hand\n          side of `//` is `.`, which always produces just one value,\n          while in `(false, null, 1) // 42` the left-hand side is a\n          generator of three values, and since it produces a\n          value other `false` and `null`, the default `42` is not\n          produced.\n\n        examples:\n          - program: 'empty // 42'\n            input: 'null'\n            output: ['42']\n          - program: '.foo // 42'\n            input: '{\"foo\": 19}'\n            output: ['19']\n          - program: '.foo // 42'\n            input: '{}'\n            output: ['42']\n          - program: '(false, null, 1) // 42'\n            input: 'null'\n            output: ['1']\n          - program: '(false, null, 1) | . // 42'\n            input: 'null'\n            output: ['42', '42', '1']\n\n      - title: try-catch\n        body: |\n\n          Errors can be caught by using `try EXP catch EXP`.  The first\n          expression is executed, and if it fails then the second is\n          executed with the error message.  The output of the handler,\n          if any, is output as if it had been the output of the\n          expression to try.\n\n          The `try EXP` form uses `empty` as the exception handler.\n\n        examples:\n          - program: 'try .a catch \". is not an object\"'\n            input: 'true'\n            output: ['\". is not an object\"']\n          - program: '[.[]|try .a]'\n            input: '[{}, true, {\"a\":1}]'\n            output: ['[null, 1]']\n          - program: 'try error(\"some exception\") catch .'\n            input: 'true'\n            output: ['\"some exception\"']\n\n      - title: Breaking out of control structures\n        body: |\n\n          A convenient use of try/catch is to break out of control\n          structures like `reduce`, `foreach`, `while`, and so on.\n\n          For example:\n\n              # Repeat an expression until it raises \"break\" as an\n              # error, then stop repeating without re-raising the error.\n              # But if the error caught is not \"break\" then re-raise it.\n              try repeat(exp) catch if .==\"break\" then empty else error\n\n          jq has a syntax for named lexical labels to \"break\" or \"go (back) to\":\n\n              label $out | ... break $out ...\n\n          The `break $label_name` expression will cause the program to\n          act as though the nearest (to the left) `label $label_name`\n          produced `empty`.\n\n          The relationship between the `break` and corresponding `label`\n          is lexical: the label has to be \"visible\" from the break.\n\n          To break out of a `reduce`, for example:\n\n              label $out | reduce .[] as $item (null; if .==false then break $out else ... end)\n\n          The following jq program produces a syntax error:\n\n              break $out\n\n          because no label `$out` is visible.\n\n      - title: \"Error Suppression / Optional Operator: `?`\"\n        body: |\n\n          The `?` operator, used as `EXP?`, is shorthand for `try EXP`.\n\n        examples:\n          - program: '[.[] | .a?]'\n            input: '[{}, true, {\"a\":1}]'\n            output: ['[null, 1]']\n          - program: '[.[] | tonumber?]'\n            input: '[\"1\", \"invalid\", \"3\", 4]'\n            output: ['[1, 3, 4]']\n\n  - title: Regular expressions\n    body: |\n\n      jq uses the\n      [Oniguruma regular expression library](https://github.com/kkos/oniguruma/blob/master/doc/RE),\n      as do PHP, TextMate, Sublime Text, etc, so the\n      description here will focus on jq specifics.\n\n      Oniguruma supports several flavors of regular expression, so it is important to know\n      that jq uses the [\"Perl NG\" (Perl with named groups)](https://github.com/kkos/oniguruma/blob/master/doc/SYNTAX.md) flavor.\n\n      The jq regex filters are defined so that they can be used using\n      one of these patterns:\n\n          STRING | FILTER(REGEX)\n          STRING | FILTER(REGEX; FLAGS)\n          STRING | FILTER([REGEX])\n          STRING | FILTER([REGEX, FLAGS])\n\n      where:\n\n      * STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;\n      * REGEX, after string interpolation, should be a valid regular expression;\n      * FILTER is one of `test`, `match`, or `capture`, as described below.\n\n      Since REGEX must evaluate to a JSON string, some characters that are needed\n      to form a regular expression must be escaped. For example, the regular expression\n      `\\s` signifying a whitespace character would be written as `\"\\\\s\"`.\n\n      FLAGS is a string consisting of one of more of the supported flags:\n\n      * `g` - Global search (find all matches, not just the first)\n      * `i` - Case insensitive search\n      * `m` - Multi line mode (`.` will match newlines)\n      * `n` - Ignore empty matches\n      * `p` - Both s and m modes are enabled\n      * `s` - Single line mode (`^` -> `\\A`, `$` -> `\\Z`)\n      * `l` - Find longest possible matches\n      * `x` - Extended regex format (ignore whitespace and comments)\n\n      To match a whitespace with the `x` flag, use `\\s`, e.g.\n\n          jq -n '\"a b\" | test(\"a\\\\sb\"; \"x\")'\n\n      Note that certain flags may also be specified within REGEX, e.g.\n\n          jq -n '(\"test\", \"TEst\", \"teST\", \"TEST\") | test(\"(?i)te(?-i)st\")'\n\n      evaluates to: `true`, `true`, `false`, `false`.\n\n    entries:\n      - title: \"`test(val)`, `test(regex; flags)`\"\n        body: |\n\n          Like `match`, but does not return match objects, only `true` or `false`\n          for whether or not the regex matches the input.\n\n        examples:\n          - program: 'test(\"foo\")'\n            input: '\"foo\"'\n            output: ['true']\n          - program: '.[] | test(\"a b c # spaces are ignored\"; \"ix\")'\n            input: '[\"xabcd\", \"ABC\"]'\n            output: ['true', 'true']\n\n      - title: \"`match(val)`, `match(regex; flags)`\"\n        body: |\n\n          **match** outputs an object for each match it finds.  Matches have\n          the following fields:\n\n          * `offset` - offset in UTF-8 codepoints from the beginning of the input\n          * `length` - length in UTF-8 codepoints of the match\n          * `string` - the string that it matched\n          * `captures` - an array of objects representing capturing groups.\n\n          Capturing group objects have the following fields:\n\n          * `offset` - offset in UTF-8 codepoints from the beginning of the input\n          * `length` - length in UTF-8 codepoints of this capturing group\n          * `string` - the string that was captured\n          * `name` - the name of the capturing group (or `null` if it was unnamed)\n\n          Capturing groups that did not match anything return an offset of -1\n\n        examples:\n          - program: 'match(\"(abc)+\"; \"g\")'\n            input: '\"abc abc\"'\n            output:\n             - '{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"name\": null}]}'\n             - '{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"name\": null}]}'\n          - program: 'match(\"foo\")'\n            input: '\"foo bar foo\"'\n            output: ['{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}']\n          - program: 'match([\"foo\", \"ig\"])'\n            input: '\"foo bar FOO\"'\n            output:\n             - '{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}'\n             - '{\"offset\": 8, \"length\": 3, \"string\": \"FOO\", \"captures\": []}'\n          - program: 'match(\"foo (?<bar123>bar)? foo\"; \"ig\")'\n            input: '\"foo bar foo foo  foo\"'\n            output:\n             - '{\"offset\": 0, \"length\": 11, \"string\": \"foo bar foo\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"bar\", \"name\": \"bar123\"}]}'\n             - '{\"offset\": 12, \"length\": 8, \"string\": \"foo  foo\", \"captures\": [{\"offset\": -1, \"length\": 0, \"string\": null, \"name\": \"bar123\"}]}'\n\n          - program: '[ match(\".\"; \"g\")] | length'\n            input: '\"abc\"'\n            output: ['3']\n\n\n      - title: \"`capture(val)`, `capture(regex; flags)`\"\n        body: |\n\n         Collects the named captures in a JSON object, with the name\n         of each capture as the key, and the matched string as the\n         corresponding value.\n\n        examples:\n          - program: 'capture(\"(?<a>[a-z]+)-(?<n>[0-9]+)\")'\n            input: '\"xyzzy-14\"'\n            output: ['{ \"a\": \"xyzzy\", \"n\": \"14\" }']\n\n      - title: \"`scan(regex)`, `scan(regex; flags)`\"\n        body: |\n\n          Emit a stream of the non-overlapping substrings of the input\n          that match the regex in accordance with the flags, if any\n          have been specified.  If there is no match, the stream is empty.\n          To capture all the matches for each input string, use the idiom\n          `[ expr ]`, e.g. `[ scan(regex) ]`.  If the regex contains capturing\n          groups, the filter emits a stream of arrays, each of which contains\n          the captured strings.\n\n        examples:\n          - program: 'scan(\"c\")'\n            input: '\"abcdefabc\"'\n            output: ['\"c\"', '\"c\"']\n          - program: 'scan(\"(a+)(b+)\")'\n            input: '\"abaabbaaabbb\"'\n            output: ['[\"a\",\"b\"]', '[\"aa\",\"bb\"]', '[\"aaa\",\"bbb\"]']\n\n      - title: \"`split(regex; flags)`\"\n        body: |\n\n          Splits an input string on each regex match.\n\n          For backwards compatibility, when called with a single argument,\n          `split` splits on a string, not a regex.\n\n        examples:\n          - program: 'split(\", *\"; null)'\n            input: '\"ab,cd, ef\"'\n            output: ['[\"ab\",\"cd\",\"ef\"]']\n\n\n      - title: \"`splits(regex)`, `splits(regex; flags)`\"\n        body: |\n\n          These provide the same results as their `split` counterparts,\n          but as a stream instead of an array.\n\n        examples:\n          - program: 'splits(\", *\")'\n            input: '\"ab,cd,   ef, gh\"'\n            output: ['\"ab\"','\"cd\"','\"ef\"','\"gh\"']\n          - program: 'splits(\",? *\"; \"n\")'\n            input: '\"ab,cd ef,  gh\"'\n            output: ['\"ab\"','\"cd\"','\"ef\"','\"gh\"']\n\n      - title: \"`sub(regex; tostring)`, `sub(regex; tostring; flags)`\"\n        body: |\n\n          Emit the string obtained by replacing the first match of\n          regex in the input string with `tostring`, after\n          interpolation.  `tostring` should be a jq string or a stream\n          of such strings, each of which may contain references to\n          named captures. The named captures are, in effect, presented\n          as a JSON object (as constructed by `capture`) to\n          `tostring`, so a reference to a captured variable named \"x\"\n          would take the form: `\"\\(.x)\"`.\n\n        examples:\n          - program: 'sub(\"[^a-z]*(?<x>[a-z]+)\"; \"Z\\(.x)\"; \"g\")'\n            input: '\"123abc456def\"'\n            output: ['\"ZabcZdef\"']\n\n          - program: '[sub(\"(?<a>.)\"; \"\\(.a|ascii_upcase)\", \"\\(.a|ascii_downcase)\")]'\n            input: '\"aB\"'\n            output: ['[\"AB\",\"aB\"]']\n\n      - title: \"`gsub(regex; tostring)`, `gsub(regex; tostring; flags)`\"\n        body: |\n\n          `gsub` is like `sub` but all the non-overlapping occurrences of the regex are\n          replaced by `tostring`, after interpolation. If the second argument is a stream\n          of jq strings, then `gsub` will produce a corresponding stream of JSON strings.\n\n        examples:\n          - program: 'gsub(\"(?<x>.)[^a]*\"; \"+\\(.x)-\")'\n            input: '\"Abcabc\"'\n            output: ['\"+A-+a-\"']\n\n          - program: '[gsub(\"p\"; \"a\", \"b\")]'\n            input: '\"p\"'\n            output: ['[\"a\",\"b\"]']\n\n\n  - title: Advanced features\n    body: |\n      Variables are an absolute necessity in most programming languages, but\n      they're relegated to an \"advanced feature\" in jq.\n\n      In most languages, variables are the only means of passing around\n      data. If you calculate a value, and you want to use it more than once,\n      you'll need to store it in a variable. To pass a value to another part\n      of the program, you'll need that part of the program to define a\n      variable (as a function parameter, object member, or whatever) in\n      which to place the data.\n\n      It is also possible to define functions in jq, although this is\n      is a feature whose biggest use is defining jq's standard library\n      (many jq functions such as `map` and `select` are in fact written\n      in jq).\n\n      jq has reduction operators, which are very powerful but a bit\n      tricky.  Again, these are mostly used internally, to define some\n      useful bits of jq's standard library.\n\n      It may not be obvious at first, but jq is all about generators\n      (yes, as often found in other languages).  Some utilities are\n      provided to help deal with generators.\n\n      Some minimal I/O support (besides reading JSON from standard\n      input, and writing JSON to standard output) is available.\n\n      Finally, there is a module/library system.\n\n    entries:\n      - title: \"Variable / Symbolic Binding Operator: `... as $identifier | ...`\"\n        body: |\n\n          In jq, all filters have an input and an output, so manual\n          plumbing is not necessary to pass a value from one part of a program\n          to the next. Many expressions, for instance `a + b`, pass their input\n          to two distinct subexpressions (here `a` and `b` are both passed the\n          same input), so variables aren't usually necessary in order to use a\n          value twice.\n\n          For instance, calculating the average value of an array of numbers\n          requires a few variables in most languages - at least one to hold the\n          array, perhaps one for each element or for a loop counter. In jq, it's\n          simply `add / length` - the `add` expression is given the array and\n          produces its sum, and the `length` expression is given the array and\n          produces its length.\n\n          So, there's generally a cleaner way to solve most problems in jq than\n          defining variables. Still, sometimes they do make things easier, so jq\n          lets you define variables using `expression as $variable`. All\n          variable names start with `$`. Here's a slightly uglier version of the\n          array-averaging example:\n\n              length as $array_length | add / $array_length\n\n          We'll need a more complicated problem to find a situation where using\n          variables actually makes our lives easier.\n\n\n          Suppose we have an array of blog posts, with \"author\" and \"title\"\n          fields, and another object which is used to map author usernames to\n          real names. Our input looks like:\n\n              {\"posts\": [{\"title\": \"First post\", \"author\": \"anon\"},\n                         {\"title\": \"A well-written article\", \"author\": \"person1\"}],\n               \"realnames\": {\"anon\": \"Anonymous Coward\",\n                             \"person1\": \"Person McPherson\"}}\n\n          We want to produce the posts with the author field containing a real\n          name, as in:\n\n              {\"title\": \"First post\", \"author\": \"Anonymous Coward\"}\n              {\"title\": \"A well-written article\", \"author\": \"Person McPherson\"}\n\n          We use a variable, `$names`, to store the realnames object, so that we\n          can refer to it later when looking up author usernames:\n\n              .realnames as $names | .posts[] | {title, author: $names[.author]}\n\n          The expression `exp as $x | ...` means: for each value of expression\n          `exp`, run the rest of the pipeline with the entire original input, and\n          with `$x` set to that value.  Thus `as` functions as something of a\n          foreach loop.\n\n          Just as `{foo}` is a handy way of writing `{foo: .foo}`, so\n          `{$foo}` is a handy way of writing `{foo: $foo}`.\n\n          Multiple variables may be declared using a single `as` expression by\n          providing a pattern that matches the structure of the input\n          (this is known as \"destructuring\"):\n\n              . as {realnames: $names, posts: [$first, $second]} | ...\n\n          The variable declarations in array patterns (e.g., `. as\n          [$first, $second]`) bind to the elements of the array in from\n          the element at index zero on up, in order.  When there is no\n          value at the index for an array pattern element, `null` is\n          bound to that variable.\n\n          Variables are scoped over the rest of the expression that defines\n          them, so\n\n              .realnames as $names | (.posts[] | {title, author: $names[.author]})\n\n          will work, but\n\n              (.realnames as $names | .posts[]) | {title, author: $names[.author]}\n\n          won't.\n\n          For programming language theorists, it's more accurate to\n          say that jq variables are lexically-scoped bindings.  In\n          particular there's no way to change the value of a binding;\n          one can only setup a new binding with the same name, but which\n          will not be visible where the old one was.\n\n        examples:\n          - program: '.bar as $x | .foo | . + $x'\n            input: '{\"foo\":10, \"bar\":200}'\n            output: ['210']\n          - program: '. as $i|[(.*2|. as $i| $i), $i]'\n            input: '5'\n            output: ['[10,5]']\n          - program: '. as [$a, $b, {c: $c}] | $a + $b + $c'\n            input: '[2, 3, {\"c\": 4, \"d\": 5}]'\n            output: ['9']\n          - program: '.[] as [$a, $b] | {a: $a, b: $b}'\n            input: '[[0], [0, 1], [2, 1, 0]]'\n            output: ['{\"a\":0,\"b\":null}', '{\"a\":0,\"b\":1}', '{\"a\":2,\"b\":1}']\n\n      - title: 'Destructuring Alternative Operator: `?//`'\n        body: |\n\n          The destructuring alternative operator provides a concise mechanism\n          for destructuring an input that can take one of several forms.\n\n          Suppose we have an API that returns a list of resources and events\n          associated with them, and we want to get the user_id and timestamp of\n          the first event for each resource. The API (having been clumsily\n          converted from XML) will only wrap the events in an array if the resource\n          has multiple events:\n\n              {\"resources\": [{\"id\": 1, \"kind\": \"widget\", \"events\": {\"action\": \"create\", \"user_id\": 1, \"ts\": 13}},\n                             {\"id\": 2, \"kind\": \"widget\", \"events\": [{\"action\": \"create\", \"user_id\": 1, \"ts\": 14}, {\"action\": \"destroy\", \"user_id\": 1, \"ts\": 15}]}]}\n\n          We can use the destructuring alternative operator to handle this structural change simply:\n\n              .resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}\n\n          Or, if we aren't sure if the input is an array of values or an object:\n\n              .[] as [$id, $kind, $user_id, $ts] ?// {$id, $kind, $user_id, $ts} | ...\n\n          Each alternative need not define all of the same variables, but all named\n          variables will be available to the subsequent expression. Variables not\n          matched in the alternative that succeeded will be `null`:\n\n              .resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$first_user_id, $first_ts}]} | {$user_id, $first_user_id, $kind, $id, $ts, $first_ts}\n\n          Additionally, if the subsequent expression returns an error, the\n          alternative operator will attempt to try the next binding. Errors\n          that occur during the final alternative are passed through.\n\n              [[3]] | .[] as [$a] ?// [$b] | if $a != null then error(\"err: \\($a)\") else {$a,$b} end\n\n        examples:\n          - program: '.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}'\n            input: '[{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]'\n            output: ['{\"a\":1,\"b\":2,\"d\":3,\"e\":4}', '{\"a\":1,\"b\":2,\"d\":3,\"e\":4}']\n          - program: '.[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}'\n            input: '[{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]'\n            output: ['{\"a\":1,\"b\":2,\"d\":3,\"e\":null}', '{\"a\":1,\"b\":2,\"d\":null,\"e\":4}']\n          - program: '.[] as [$a] ?// [$b] | if $a != null then error(\"err: \\($a)\") else {$a,$b} end'\n            input: '[[3]]'\n            output: ['{\"a\":null,\"b\":3}']\n\n      - title: 'Defining Functions'\n        body: |\n\n          You can give a filter a name using \"def\" syntax:\n\n              def increment: . + 1;\n\n          From then on, `increment` is usable as a filter just like a\n          builtin function (in fact, this is how many of the builtins\n          are defined). A function may take arguments:\n\n              def map(f): [.[] | f];\n\n          Arguments are passed as _filters_ (functions with no\n          arguments), _not_ as values. The same argument may be\n          referenced multiple times with different inputs (here `f` is\n          run for each element of the input array).  Arguments to a\n          function work more like callbacks than like value arguments.\n          This is important to understand.  Consider:\n\n              def foo(f): f|f;\n              5|foo(.*2)\n\n          The result will be 20 because `f` is `.*2`, and during the\n          first invocation of `f` `.` will be 5, and the second time it\n          will be 10 (5 * 2), so the result will be 20.  Function\n          arguments are filters, and filters expect an input when\n          invoked.\n\n          If you want the value-argument behaviour for defining simple\n          functions, you can just use a variable:\n\n              def addvalue(f): f as $f | map(. + $f);\n\n          Or use the short-hand:\n\n              def addvalue($f): ...;\n\n          With either definition, `addvalue(.foo)` will add the current\n          input's `.foo` field to each element of the array.  Do note\n          that calling `addvalue(.[])` will cause the `map(. + $f)` part\n          to be evaluated once per value in the value of `.` at the call\n          site.\n\n          Multiple definitions using the same function name are allowed.\n          Each re-definition replaces the previous one for the same\n          number of function arguments, but only for references from\n          functions (or main program) subsequent to the re-definition.\n          See also the section below on scoping.\n\n        examples:\n          - program: 'def addvalue(f): . + [f]; map(addvalue(.[0]))'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1], [10,20,10]]']\n          - program: 'def addvalue(f): f as $x | map(. + $x); addvalue(.[0])'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1,2], [10,20,1,2]]']\n\n      - title: 'Scoping'\n        body: |\n\n          There are two types of symbols in jq: value bindings (a.k.a.,\n          \"variables\"), and functions.  Both are scoped lexically,\n          with expressions being able to refer only to symbols that\n          have been defined \"to the left\" of them.  The only exception\n          to this rule is that functions can refer to themselves so as\n          to be able to create recursive functions.\n\n          For example, in the following expression there is a binding\n          which is visible \"to the right\" of it, `... | .*3 as\n          $times_three | [. + $times_three] | ...`, but not \"to the\n          left\".  Consider this expression now, `... | (.*3 as\n          $times_three | [. + $times_three]) | ...`: here the binding\n          `$times_three` is _not_ visible past the closing parenthesis.\n\n      - title: \"`isempty(exp)`\"\n        body: |\n\n          Returns true if `exp` produces no outputs, false otherwise.\n\n        examples:\n          - program: 'isempty(empty)'\n            input: 'null'\n            output: ['true']\n\n          - program: 'isempty(.[])'\n            input: '[]'\n            output: ['true']\n\n          - program: 'isempty(.[])'\n            input: '[1,2,3]'\n            output: ['false']\n\n      - title: \"`limit(n; expr)`\"\n        body: |\n\n          The `limit` function extracts up to `n` outputs from `expr`.\n\n        examples:\n          - program: '[limit(3; .[])]'\n            input: '[0,1,2,3,4,5,6,7,8,9]'\n            output: ['[0,1,2]']\n\n      - title: \"`skip(n; expr)`\"\n        body: |\n\n          The `skip` function skips the first `n` outputs from `expr`.\n\n        examples:\n          - program: '[skip(3; .[])]'\n            input: '[0,1,2,3,4,5,6,7,8,9]'\n            output: ['[3,4,5,6,7,8,9]']\n\n      - title: \"`first(expr)`, `last(expr)`, `nth(n; expr)`\"\n        body: |\n\n          The `first(expr)` and `last(expr)` functions extract the first\n          and last values from `expr`, respectively.\n\n          The `nth(n; expr)` function extracts the nth value output by `expr`.\n          Note that `nth(n; expr)` doesn't support negative values of `n`.\n\n        examples:\n          - program: '[first(range(.)), last(range(.)), nth(5; range(.))]'\n            input: '10'\n            output: ['[0,9,5]']\n          - program: '[first(empty), last(empty), nth(5; empty)]'\n            input: 'null'\n            output: ['[]']\n\n      - title: \"`first`, `last`, `nth(n)`\"\n        body: |\n\n          The `first` and `last` functions extract the first\n          and last values from any array at `.`.\n\n          The `nth(n)` function extracts the nth value of any array at `.`.\n\n        examples:\n          - program: '[range(.)]|[first, last, nth(5)]'\n            input: '10'\n            output: ['[0,9,5]']\n\n      - title: \"`reduce`\"\n        body: |\n\n          The `reduce` syntax allows you to combine all of the results of\n          an expression by accumulating them into a single answer.\n          The form is `reduce EXP as $var (INIT; UPDATE)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              reduce .[] as $item (0; . + $item)\n\n          For each result that `.[]` produces, `. + $item` is run to\n          accumulate a running total, starting from 0 as the input value.\n          In this example, `.[]` produces the results `1`, `2`, and `3`,\n          so the effect is similar to running something like this:\n\n              0 | 1 as $item | . + $item |\n                  2 as $item | . + $item |\n                  3 as $item | . + $item\n\n        examples:\n          - program: 'reduce .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['15']\n\n          - program: 'reduce .[] as [$i,$j] (0; . + $i * $j)'\n            input: '[[1,2],[3,4],[5,6]]'\n            output: ['44']\n\n          - program: 'reduce .[] as {$x,$y} (null; .x += $x | .y += [$y])'\n            input: '[{\"x\":\"a\",\"y\":1},{\"x\":\"b\",\"y\":2},{\"x\":\"c\",\"y\":3}]'\n            output: ['{\"x\":\"abc\",\"y\":[1,2,3]}']\n\n      - title: \"`foreach`\"\n        body: |\n\n          The `foreach` syntax is similar to `reduce`, but intended to\n          allow the construction of `limit` and reducers that produce\n          intermediate results.\n\n          The form is `foreach EXP as $var (INIT; UPDATE; EXTRACT)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              foreach .[] as $item (0; . + $item; [$item, . * 2])\n\n          Like the `reduce` syntax, `. + $item` is run for each result\n          that `.[]` produces, but `[$item, . * 2]` is run for each\n          intermediate values. In this example, since the intermediate\n          values are `1`, `3`, and `6`, the `foreach` expression produces\n          `[1,2]`, `[2,6]`, and `[3,12]`. So the effect is similar\n          to running something like this:\n\n              0 | 1 as $item | . + $item | [$item, . * 2],\n                  2 as $item | . + $item | [$item, . * 2],\n                  3 as $item | . + $item | [$item, . * 2]\n\n          When `EXTRACT` is omitted, the identity filter is used.\n          That is, it outputs the intermediate values as they are.\n\n        examples:\n          - program: 'foreach .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['1','3','6','10','15']\n\n          - program: 'foreach .[] as $item (0; . + $item; [$item, . * 2])'\n            input: '[1,2,3,4,5]'\n            output: ['[1,2]','[2,6]','[3,12]','[4,20]','[5,30]']\n\n          - program: 'foreach .[] as $item (0; . + 1; {index: ., $item})'\n            input: '[\"foo\", \"bar\", \"baz\"]'\n            output:\n              - '{\"index\":1,\"item\":\"foo\"}'\n              - '{\"index\":2,\"item\":\"bar\"}'\n              - '{\"index\":3,\"item\":\"baz\"}'\n\n      - title: Recursion\n        body: |\n\n          As described above, `recurse` uses recursion, and any jq\n          function can be recursive.  The `while` builtin is also\n          implemented in terms of recursion.\n\n          Tail calls are optimized whenever the expression to the left of\n          the recursive call outputs its last value.  In practice this\n          means that the expression to the left of the recursive call\n          should not produce more than one output for each input.\n\n          For example:\n\n              def recurse(f): def r: ., (f | select(. != null) | r); r;\n\n              def while(cond; update):\n                def _while:\n                  if cond then ., (update | _while) else empty end;\n                _while;\n\n              def repeat(exp):\n                def _repeat:\n                  exp, _repeat;\n                _repeat;\n\n      - title: Generators and iterators\n        body: |\n\n            Some jq operators and functions are actually generators in\n            that they can produce zero, one, or more values for each\n            input, just as one might expect in other programming\n            languages that have generators.  For example, `.[]`\n            generates all the values in its input (which must be an\n            array or an object), `range(0; 10)` generates the integers\n            between 0 and 10, and so on.\n\n            Even the comma operator is a generator, generating first\n            the values generated by the expression to the left of the\n            comma, then the values generated by the expression on the\n            right of the comma.\n\n            The `empty` builtin is the generator that produces zero\n            outputs.  The `empty` builtin backtracks to the preceding\n            generator expression.\n\n            All jq functions can be generators just by using builtin\n            generators.  It is also possible to construct new generators\n            using only recursion and the comma operator.  If\n            recursive calls are \"in tail position\" then the\n            generator will be efficient.  In the example below the\n            recursive call by `_range` to itself is in tail position.\n            The example shows off three advanced topics: tail recursion,\n            generator construction, and sub-functions.\n\n        examples:\n          - program: 'def range(init; upto; by):\n                    def _range:\n                        if (by > 0 and . < upto) or (by < 0 and . > upto)\n                        then ., ((.+by)|_range)\n                        else empty end;\n                    if init == upto then empty elif by == 0 then init else init|_range end;\n                range(0; 10; 3)'\n            input: 'null'\n            output: ['0', '3', '6', '9']\n          - program: 'def while(cond; update):\n                    def _while:\n                        if cond then ., (update | _while) else empty end;\n                    _while;\n                [while(.<100; .*2)]'\n            input: '1'\n            output: ['[1,2,4,8,16,32,64]']\n\n  - title: 'Math'\n    body: |\n\n      jq currently only has IEEE754 double-precision (64-bit) floating\n      point number support.\n\n      Besides simple arithmetic operators such as `+`, jq also has most\n      standard math functions from the C math library.  C math functions\n      that take a single input argument (e.g., `sin()`) are available as\n      zero-argument jq functions.  C math functions that take two input\n      arguments (e.g., `pow()`) are available as two-argument jq\n      functions that ignore `.`.  C math functions that take three input\n      arguments are available as three-argument jq functions that ignore\n      `.`.\n\n      Availability of standard math functions depends on the\n      availability of the corresponding math functions in your operating\n      system and C math library.  Unavailable math functions will be\n      defined but will raise an error.\n\n      One-input C math functions: `acos` `acosh` `asin` `asinh` `atan`\n      `atanh` `cbrt` `ceil` `cos` `cosh` `erf` `erfc` `exp` `exp10`\n      `exp2` `expm1` `fabs` `floor` `gamma` `j0` `j1` `lgamma` `log`\n      `log10` `log1p` `log2` `logb` `nearbyint` `rint` `round`\n      `significand` `sin` `sinh` `sqrt` `tan` `tanh` `tgamma` `trunc`\n      `y0` `y1`.\n\n      Two-input C math functions: `atan2` `copysign` `drem` `fdim`\n      `fmax` `fmin` `fmod` `frexp` `hypot` `jn` `ldexp` `modf`\n      `nextafter` `nexttoward` `pow` `remainder` `scalb` `scalbln` `yn`.\n\n      Three-input C math functions: `fma`.\n\n      See your system's manual for more information on each of these.\n\n  - title: 'I/O'\n    body: |\n\n      At this time jq has minimal support for I/O, mostly in the\n      form of control over when inputs are read.  Two builtins functions\n      are provided for this, `input` and `inputs`, that read from the\n      same sources (e.g., `stdin`, files named on the command-line) as\n      jq itself.  These two builtins, and jq's own reading actions, can\n      be interleaved with each other.  They are commonly used in combination\n      with the null input option `-n` to prevent one input from being read\n      implicitly.\n\n      Two builtins provide minimal output capabilities, `debug`, and\n      `stderr`.  (Recall that a jq program's output values are always\n      output as JSON texts on `stdout`.) The `debug` builtin can have\n      application-specific behavior, such as for executables that use\n      the libjq C API but aren't the jq executable itself.  The `stderr`\n      builtin outputs its input in raw mode to stderr with no additional\n      decoration, not even a newline.\n\n      Most jq builtins are referentially transparent, and yield constant\n      and repeatable value streams when applied to constant inputs.\n      This is not true of I/O builtins.\n\n    entries:\n      - title: \"`input`\"\n        body: |\n\n          Outputs one new input.\n\n          Note that when using `input` it is generally necessary to\n          invoke jq with the `-n` command-line option, otherwise\n          the first entity will be lost.\n\n              echo 1 2 3 4 | jq '[., input]' # [1,2] [3,4]\n\n      - title: \"`inputs`\"\n        body: |\n\n          Outputs all remaining inputs, one by one.\n\n          This is primarily useful for reductions over a program's\n          inputs.  Note that when using `inputs` it is generally necessary\n          to invoke jq with the `-n` command-line option, otherwise\n          the first entity will be lost.\n\n              echo 1 2 3 | jq -n 'reduce inputs as $i (0; . + $i)' # 6\n\n      - title: \"`debug`, `debug(msgs)`\"\n        body: |\n\n          These two filters are like `.` but have as a side-effect the\n          production of one or more messages on stderr.\n\n          The message produced by the `debug` filter has the form\n\n              [\"DEBUG:\",<input-value>]\n\n          where `<input-value>` is a compact rendition of the input\n          value.  This format may change in the future.\n\n          The `debug(msgs)` filter is defined as `(msgs | debug | empty), .`\n          thus allowing great flexibility in the content of the message,\n          while also allowing multi-line debugging statements to be created.\n\n          For example, the expression:\n\n              1 as $x | 2 | debug(\"Entering function foo with $x == \\($x)\", .) | (.+1)\n\n          would produce the value 3 but with the following two lines\n          being written to stderr:\n\n              [\"DEBUG:\",\"Entering function foo with $x == 1\"]\n              [\"DEBUG:\",2]\n\n      - title: \"`stderr`\"\n        body: |\n\n          Prints its input in raw and compact mode to stderr with no\n          additional decoration, not even a newline.\n\n      - title: \"`input_filename`\"\n        body: |\n\n          Returns the name of the file whose input is currently being\n          filtered.  Note that this will not work well unless jq is\n          running in a UTF-8 locale.\n\n      - title: \"`input_line_number`\"\n        body: |\n\n          Returns the line number of the input currently being filtered.\n\n  - title: 'Streaming'\n    body: |\n\n      With the `--stream` option jq can parse input texts in a streaming\n      fashion, allowing jq programs to start processing large JSON texts\n      immediately rather than after the parse completes.  If you have a\n      single JSON text that is 1GB in size, streaming it will allow you\n      to process it much more quickly.\n\n      However, streaming isn't easy to deal with as the jq program will\n      have `[<path>, <leaf-value>]` (and a few other forms) as inputs.\n\n      Several builtins are provided to make handling streams easier.\n\n      The examples below use the streamed form of `[\"a\",[\"b\"]]`, which is\n      `[[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]]`.\n\n      Streaming forms include `[<path>, <leaf-value>]` (to indicate any\n      scalar value, empty array, or empty object), and `[<path>]` (to\n      indicate the end of an array or object).  Future versions of jq\n      run with `--stream` and `--seq` may output additional forms such\n      as `[\"error message\"]` when an input text fails to parse.\n\n    entries:\n      - title: \"`truncate_stream(stream_expression)`\"\n        body: |\n\n          Consumes a number as input and truncates the corresponding\n          number of path elements from the left of the outputs of the\n          given streaming expression.\n\n        examples:\n          - program: 'truncate_stream([[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]])'\n            input: '1'\n            output: ['[[0],\"b\"]', '[[0]]']\n\n      - title: \"`fromstream(stream_expression)`\"\n        body: |\n\n          Outputs values corresponding to the stream expression's\n          outputs.\n\n        examples:\n          - program: 'fromstream(1|truncate_stream([[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]]))'\n            input: 'null'\n            output: ['[\"b\"]']\n\n      - title: \"`tostream`\"\n        body: |\n\n          The `tostream` builtin outputs the streamed form of its input.\n\n        examples:\n          - program: '. as $dot|fromstream($dot|tostream)|.==$dot'\n            input: '[0,[1,{\"a\":1},{\"b\":2}]]'\n            output: ['true']\n\n  - title: Assignment\n    body: |\n      Assignment works a little differently in jq than in most\n      programming languages. jq doesn't distinguish between references\n      to and copies of something - two objects or arrays are either\n      equal or not equal, without any further notion of being \"the\n      same object\" or \"not the same object\".\n\n      If an object has two fields which are arrays, `.foo` and `.bar`,\n      and you append something to `.foo`, then `.bar` will not get\n      bigger, even if you've previously set `.bar = .foo`.  If you're\n      used to programming in languages like Python, Java, Ruby,\n      JavaScript, etc. then you can think of it as though jq does a full\n      deep copy of every object before it does the assignment (for\n      performance it doesn't actually do that, but that's the general\n      idea).\n\n      This means that it's impossible to build circular values in jq\n      (such as an array whose first element is itself). This is quite\n      intentional, and ensures that anything a jq program can produce\n      can be represented in JSON.\n\n      All the assignment operators in jq have path expressions on the\n      left-hand side (LHS).  The right-hand side (RHS) provides values\n      to set to the paths named by the LHS path expressions.\n\n      Values in jq are always immutable.  Internally, assignment works\n      by using a reduction to compute new, replacement values for `.` that\n      have had all the desired assignments applied to `.`, then\n      outputting the modified value.  This might be made clear by this\n      example: `{a:{b:{c:1}}} | (.a.b|=3), .`.  This will output\n      `{\"a\":{\"b\":3}}` and `{\"a\":{\"b\":{\"c\":1}}}` because the last\n      sub-expression, `.`, sees the original value, not the modified\n      value.\n\n      Most users will want to use modification assignment operators,\n      such as `|=` or `+=`, rather than `=`.\n\n      Note that the LHS of assignment operators refers to a value in\n      `.`.  Thus `$var.foo = 1` won't work as expected (`$var.foo` is\n      not a valid or useful path expression in `.`); use `$var | .foo =\n      1` instead.\n\n      Note too that `.a,.b=0` does not set `.a` and `.b`, but\n      `(.a,.b)=0` sets both.\n\n    entries:\n      - title: \"Update-assignment: `|=`\"\n        body: |\n          This is the \"update\" operator `|=`.  It takes a filter on the\n          right-hand side and works out the new value for the property\n          of `.` being assigned to by running the old value through this\n          expression. For instance, `(.foo, .bar) |= .+1` will build an\n          object with the `foo` field set to the input's `foo` plus 1,\n          and the `bar` field set to the input's `bar` plus 1.\n\n          The left-hand side can be any general path expression; see `path()`.\n\n          Note that the left-hand side of `|=` refers to a value in `.`.\n          Thus `$var.foo |= . + 1` won't work as expected (`$var.foo` is\n          not a valid or useful path expression in `.`); use `$var |\n          .foo |= . + 1` instead.\n\n          If the right-hand side outputs no values (i.e., `empty`), then\n          the left-hand side path will be deleted, as with `del(path)`.\n\n          If the right-hand side outputs multiple values, only the first\n          one will be used (COMPATIBILITY NOTE: in jq 1.5 and earlier\n          releases, it used to be that only the last one was used).\n\n        examples:\n          - program: '(..|select(type==\"boolean\")) |= if . then 1 else 0 end'\n            input: '[true,false,[5,true,[true,[false]],false]]'\n            output: ['[1,0,[5,1,[1,[0]],0]]']\n\n      - title: \"Arithmetic update-assignment: `+=`, `-=`, `*=`, `/=`, `%=`, `//=`\"\n        body: |\n\n          jq has a few operators of the form `a op= b`, which are all\n          equivalent to `a |= . op b`. So, `+= 1` can be used to\n          increment values, being the same as `|= . + 1`.\n\n        examples:\n          - program: .foo += 1\n            input: '{\"foo\": 42}'\n            output: ['{\"foo\": 43}']\n\n      - title: \"Plain assignment: `=`\"\n        body: |\n\n          This is the plain assignment operator.  Unlike the others, the\n          input to the right-hand side (RHS) is the same as the input to\n          the left-hand side (LHS) rather than the value at the LHS\n          path, and all values output by the RHS will be used (as shown\n          below).\n\n          If the RHS of `=` produces multiple values, then for each such\n          value jq will set the paths on the left-hand side to the value\n          and then it will output the modified `.`.  For example,\n          `(.a,.b) = range(2)` outputs `{\"a\":0,\"b\":0}`, then\n          `{\"a\":1,\"b\":1}`.  The \"update\" assignment forms (see above) do\n          not do this.\n\n          This example should show the difference between `=` and `|=`:\n\n          Provide input `{\"a\": {\"b\": 10}, \"b\": 20}` to the programs\n\n              .a = .b\n\n          and\n\n              .a |= .b\n\n          The former will set the `a` field of the input to the `b`\n          field of the input, and produce the output `{\"a\": 20, \"b\": 20}`.\n          The latter will set the `a` field of the input to the `a`\n          field's `b` field, producing `{\"a\": 10, \"b\": 20}`.\n\n        examples:\n          - program: .a = .b\n            input: '{\"a\": {\"b\": 10}, \"b\": 20}'\n            output: ['{\"a\":20,\"b\":20}']\n\n          - program: .a |= .b\n            input: '{\"a\": {\"b\": 10}, \"b\": 20}'\n            output: ['{\"a\":10,\"b\":20}']\n\n          - program: (.a, .b) = range(3)\n            input: 'null'\n            output:\n              - '{\"a\":0,\"b\":0}'\n              - '{\"a\":1,\"b\":1}'\n              - '{\"a\":2,\"b\":2}'\n\n          - program: (.a, .b) |= range(3)\n            input: 'null'\n            output: ['{\"a\":0,\"b\":0}']\n\n      - title: Complex assignments\n        body: |\n          Lots more things are allowed on the left-hand side of a jq assignment\n          than in most languages. We've already seen simple field accesses on\n          the left hand side, and it's no surprise that array accesses work just\n          as well:\n\n              .posts[0].title = \"JQ Manual\"\n\n          What may come as a surprise is that the expression on the left may\n          produce multiple results, referring to different points in the input\n          document:\n\n              .posts[].comments |= . + [\"this is great\"]\n\n          That example appends the string \"this is great\" to the \"comments\"\n          array of each post in the input (where the input is an object with a\n          field \"posts\" which is an array of posts).\n\n          When jq encounters an assignment like 'a = b', it records the \"path\"\n          taken to select a part of the input document while executing a. This\n          path is then used to find which part of the input to change while\n          executing the assignment. Any filter may be used on the\n          left-hand side of an equals - whichever paths it selects from the\n          input will be where the assignment is performed.\n\n          This is a very powerful operation. Suppose we wanted to add a comment\n          to blog posts, using the same \"blog\" input above. This time, we only\n          want to comment on the posts written by \"stedolan\". We can find those\n          posts using the \"select\" function described earlier:\n\n              .posts[] | select(.author == \"stedolan\")\n\n          The paths provided by this operation point to each of the posts that\n          \"stedolan\" wrote, and we can comment on each of them in the same way\n          that we did before:\n\n              (.posts[] | select(.author == \"stedolan\") | .comments) |=\n                  . + [\"terrible.\"]\n\n  - title: Comments\n\n    body: |\n\n      You can write comments in your jq filters using `#`.\n\n      A `#` character (not part of a string) starts a comment.\n      All characters from `#` to the end of the line are ignored.\n\n      If the end of the line is preceded by an odd number of backslash\n      characters, the following line is also considered part of the\n      comment and is ignored.\n\n      For example, the following code outputs `[1,3,4,7]`\n\n          [\n            1,\n            # foo \\\n            2,\n            # bar \\\\\n            3,\n            4, # baz \\\\\\\n            5, \\\n            6,\n            7\n            # comment \\\n              comment \\\n              comment\n          ]\n\n      Backslash continuing the comment on the next line can be useful\n      when writing the \"shebang\" for a jq script:\n\n          #!/bin/sh --\n          # total - Output the sum of the given arguments (or stdin)\n          # usage: total [numbers...]\n          # \\\n          exec jq --args -MRnf -- \"$0\" \"$@\"\n\n          $ARGS.positional |\n          reduce (\n            if . == []\n              then inputs\n              else .[]\n            end |\n            . as $dot |\n            try tonumber catch false |\n            if not or isnan then\n              @json \"total: Invalid number \\($dot).\\n\" | halt_error(1)\n            end\n          ) as $n (0; . + $n)\n\n      The `exec` line is considered a comment by jq, so it is ignored.\n      But it is not ignored by `sh`, since in `sh` a backslash at the\n      end of the line does not continue the comment.\n      With this trick, when the script is invoked as `total 1 2`,\n      `/bin/sh -- /path/to/total 1 2` will be run, and `sh` will then\n      run `exec jq --args -MRnf -- /path/to/total 1 2` replacing itself\n      with a `jq` interpreter invoked with the specified options (`-M`,\n      `-R`, `-n`, `--args`), that evaluates the current file (`$0`),\n      with the arguments (`$@`) that were passed to `sh`.\n\n  - title: Modules\n    body: |\n\n      jq has a library/module system.  Modules are files whose names end\n      in `.jq`.\n\n      Modules imported by a program are searched for in a default search\n      path (see below).  The `import` and `include` directives allow the\n      importer to alter this path.\n\n      Paths in the search path are subject to various substitutions.\n\n      For paths starting with `~/`, the user's home directory is\n      substituted for `~`.\n\n      For paths starting with `$ORIGIN/`, the directory where the jq\n      executable is located is substituted for `$ORIGIN`.\n\n      For paths starting with `./` or paths that are `.`, the path of\n      the including file is substituted for `.`.  For top-level programs\n      given on the command-line, the current directory is used.\n\n      Import directives can optionally specify a search path to which\n      the default is appended.\n\n      The default search path is the search path given to the `-L`\n      command-line option, else `[\"~/.jq\", \"$ORIGIN/../lib/jq\",\n      \"$ORIGIN/../lib\"]`.\n\n      Null and empty string path elements terminate search path\n      processing.\n\n      A dependency with relative path `foo/bar` would be searched for in\n      `foo/bar.jq` and `foo/bar/bar.jq` in the given search path. This\n      is intended to allow modules to be placed in a directory along\n      with, for example, version control files, README files, and so on,\n      but also to allow for single-file modules.\n\n      Consecutive components with the same name are not allowed to avoid\n      ambiguities (e.g., `foo/foo`).\n\n      For example, with `-L$HOME/.jq` a module `foo` can be found in\n      `$HOME/.jq/foo.jq` and `$HOME/.jq/foo/foo.jq`.\n\n      If `.jq` exists in the user's home directory, and is a file (not a\n      directory), it is automatically sourced into the main program.\n\n    entries:\n      - title: \"`import RelativePathString as NAME [<metadata>];`\"\n        body: |\n\n          Imports a module found at the given path relative to a\n          directory in a search path.  A `.jq` suffix will be added to\n          the relative path string.  The module's symbols are prefixed\n          with `NAME::`.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like `homepage` and so on.  At\n          this time jq only uses the `search` key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n          The `search` key in the metadata, if present, should have a\n          string or array value (array of strings); this is the search\n          path to be prefixed to the top-level search path.\n\n      - title: \"`include RelativePathString [<metadata>];`\"\n        body: |\n\n          Imports a module found at the given path relative to a\n          directory in a search path as if it were included in place.  A\n          `.jq` suffix will be added to the relative path string.  The\n          module's symbols are imported into the caller's namespace as\n          if the module's content had been included directly.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like `homepage` and so on.  At\n          this time jq only uses the `search` key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n      - title: \"`import RelativePathString as $NAME [<metadata>];`\"\n        body: |\n\n          Imports a JSON file found at the given path relative to a\n          directory in a search path.  A `.json` suffix will be added to\n          the relative path string.  The file's data will be available\n          as `$NAME::NAME`.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like `homepage` and so on.  At\n          this time jq only uses the `search` key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n          The `search` key in the metadata, if present, should have a\n          string or array value (array of strings); this is the search\n          path to be prefixed to the top-level search path.\n\n      - title: \"`module <metadata>;`\"\n        body: |\n\n          This directive is entirely optional.  It's not required for\n          proper operation.  It serves only the purpose of providing\n          metadata that can be read with the `modulemeta` builtin.\n\n          The metadata must be a constant jq expression.  It should be\n          an object with keys like `homepage`.  At this time jq doesn't\n          use this metadata, but it is made available to users via the\n          `modulemeta` builtin.\n\n      - title: \"`modulemeta`\"\n        body: |\n\n          Takes a module name as input and outputs the module's metadata\n          as an object, with the module's imports (including metadata)\n          as an array value for the `deps` key and the module's defined\n          functions as an array value for the `defs` key.\n\n          Programs can use this to query a module's metadata, which they\n          could then use to, for example, search for, download, and\n          install missing dependencies.\n\n  - title: Colors\n    body: |\n\n      To configure alternative colors just set the `JQ_COLORS`\n      environment variable to colon-delimited list of partial terminal\n      escape sequences like `\"1;31\"`, in this order:\n\n        - color for `null`\n        - color for `false`\n        - color for `true`\n        - color for numbers\n        - color for strings\n        - color for arrays\n        - color for objects\n        - color for object keys\n\n      The default color scheme is the same as setting\n      `JQ_COLORS=\"0;90:0;39:0;39:0;39:0;32:1;39:1;39:1;34\"`.\n\n      This is not a manual for VT100/ANSI escapes.  However, each of\n      these color specifications should consist of two numbers separated\n      by a semi-colon, where the first number is one of these:\n\n        - 1 (bright)\n        - 2 (dim)\n        - 4 (underscore)\n        - 5 (blink)\n        - 7 (reverse)\n        - 8 (hidden)\n\n      and the second is one of these:\n\n        - 30 (black)\n        - 31 (red)\n        - 32 (green)\n        - 33 (yellow)\n        - 34 (blue)\n        - 35 (magenta)\n        - 36 (cyan)\n        - 37 (white)\n"
  },
  {
    "path": "docs/content/manual/v1.3/manual.yml",
    "content": "---\nheadline: jq 1.3 Manual\n\nbody: |\n\n  A jq program is a \"filter\": it takes an input, and produces an\n  output. There are a lot of builtin filters for extracting a\n  particular field of an object, or converting a number to a string,\n  or various other standard tasks.\n\n  Filters can be combined in various ways - you can pipe the output of\n  one filter into another filter, or collect the output of a filter\n  into an array.\n\n  Some filters produce multiple results, for instance there's one that\n  produces all the elements of its input array. Piping that filter\n  into a second runs the second filter for each element of the\n  array. Generally, things that would be done with loops and iteration\n  in other languages are just done by gluing filters together in jq.\n\n  It's important to remember that every filter has an input and an\n  output. Even literals like \"hello\" or 42 are filters - they take an\n  input but always produce the same literal as output. Operations that\n  combine two filters, like addition, generally feed the same input to\n  both and combine the results. So, you can implement an averaging\n  filter as `add / length` - feeding the input array both to the `add`\n  filter and the `length` filter and dividing the results.\n\n  But that's getting ahead of ourselves. :) Let's start with something\n  simpler:\n\nmanpage_intro: |\n  jq(1) -- Command-line JSON processor\n  ====================================\n\n  ## SYNOPSIS\n\n  `jq` [<options>...] <filter> [<files>...]\n\n  `jq` can transform JSON in various ways, by selecting, iterating,\n  reducing and otherwise mangling JSON documents. For instance,\n  running the command `jq 'map(.price) | add'` will take an array of\n  JSON objects as input and return the sum of their \"price\" fields.\n\n  By default, `jq` reads a stream of JSON objects (whitespace\n  separated) from `stdin`. One or more <files> may be specified, in\n  which case `jq` will read input from those instead.\n\n  The <options> are described in the [INVOKING JQ] section, they\n  mostly concern input and output formatting. The <filter> is written\n  in the jq language and specifies how to transform the input\n  document.\n\n  ## FILTERS\n\nmanpage_epilogue: |\n  ## BUGS\n\n  Presumably. Report them or discuss them at:\n\n      https://github.com/jqlang/jq/issues\n\n  ## AUTHOR\n\n  Stephen Dolan `<mu@netsoc.tcd.ie>`\n\nsections:\n  - title: Invoking jq\n    body: |\n\n      jq filters run on a stream of JSON data. The input to jq is\n      parsed as a sequence of whitespace-separated JSON values which\n      are passed through the provided filter one at a time. The\n      output(s) of the filter are written to standard output, as a\n      sequence of newline-separated JSON data.\n\n      You can affect how jq reads and writes its input and output\n      using some command-line options:\n\n      * `--null-input` / `-n`:\n\n        Don't read any input at all. Instead, the filter is run once\n        using `null` as the input. This is useful when using jq as a\n        simple calculator or to construct JSON data from scratch.\n\n      * `--raw-input` / `-R`:\n\n        Don't parse the input as JSON. Instead, each line of text is\n        passed to the filter as a string. If combined with `--slurp`,\n        then the entire input is passed to the filter as a single long\n        string.\n\n      * `--slurp` / `-s`:\n\n        Instead of running the filter for each JSON object in the\n        input, read the entire input stream into a large array and run\n        the filter just once.\n\n      * `--compact-output` / `-c`:\n\n        By default, jq pretty-prints JSON output. Using this option\n        will result in more compact output by instead putting each\n        JSON object on a single line.\n\n      * `--raw-output` / `-r`:\n\n        With this option, if the filter's result is a string then it\n        will be written directly to standard output rather than being\n        formatted as a JSON string with quotes. This can be useful for\n        making jq filters talk to non-JSON-based systems.\n\n      * `--ascii-output` / `-a`:\n\n        jq usually outputs non-ASCII Unicode codepoints as UTF-8, even\n        if the input specified them as escape sequences (like\n        \"\\u03bc\"). Using this option, you can force jq to produce pure\n        ASCII output with every non-ASCII character replaced with the\n        equivalent escape sequence.\n\n      * `--color-output` / `-C` and `--monochrome-output` / `-M`:\n\n        By default, jq outputs colored JSON if writing to a\n        terminal. You can force it to produce color even if writing to\n        a pipe or a file using `-C`, and disable color with `-M`.\n\n      * `--arg name value`:\n\n        This option passes a value to the jq program as a predefined\n        variable. If you run jq with `--arg foo bar`, then `$foo` is\n        available in the program and has the value `\"bar\"`.\n\n  - title: Basic filters\n    entries:\n      - title: \"`.`\"\n        body: |\n\n          The absolute simplest (and least interesting) filter\n          is `.`. This is a filter that takes its input and\n          produces it unchanged as output.\n\n          Since jq by default pretty-prints all output, this trivial\n          program can be a useful way of formatting JSON output from,\n          say, `curl`.\n\n        examples:\n          - program: '.'\n            input: '\"Hello, world!\"'\n            output: ['\"Hello, world!\"']\n\n      - title: \"`.foo`\"\n        body: |\n\n          The simplest *useful* filter is .foo. When given a\n          JSON object (aka dictionary or hash) as input, it produces\n          the value at the key \"foo\", or null if there's none present.\n\n        examples:\n          - program: '.foo'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n          - program: '.foo'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n\n      - title: \"`.[foo]`, `.[2]`, `.[10:15]`\"\n        body: |\n\n          You can also look up fields of an object using syntax like\n          `.[\"foo\"]` (`.foo` above is a shorthand version of this). This\n          one works for arrays as well, if the key is an integer. Arrays\n          are zero-based, so `.[2]` returns the third element of the array.\n\n          The `.[10:15]` syntax can be used to return a subarray of an\n          array. The array returned by `.[10:15]` will be of length 5,\n          containing the elements from index 10 (inclusive) to index\n          15 (exclusive). Either index may be negative (in which case\n          it counts backwards from the end of the array), or omitted\n          (in which case it refers to the start or end of the array).\n\n        examples:\n          - program: '.[0]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['{\"name\":\"JSON\", \"good\":true}']\n\n          - program: '.[2]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['null']\n\n          - program: '.[2:4]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"c\", \"d\"]']\n\n          - program: '.[:3]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"a\", \"b\", \"c\"]']\n\n          - program: '.[-2:]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"d\", \"e\"]']\n\n      - title: \"`.[]`\"\n        body: |\n\n          If you use the `.[foo]` syntax, but omit the index\n          entirely, it will return *all* of the elements of an\n          array. Running `.[]` with the input `[1,2,3]` will produce the\n          numbers as three separate results, rather than as a single\n          array.\n\n          You can also use this on an object, and it will return all\n          the values of the object.\n\n        examples:\n          - program: '.[]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output:\n              - '{\"name\":\"JSON\", \"good\":true}'\n              - '{\"name\":\"XML\", \"good\":false}'\n\n          - program: '.[]'\n            input: '[]'\n            output: []\n\n          - program: '.[]'\n            input: '{\"a\": 1, \"b\": 1}'\n            output: ['1', '1']\n\n      - title: \"`,`\"\n        body: |\n\n          If two filters are separated by a comma, then the\n          input will be fed into both and there will be multiple\n          outputs: first, all of the outputs produced by the left\n          expression, and then all of the outputs produced by the\n          right. For instance, filter `.foo, .bar`, produces\n          both the \"foo\" fields and \"bar\" fields as separate outputs.\n\n        examples:\n          - program: '.foo, .bar'\n            input: '{\"foo\": 42, \"bar\": \"something else\", \"baz\": true}'\n            output: ['42', '\"something else\"']\n\n          - program: \".user, .projects[]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['\"stedolan\"', '\"jq\"', '\"wikiflow\"']\n\n          - program: '.[4,2]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['\"e\"', '\"c\"']\n\n      - title: \"`|`\"\n        body: |\n          The | operator combines two filters by feeding the output(s) of\n          the one on the left into the input of the one on the right. It's\n          pretty much the same as the Unix shell's pipe, if you're used to\n          that.\n\n          If the one on the left produces multiple results, the one on\n          the right will be run for each of those results. So, the\n          expression `.[] | .foo` retrieves the \"foo\" field of each\n          element of the input array.\n\n        examples:\n          - program: '.[] | .name'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['\"JSON\"', '\"XML\"']\n\n  - title: Types and Values\n    body: |\n\n      jq supports the same set of datatypes as JSON - numbers,\n      strings, booleans, arrays, objects (which in JSON-speak are\n      hashes with only string keys), and \"null\".\n\n      Booleans, null, strings and numbers are written the same way as\n      in JSON. Just like everything else in jq, these simple\n      values take an input and produce an output - `42` is a valid jq\n      expression that takes an input, ignores it, and returns 42\n      instead.\n\n    entries:\n      - title: \"Array construction: `[]`\"\n        body: |\n\n          As in JSON, `[]` is used to construct arrays, as in\n          `[1,2,3]`. The elements of the arrays can be any jq\n          expression. All of the results produced by all of the\n          expressions are collected into one big array. You can use it\n          to construct an array out of a known quantity of values (as\n          in `[.foo, .bar, .baz]`) or to \"collect\" all the results of a\n          filter into an array (as in `[.items[].name]`)\n\n          Once you understand the \",\" operator, you can look at jq's array\n          syntax in a different light: the expression `[1,2,3]` is not using a\n          built-in syntax for comma-separated arrays, but is instead applying\n          the `[]` operator (collect results) to the expression 1,2,3 (which\n          produces three different results).\n\n          If you have a filter `X` that produces four results,\n          then the expression `[X]` will produce a single result, an\n          array of four elements.\n\n        examples:\n          - program: \"[.user, .projects[]]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['[\"stedolan\", \"jq\", \"wikiflow\"]']\n      - title: \"Objects: `{}`\"\n        body: |\n\n          Like JSON, `{}` is for constructing objects (aka\n          dictionaries or hashes), as in: `{\"a\": 42, \"b\": 17}`.\n\n          If the keys are \"sensible\" (all alphabetic characters), then\n          the quotes can be left off. The value can be any expression\n          (although you may need to wrap it in parentheses if it's a\n          complicated one), which gets applied to the {} expression's\n          input (remember, all filters have an input and an\n          output).\n\n              {foo: .bar}\n\n          will produce the JSON object `{\"foo\": 42}` if given the JSON\n          object `{\"bar\":42, \"baz\":43}`. You can use this to select\n          particular fields of an object: if the input is an object\n          with \"user\", \"title\", \"id\", and \"content\" fields and you\n          just want \"user\" and \"title\", you can write\n\n              {user: .user, title: .title}\n\n          Because that's so common, there's a shortcut syntax: `{user, title}`.\n\n          If one of the expressions produces multiple results,\n          multiple dictionaries will be produced. If the input's\n\n              {\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n\n          then the expression\n\n              {user, title: .titles[]}\n\n          will produce two outputs:\n\n              {\"user\":\"stedolan\", \"title\": \"JQ Primer\"}\n              {\"user\":\"stedolan\", \"title\": \"More JQ\"}\n\n          Putting parentheses around the key means it will be evaluated as an\n          expression. With the same input as above,\n\n              {(.user): .titles}\n\n          produces\n\n              {\"stedolan\": [\"JQ Primer\", \"More JQ\"]}\n\n        examples:\n          - program: '{user, title: .titles[]}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output:\n              - '{\"user\":\"stedolan\", \"title\": \"JQ Primer\"}'\n              - '{\"user\":\"stedolan\", \"title\": \"More JQ\"}'\n          - program: '{(.user): .titles}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output: ['{\"stedolan\": [\"JQ Primer\", \"More JQ\"]}']\n\n  - title: Builtin operators and functions\n    body: |\n\n      Some jq operators (for instance, `+`) do different things\n      depending on the type of their arguments (arrays, numbers,\n      etc.). However, jq never does implicit type conversions. If you\n      try to add a string to an object you'll get an error message and\n      no result.\n\n    entries:\n      - title: \"Addition: `+`\"\n        body: |\n\n          The operator `+` takes two filters, applies them both\n          to the same input, and adds the results together. What\n          \"adding\" means depends on the types involved:\n\n          - **Numbers** are added by normal arithmetic.\n\n          - **Arrays** are added by being concatenated into a larger array.\n\n          - **Strings** are added by being joined into a larger string.\n\n          - **Objects** are added by merging, that is, inserting all\n              the key-value pairs from both objects into a single\n              combined object. If both objects contain a value for the\n              same key, the object on the right of the `+` wins.\n\n          `null` can be added to any value, and returns the other\n          value unchanged.\n\n        examples:\n          - program: '.a + 1'\n            input: '{\"a\": 7}'\n            output: ['8']\n          - program: '.a + .b'\n            input: '{\"a\": [1,2], \"b\": [3,4]}'\n            output: ['[1,2,3,4]']\n          - program: '.a + null'\n            input: '{\"a\": 1}'\n            output: ['1']\n          - program: '.a + 1'\n            input: '{}'\n            output: ['1']\n          - program: '{a: 1} + {b: 2} + {c: 3} + {a: 42}'\n            input: 'null'\n            output: ['{\"a\": 42, \"b\": 2, \"c\": 3}']\n\n      - title: \"Subtraction: `-`\"\n        body: |\n\n          As well as normal arithmetic subtraction on numbers, the `-`\n          operator can be used on arrays to remove all occurrences of\n          the second array's elements from the first array.\n\n        examples:\n          - program: '4 - .a'\n            input: '{\"a\":3}'\n            output: ['1']\n          - program: . - [\"xml\", \"yaml\"]\n            input: '[\"xml\", \"yaml\", \"json\"]'\n            output: ['[\"json\"]']\n\n      - title: \"Multiplication, division: `*` and `/`\"\n        body: |\n\n          These operators only work on numbers, and do the expected.\n\n        examples:\n          - program: '10 / . * 3'\n            input: '5'\n            output: ['6']\n\n      - title: '`length`'\n        body: |\n\n          The builtin function `length` gets the length of various\n          different types of value:\n\n          - The length of a **string** is the number of Unicode\n            codepoints it contains (which will be the same as its\n            JSON-encoded length in bytes if it's pure ASCII).\n\n          - The length of an **array** is the number of elements.\n\n          - The length of an **object** is the number of key-value pairs.\n\n          - The length of **null** is zero.\n\n        examples:\n          - program: '.[] | length'\n            input: '[[1,2], \"string\", {\"a\":2}, null]'\n            output: ['2', '6', '1', '0']\n\n      - title: '`keys`'\n        body: |\n\n          The builtin function `keys`, when given an object, returns\n          its keys in an array.\n\n          The keys are sorted \"alphabetically\", by unicode codepoint\n          order. This is not an order that makes particular sense in\n          any particular language, but you can count on it being the\n          same for any two objects with the same set of keys,\n          regardless of locale settings.\n\n          When `keys` is given an array, it returns the valid indices\n          for that array: the integers from 0 to length-1.\n\n        examples:\n          - program: 'keys'\n            input: '{\"abc\": 1, \"abcd\": 2, \"Foo\": 3}'\n            output: ['[\"Foo\", \"abc\", \"abcd\"]']\n          - program: 'keys'\n            input: '[42,3,35]'\n            output: ['[0,1,2]']\n\n      - title: '`has`'\n        body: |\n\n          The builtin function `has` returns whether the input object\n          has the given key, or the input array has an element at the\n          given index.\n\n          `has($key)` has the same effect as checking whether `$key`\n          is a member of the array returned by `keys`, although `has`\n          will be faster.\n\n        examples:\n          - program: 'map(has(\"foo\"))'\n            input: '[{\"foo\": 42}, {}]'\n            output: ['[true, false]']\n          - program: 'map(has(2))'\n            input: '[[0,1], [\"a\",\"b\",\"c\"]]'\n            output: ['[false, true]']\n\n      - title: \"`to_entries`, `from_entries`, `with_entries(f)`\"\n        body: |\n\n          These functions convert between an object and an array of\n          key-value pairs. If `to_entries` is passed an object, then\n          for each `k: v` entry in the input, the output array\n          includes `{\"key\": k, \"value\": v}`.\n\n          `from_entries` does the opposite conversion, and\n          `with_entries(f)` is a shorthand for `to_entries | map(f) |\n          from_entries`, useful for doing some operation to all keys\n          and values of an object.\n\n        examples:\n          - program: 'to_entries'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]']\n          - program: 'from_entries'\n            input: '[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]'\n            output: ['{\"a\": 1, \"b\": 2}']\n          - program: 'with_entries(.key |= \"KEY_\" + .)'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['{\"KEY_a\": 1, \"KEY_b\": 2}']\n\n\n      - title: '`select`'\n        body: |\n\n          The function `select(foo)` produces its input unchanged if\n          `foo` returns true for that input, and produces no output\n          otherwise.\n\n          It's useful for filtering lists: '`[1,2,3] | map(select(. >= 2))`'\n          will give you `[3]`.\n\n        examples:\n          - program: 'map(select(. >= 2))'\n            input: '[1,5,3,0,7]'\n            output: ['[5,3,7]']\n\n      - title: '`empty`'\n        body: |\n\n          `empty` returns no results. None at all. Not even `null`.\n\n          It's useful on occasion. You'll know if you need it :)\n\n        examples:\n          - program: '1, empty, 2'\n            input: 'null'\n            output: ['1', '2']\n          - program: '[1,2,empty,3]'\n            input: 'null'\n            output: ['[1,2,3]']\n\n      - title: '`map(f)`'\n        body: |\n\n          For any filter `f`, `map(f)` will run that filter for each\n          element of the input array, and produce the outputs a new\n          array. `map(.+1)` will increment each element of an array of numbers.\n\n          `map(f)` is equivalent to `[.[] | f]`. In fact, this is how\n          it's defined.\n\n        examples:\n          - program: 'map(.+1)'\n            input: '[1,2,3]'\n            output: ['[2,3,4]']\n\n      - title: '`add`'\n        body: |\n\n          The filter `add` takes as input an array, and produces as\n          output the elements of the array added together. This might\n          mean summed, concatenated or merged depending on the types\n          of the elements of the input array - the rules are the same\n          as those for the `+` operator (described above).\n\n          If the input is an empty array, `add` returns `null`.\n\n        examples:\n          - program: add\n            input: '[\"a\",\"b\",\"c\"]'\n            output: ['\"abc\"']\n          - program: add\n            input: '[1, 2, 3]'\n            output: ['6']\n          - program: add\n            input: '[]'\n            output: [\"null\"]\n\n      - title: '`range`'\n        body: |\n\n          The `range` function produces a range of numbers. `range(4;10)`\n          produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers\n          are produced as separate outputs. Use `[range(4;10)]` to get a range as\n          an array.\n\n        examples:\n          - program: 'range(2;4)'\n            input: 'null'\n            output: ['2', '3']\n          - program: '[range(2;4)]'\n            input: 'null'\n            output: ['[2,3]']\n\n      - title: '`tonumber`'\n        body: |\n\n          The `tonumber` function parses its input as a number. It\n          will convert correctly-formatted strings to their numeric\n          equivalent, leave numbers alone, and give an error on all other input.\n\n        examples:\n          - program: '.[] | tonumber'\n            input: '[1, \"1\"]'\n            output: ['1', '1']\n\n      - title: '`tostring`'\n        body: |\n\n          The `tostring` function prints its input as a\n          string. Strings are left unchanged, and all other values are\n          JSON-encoded.\n\n        examples:\n          - program: '.[] | tostring'\n            input: '[1, \"1\", [1]]'\n            output: ['\"1\"', '\"1\"', '\"[1]\"']\n\n      - title: '`type`'\n        body: |\n\n          The `type` function returns the type of its argument as a\n          string, which is one of null, boolean, number, string, array\n          or object.\n\n        examples:\n          - program: 'map(type)'\n            input: '[0, false, [], {}, null, \"hello\"]'\n            output: ['[\"number\", \"boolean\", \"array\", \"object\", \"null\", \"string\"]']\n\n      - title: '`sort`, `sort_by`'\n        body: |\n\n          The `sort` functions sorts its input, which must be an\n          array. Values are sorted in the following order:\n\n          * `null`\n          * `false`\n          * `true`\n          * numbers\n          * strings, in alphabetical order (by unicode codepoint value)\n          * arrays, in lexical order\n          * objects\n\n          The ordering for objects is a little complex: first they're\n          compared by comparing their sets of keys (as arrays in\n          sorted order), and if their keys are equal then the values\n          are compared key by key.\n\n          `sort_by` may be used to sort by a particular field of an\n          object, or by applying any jq filter. `sort_by(foo)`\n          compares two elements by comparing the result of `foo` on\n          each element.\n\n        examples:\n          - program: 'sort'\n            input: '[8,3,null,6]'\n            output: ['[null,3,6,8]']\n          - program: 'sort_by(.foo)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":100}, {\"foo\":2, \"bar\":1}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":100}, {\"foo\":4, \"bar\":10}]']\n\n      - title: '`group_by`'\n        body: |\n\n          `group_by(.foo)` takes as input an array, groups the\n          elements having the same `.foo` field into separate arrays,\n          and produces all of these arrays as elements of a larger\n          array, sorted by the value of the `.foo` field.\n\n          Any jq expression, not just a field access, may be used in\n          place of `.foo`. The sorting order is the same as described\n          in the `sort` function above.\n\n        examples:\n          - program: 'group_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":10}, {\"foo\":3, \"bar\":100}, {\"foo\":1, \"bar\":1}]'\n            output: ['[[{\"foo\":1, \"bar\":10}, {\"foo\":1, \"bar\":1}], [{\"foo\":3, \"bar\":100}]]']\n\n      - title: '`min`, `max`, `min_by`, `max_by`'\n        body: |\n\n          Find the minimum or maximum element of the input array. The\n          `_by` versions allow you to specify a particular field or\n          property to examine, e.g. `min_by(.foo)` finds the object\n          with the smallest `foo` field.\n\n        examples:\n          - program: 'min'\n            input: '[5,4,2,7]'\n            output: ['2']\n          - program: 'max_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":14}, {\"foo\":2, \"bar\":3}]'\n            output: ['{\"foo\":2, \"bar\":3}']\n\n      - title: '`unique`'\n        body: |\n\n          The `unique` function takes as input an array and produces\n          an array of the same elements, in sorted order, with\n          duplicates removed.\n\n        examples:\n          - program: 'unique'\n            input: '[1,2,5,3,5,3,1,3]'\n            output: ['[1,2,3,5]']\n\n      - title: '`reverse`'\n        body: |\n\n          This function reverses an array.\n\n        examples:\n          - program: 'reverse'\n            input: '[1,2,3,4]'\n            output: ['[4,3,2,1]']\n\n      - title: '`contains`'\n        body: |\n\n          The filter `contains(b)` will produce true if b is\n          completely contained within the input. A string B is\n          contained in a string A if B is a substring of A. An array B\n          is contained in an array A is all elements in B are\n          contained in any element in A. An object B is contained in\n          object A if all of the values in B are contained in the\n          value in A with the same key. All other types are assumed to\n          be contained in each other if they are equal.\n\n        examples:\n          - program: 'contains(\"bar\")'\n            input: '\"foobar\"'\n            output: ['true']\n          - program: 'contains([\"baz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['true']\n          - program: 'contains([\"bazzzzz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['false']\n          - program: 'contains({foo: 12, bar: [{barp: 12}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['true']\n          - program: 'contains({foo: 12, bar: [{barp: 15}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['false']\n\n      - title: '`recurse`'\n        body: |\n\n          The `recurse` function allows you to search through a\n          recursive structure, and extract interesting data from all\n          levels. Suppose your input represents a filesystem:\n\n              {\"name\": \"/\", \"children\": [\n                {\"name\": \"/bin\", \"children\": [\n                  {\"name\": \"/bin/ls\", \"children\": []},\n                  {\"name\": \"/bin/sh\", \"children\": []}]},\n                {\"name\": \"/home\", \"children\": [\n                  {\"name\": \"/home/stephen\", \"children\": [\n                    {\"name\": \"/home/stephen/jq\", \"children\": []}]}]}]}\n\n          Now suppose you want to extract all of the filenames\n          present. You need to retrieve `.name`, `.children[].name`,\n          `.children[].children[].name`, and so on. You can do this\n          with:\n\n              recurse(.children[]) | .name\n\n        examples:\n          - program: 'recurse(.foo[])'\n            input: '{\"foo\":[{\"foo\": []}, {\"foo\":[{\"foo\":[]}]}]}'\n            output:\n              - '{\"foo\":[{\"foo\":[]},{\"foo\":[{\"foo\":[]}]}]}'\n              - '{\"foo\":[]}'\n              - '{\"foo\":[{\"foo\":[]}]}'\n              - '{\"foo\":[]}'\n\n\n      - title: \"String interpolation: `\\\\(exp)`\"\n        body: |\n\n          Inside a string, you can put an expression inside parens\n          after a backslash. Whatever the expression returns will be\n          interpolated into the string.\n\n        examples:\n          - program: '\"The input was \\(.), which is one less than \\(.+1)\"'\n            input: '42'\n            output: ['\"The input was 42, which is one less than 43\"']\n\n      - title: \"Format strings and escaping\"\n        body: |\n\n          The `@foo` syntax is used to format and escape strings,\n          which is useful for building URLs, documents in a language\n          like HTML or XML, and so forth. `@foo` can be used as a\n          filter on its own, the possible escapings are:\n\n          * `@text`:\n\n            Calls `tostring`, see that function for details.\n\n          * `@json`:\n\n            Serialises the input as JSON.\n\n          * `@html`:\n\n            Applies HTML/XML escaping, by mapping the characters\n            `<>&'\"` to their entity equivalents `&lt;`, `&gt;`,\n            `&amp;`, `&apos;`, `&quot;`.\n\n          * `@uri`:\n\n            Applies percent-encoding, by mapping all reserved URI\n            characters to a `%xx` sequence.\n\n          * `@csv`:\n\n            The input must be an array, and it is rendered as CSV\n            with double quotes for strings, and quotes escaped by\n            repetition.\n\n          * `@sh`:\n\n            The input is escaped suitable for use in a command-line\n            for a POSIX shell. If the input is an array, the output\n            will be a series of space-separated strings.\n\n          * `@base64`:\n\n            The input is converted to base64 as specified by RFC 4648.\n\n          This syntax can be combined with string interpolation in a\n          useful way. You can follow a `@foo` token with a string\n          literal. The contents of the string literal will *not* be\n          escaped. However, all interpolations made inside that string\n          literal will be escaped. For instance,\n\n              @uri \"https://www.google.com/search?q=\\(.search)\"\n\n          will produce the following output for the input\n          `{\"search\":\"jq!\"}`:\n\n              https://www.google.com/search?q=jq%21\n\n          Note that the slashes, question mark, etc. in the URL are\n          not escaped, as they were part of the string literal.\n\n        examples:\n          - program: '@html'\n            input: '\"This works if x < y\"'\n            output: ['\"This works if x &lt; y\"']\n\n          - program: '@sh \"echo \\(.)\"'\n            input: \"\\\"O'Hara's Ale\\\"\"\n            output: [\"\\\"echo 'O'\\\\\\\\''Hara'\\\\\\\\''s Ale'\\\"\"]\n\n  - title: Conditionals and Comparisons\n    entries:\n      - title: '`==`, `!=`'\n        body: |\n\n          The expression 'a == b' will produce 'true' if the result of a and b\n          are equal (that is, if they represent equivalent JSON documents) and\n          'false' otherwise. In particular, strings are never considered equal\n          to numbers. If you're coming from JavaScript, jq's == is like\n          JavaScript's === - considering values equal only when they have the\n          same type as well as the same value.\n\n          != is \"not equal\", and 'a != b' returns the opposite value of 'a == b'\n\n        examples:\n          - program: '.[] == 1'\n            input: '[1, 1.0, \"1\", \"banana\"]'\n            output: ['true', 'true', 'false', 'false']\n\n      - title: if-then-else-end\n        body: |\n\n          `if A then B else C end` will act the same as `B` if `A`\n          produces a value other than false or null, but act the same\n          as `C` otherwise.\n\n          Checking for false or null is a simpler notion of\n          \"truthiness\" than is found in JavaScript or Python, but it\n          means that you'll sometimes have to be more explicit about\n          the condition you want: you can't test whether, e.g. a\n          string is empty using `if .name then A else B end`, you'll\n          need something more like `if (.name | length) > 0 then A else\n          B end` instead.\n\n          If the condition `A` produces multiple results, then `B` is evaluated\n          once for each result that is not false or null, and `C` is evaluated\n          once for each false or null.\n\n          More cases can be added to an if using `elif A then B` syntax.\n\n        examples:\n          - program: |-\n              if . == 0 then\n                \"zero\"\n              elif . == 1 then\n                \"one\"\n              else\n                \"many\"\n              end\n            input: '2'\n            output: ['\"many\"']\n\n      - title: \"`>`, `>=`, `<=`, `<`\"\n        body: |\n\n          The comparison operators `>`, `>=`, `<=`, `<` return whether\n          their left argument is greater than, greater than or equal\n          to, less than or equal to or less than their right argument\n          (respectively).\n\n          The ordering is the same as that described for `sort`, above.\n\n        examples:\n          - program: '. < 5'\n            input: '2'\n            output: ['true']\n\n      - title: \"`and`, `or`, `not`\"\n        body: |\n\n          jq supports the normal Boolean operators `and`, `or`, `not`.\n          They have the same standard of truth as if expressions -\n          `false` and `null` are considered \"false values\", and\n          anything else is a \"true value\".\n\n          If an operand of one of these operators produces multiple\n          results, the operator itself will produce a result for each input.\n\n          `not` is in fact a builtin function rather than an operator,\n          so it is called as a filter to which things can be piped\n          rather than with special syntax, as in `.foo and .bar |\n          not`.\n\n          These three only produce the values `true` and `false`, and\n          so are only useful for genuine Boolean operations, rather\n          than the common Perl/Python/Ruby idiom of\n          \"value_that_may_be_null or default\". If you want to use this\n          form of \"or\", picking between two values rather than\n          evaluating a condition, see the `//` operator below.\n\n        examples:\n          - program: '42 and \"a string\"'\n            input: 'null'\n            output: ['true']\n          - program: '(true, false) or false'\n            input: 'null'\n            output: ['true', 'false']\n          - program: '(true, true) and (true, false)'\n            input: 'null'\n            output: ['true', 'false', 'true', 'false']\n          - program: '[true, false | not]'\n            input: 'null'\n            output: ['[false, true]']\n\n      - title: \"Alternative operator: `//`\"\n        body: |\n\n          A filter of the form `a // b` produces the same\n          results as `a`, if `a` produces results other than `false`\n          and `null`. Otherwise, `a // b` produces the same results as `b`.\n\n          This is useful for providing defaults: `.foo // 1` will\n          evaluate to `1` if there's no `.foo` element in the\n          input. It's similar to how `or` is sometimes used in Python\n          (jq's `or` operator is reserved for strictly Boolean\n          operations).\n\n        examples:\n          - program: '.foo // 42'\n            input: '{\"foo\": 19}'\n            output: ['19']\n          - program: '.foo // 42'\n            input: '{}'\n            output: ['42']\n\n  - title: Advanced features\n    body: |\n      Variables are an absolute necessity in most programming languages, but\n      they're relegated to an \"advanced feature\" in jq.\n\n      In most languages, variables are the only means of passing around\n      data. If you calculate a value, and you want to use it more than once,\n      you'll need to store it in a variable. To pass a value to another part\n      of the program, you'll need that part of the program to define a\n      variable (as a function parameter, object member, or whatever) in\n      which to place the data.\n\n      It is also possible to define functions in jq, although this is\n      is a feature whose biggest use is defining jq's standard library\n      (many jq functions such as `map` and `select` are in fact written\n      in jq).\n\n      Finally, jq has a `reduce` operation, which is very powerful but a\n      bit tricky. Again, it's mostly used internally, to define some\n      useful bits of jq's standard library.\n\n    entries:\n      - title: Variables\n        body: |\n\n          In jq, all filters have an input and an output, so manual\n          plumbing is not necessary to pass a value from one part of a program\n          to the next. Many expressions, for instance `a + b`, pass their input\n          to two distinct subexpressions (here `a` and `b` are both passed the\n          same input), so variables aren't usually necessary in order to use a\n          value twice.\n\n          For instance, calculating the average value of an array of numbers\n          requires a few variables in most languages - at least one to hold the\n          array, perhaps one for each element or for a loop counter. In jq, it's\n          simply `add / length` - the `add` expression is given the array and\n          produces its sum, and the `length` expression is given the array and\n          produces its length.\n\n          So, there's generally a cleaner way to solve most problems in jq than\n          defining variables. Still, sometimes they do make things easier, so jq\n          lets you define variables using `expression as $variable`. All\n          variable names start with `$`. Here's a slightly uglier version of the\n          array-averaging example:\n\n              length as $array_length | add / $array_length\n\n          We'll need a more complicated problem to find a situation where using\n          variables actually makes our lives easier.\n\n\n          Suppose we have an array of blog posts, with \"author\" and \"title\"\n          fields, and another object which is used to map author usernames to\n          real names. Our input looks like:\n\n              {\"posts\": [{\"title\": \"First post\", \"author\": \"anon\"},\n                         {\"title\": \"A well-written article\", \"author\": \"person1\"}],\n               \"realnames\": {\"anon\": \"Anonymous Coward\",\n                             \"person1\": \"Person McPherson\"}}\n\n          We want to produce the posts with the author field containing a real\n          name, as in:\n\n              {\"title\": \"First post\", \"author\": \"Anonymous Coward\"}\n              {\"title\": \"A well-written article\", \"author\": \"Person McPherson\"}\n\n          We use a variable, $names, to store the realnames object, so that we\n          can refer to it later when looking up author usernames:\n\n              .realnames as $names | .posts[] | {title, author: $names[.author]}\n\n          The expression `exp as $x | ...` means: for each value of expression\n          `exp`, run the rest of the pipeline with the entire original input, and\n          with `$x` set to that value.  Thus `as` functions as something of a\n          foreach loop.\n\n          Variables are scoped over the rest of the expression that defines\n          them, so\n\n              .realnames as $names | (.posts[] | {title, author: $names[.author]})\n\n          will work, but\n\n              (.realnames as $names | .posts[]) | {title, author: $names[.author]}\n\n          won't.\n\n        examples:\n          - program: '.bar as $x | .foo | . + $x'\n            input: '{\"foo\":10, \"bar\":200}'\n            output: ['210']\n\n      - title: 'Defining Functions'\n        body: |\n\n          You can give a filter a name using \"def\" syntax:\n\n              def increment: . + 1;\n\n          From then on, `increment` is usable as a filter just like a\n          builtin function (in fact, this is how some of the builtins\n          are defined). A function may take arguments:\n\n              def map(f): [.[] | f];\n\n          Arguments are passed as filters, not as values. The\n          same argument may be referenced multiple times with\n          different inputs (here `f` is run for each element of the\n          input array). Arguments to a function work more like\n          callbacks than like value arguments.\n\n          If you want the value-argument behaviour for defining simple\n          functions, you can just use a variable:\n\n              def addvalue(f): f as $value | map(. + $value);\n\n          With that definition, `addvalue(.foo)` will add the current\n          input's `.foo` field to each element of the array.\n\n        examples:\n          - program: 'def addvalue(f): . + [f]; map(addvalue(.[0]))'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1], [10,20,10]]']\n          - program: 'def addvalue(f): f as $x | map(. + $x); addvalue(.[0])'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1,2], [10,20,1,2]]']\n\n      - title: \"`reduce`\"\n        body: |\n\n          The `reduce` syntax allows you to combine all of the results of\n          an expression by accumulating them into a single answer.\n          The form is `reduce EXP as $var (INIT; UPDATE)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              reduce .[] as $item (0; . + $item)\n\n          For each result that `.[]` produces, `. + $item` is run to\n          accumulate a running total, starting from 0 as the input value.\n          In this example, `.[]` produces the results `1`, `2`, and `3`,\n          so the effect is similar to running something like this:\n\n              0 | 1 as $item | . + $item |\n                  2 as $item | . + $item |\n                  3 as $item | . + $item\n\n        examples:\n          - program: 'reduce .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['15']\n\n  - title: Assignment\n    body: |\n\n      Assignment works a little differently in jq than in most\n      programming languages. jq doesn't distinguish between references\n      to and copies of something - two objects or arrays are either\n      equal or not equal, without any further notion of being \"the\n      same object\" or \"not the same object\".\n\n      If an object has two fields which are arrays, `.foo` and `.bar`,\n      and you append something to `.foo`, then `.bar` will not get\n      bigger. Even if you've just set `.bar = .foo`. If you're used to\n      programming in languages like Python, Java, Ruby, JavaScript,\n      etc. then you can think of it as though jq does a full deep copy\n      of every object before it does the assignment (for performance,\n      it doesn't actually do that, but that's the general idea).\n\n    entries:\n      - title: \"`=`\"\n        body: |\n\n          The filter `.foo = 1` will take as input an object\n          and produce as output an object with the \"foo\" field set to\n          1. There is no notion of \"modifying\" or \"changing\" something\n          in jq - all jq values are immutable. For instance,\n\n           .foo = .bar | .foo.baz = 1\n\n          will not have the side-effect of setting .bar.baz to be set\n          to 1, as the similar-looking program in JavaScript, Python,\n          Ruby or other languages would. Unlike these languages (but\n          like Haskell and some other functional languages), there is\n          no notion of two arrays or objects being \"the same array\" or\n          \"the same object\". They can be equal, or not equal, but if\n          we change one of them in no circumstances will the other\n          change behind our backs.\n\n          This means that it's impossible to build circular values in\n          jq (such as an array whose first element is itself). This is\n          quite intentional, and ensures that anything a jq program\n          can produce can be represented in JSON.\n\n      - title: \"`|=`\"\n        body: |\n          As well as the assignment operator '=', jq provides the \"update\"\n          operator '|=', which takes a filter on the right-hand side and\n          works out the new value for the property being assigned to by running\n          the old value through this expression. For instance, .foo |= .+1 will\n          build an object with the \"foo\" field set to the input's \"foo\" plus 1.\n\n          This example should show the difference between '=' and '|=':\n\n          Provide input '{\"a\": {\"b\": 10}, \"b\": 20}' to the programs:\n\n          .a = .b\n          .a |= .b\n\n          The former will set the \"a\" field of the input to the \"b\" field of the\n          input, and produce the output {\"a\": 20}. The latter will set the \"a\"\n          field of the input to the \"a\" field's \"b\" field, producing {\"a\": 10}.\n\n      - title: \"`+=`, `-=`, `*=`, `/=`, `//=`\"\n        body: |\n\n          jq has a few operators of the form `a op= b`, which are all\n          equivalent to `a |= . op b`. So, `+= 1` can be used to increment values.\n\n        examples:\n          - program: .foo += 1\n            input: '{\"foo\": 42}'\n            output: ['{\"foo\": 43}']\n\n      - title: Complex assignments\n        body: |\n          Lots more things are allowed on the left-hand side of a jq assignment\n          than in most languages. We've already seen simple field accesses on\n          the left hand side, and it's no surprise that array accesses work just\n          as well:\n\n              .posts[0].title = \"JQ Manual\"\n\n          What may come as a surprise is that the expression on the left may\n          produce multiple results, referring to different points in the input\n          document:\n\n              .posts[].comments |= . + [\"this is great\"]\n\n          That example appends the string \"this is great\" to the \"comments\"\n          array of each post in the input (where the input is an object with a\n          field \"posts\" which is an array of posts).\n\n          When jq encounters an assignment like 'a = b', it records the \"path\"\n          taken to select a part of the input document while executing a. This\n          path is then used to find which part of the input to change while\n          executing the assignment. Any filter may be used on the\n          left-hand side of an equals - whichever paths it selects from the\n          input will be where the assignment is performed.\n\n          This is a very powerful operation. Suppose we wanted to add a comment\n          to blog posts, using the same \"blog\" input above. This time, we only\n          want to comment on the posts written by \"stedolan\". We can find those\n          posts using the \"select\" function described earlier:\n\n              .posts[] | select(.author == \"stedolan\")\n\n          The paths provided by this operation point to each of the posts that\n          \"stedolan\" wrote, and we can comment on each of them in the same way\n          that we did before:\n\n              (.posts[] | select(.author == \"stedolan\") | .comments) |=\n                  . + [\"terrible.\"]\n"
  },
  {
    "path": "docs/content/manual/v1.4/manual.yml",
    "content": "---\nheadline: jq 1.4 Manual\n\nbody: |\n\n  A jq program is a \"filter\": it takes an input, and produces an\n  output. There are a lot of builtin filters for extracting a\n  particular field of an object, or converting a number to a string,\n  or various other standard tasks.\n\n  Filters can be combined in various ways - you can pipe the output of\n  one filter into another filter, or collect the output of a filter\n  into an array.\n\n  Some filters produce multiple results, for instance there's one that\n  produces all the elements of its input array. Piping that filter\n  into a second runs the second filter for each element of the\n  array. Generally, things that would be done with loops and iteration\n  in other languages are just done by gluing filters together in jq.\n\n  It's important to remember that every filter has an input and an\n  output. Even literals like \"hello\" or 42 are filters - they take an\n  input but always produce the same literal as output. Operations that\n  combine two filters, like addition, generally feed the same input to\n  both and combine the results. So, you can implement an averaging\n  filter as `add / length` - feeding the input array both to the `add`\n  filter and the `length` filter and dividing the results.\n\n  But that's getting ahead of ourselves. :) Let's start with something\n  simpler:\n\nmanpage_intro: |\n  jq(1) -- Command-line JSON processor\n  ====================================\n\n  ## SYNOPSIS\n\n  `jq` [<options>...] <filter> [<files>...]\n\n  `jq` can transform JSON in various ways, by selecting, iterating,\n  reducing and otherwise mangling JSON documents. For instance,\n  running the command `jq 'map(.price) | add'` will take an array of\n  JSON objects as input and return the sum of their \"price\" fields.\n\n  By default, `jq` reads a stream of JSON objects (whitespace\n  separated) from `stdin`. One or more <files> may be specified, in\n  which case `jq` will read input from those instead.\n\n  The <options> are described in the [INVOKING JQ] section, they\n  mostly concern input and output formatting. The <filter> is written\n  in the jq language and specifies how to transform the input\n  document.\n\n  ## FILTERS\n\nmanpage_epilogue: |\n  ## BUGS\n\n  Presumably. Report them or discuss them at:\n\n      https://github.com/jqlang/jq/issues\n\n  ## AUTHOR\n\n  Stephen Dolan `<mu@netsoc.tcd.ie>`\n\nsections:\n  - title: Invoking jq\n    body: |\n\n      jq filters run on a stream of JSON data. The input to jq is\n      parsed as a sequence of whitespace-separated JSON values which\n      are passed through the provided filter one at a time. The\n      output(s) of the filter are written to standard output, as a\n      sequence of newline-separated JSON data.\n\n      Note: it is important to mind the shell's quoting rules.  As a\n      general rule it's best to always quote (with single-quote\n      characters) the jq program, as too many characters with special\n      meaning to jq are also shell meta-characters.  For example, `jq\n      \"foo\"` will fail on most Unix shells because that will be the same\n      as `jq foo`, which will generally fail because `foo is not\n      defined`.  When using the Windows command shell (cmd.exe) it's\n      best to use double quotes around your jq program when given on the\n      command-line (instead of the `-f program-file` option), but then\n      double-quotes in the jq program need backslash escaping.\n\n      You can affect how jq reads and writes its input and output\n      using some command-line options:\n\n      * `--null-input` / `-n`:\n\n        Don't read any input at all. Instead, the filter is run once\n        using `null` as the input. This is useful when using jq as a\n        simple calculator or to construct JSON data from scratch.\n\n      * `--raw-input` / `-R`:\n\n        Don't parse the input as JSON. Instead, each line of text is\n        passed to the filter as a string. If combined with `--slurp`,\n        then the entire input is passed to the filter as a single long\n        string.\n\n      * `--slurp` / `-s`:\n\n        Instead of running the filter for each JSON object in the\n        input, read the entire input stream into a large array and run\n        the filter just once.\n\n      * `--online-input` / `-I`:\n\n        When the top-level input value is an array produce its elements\n        instead of the array.  This allows on-line processing of\n        potentially very large top-level arrays' elements.\n\n      * `--compact-output` / `-c`:\n\n        By default, jq pretty-prints JSON output. Using this option\n        will result in more compact output by instead putting each\n        JSON object on a single line.\n\n      * `--raw-output` / `-r`:\n\n        With this option, if the filter's result is a string then it\n        will be written directly to standard output rather than being\n        formatted as a JSON string with quotes. This can be useful for\n        making jq filters talk to non-JSON-based systems.\n\n      * `--ascii-output` / `-a`:\n\n        jq usually outputs non-ASCII Unicode codepoints as UTF-8, even\n        if the input specified them as escape sequences (like\n        \"\\u03bc\"). Using this option, you can force jq to produce pure\n        ASCII output with every non-ASCII character replaced with the\n        equivalent escape sequence.\n\n      * `--sort-keys` / `-S`:\n\n        Output the fields of each object with the keys in sorted order.\n\n      * `--color-output` / `-C` and `--monochrome-output` / `-M`:\n\n        By default, jq outputs colored JSON if writing to a\n        terminal. You can force it to produce color even if writing to\n        a pipe or a file using `-C`, and disable color with `-M`.\n\n      * `--unbuffered`:\n\n        Flush the output after each JSON object is printed (useful if\n        you're piping a slow data source into jq and piping jq's\n        output elsewhere).\n\n      * `-f filename` / `--from-file filename`:\n\n        Read filter from the file rather than from a command line, like\n        awk's -f option. You can also use '#' to make comments.\n\n      * `--arg name value`:\n\n        This option passes a value to the jq program as a predefined\n        variable. If you run jq with `--arg foo bar`, then `$foo` is\n        available in the program and has the value `\"bar\"`.\n\n      * `--argfile name filename`:\n\n        This option passes the first value from the named file as a\n        value to the jq program as a predefined variable. If you run jq\n        with `--argfile foo bar`, then `$foo` is available in the\n        program and has the value resulting from parsing the content of\n        the file named `bar`.\n\n      * `--exit-status` / `-e`:\n\n        Sets the exit status of jq to 0 if the last output value was\n        neither `false` nor `null`, 1 if the last output value was\n        either `false` or `null`, or 4 if no valid result was ever\n        produced.  Normally jq exits with 2 if there was any usage\n        problem or system error, 3 if there was a jq program compile\n        error, or 0 if the jq program ran.\n\n      * `--version` / `-V`:\n\n        Output the jq version and exit with zero.\n\n      * `--help` / `-h`:\n\n        Output the jq help and exit with zero.\n\n  - title: Basic filters\n    entries:\n      - title: \"`.`\"\n        body: |\n\n          The absolute simplest (and least interesting) filter\n          is `.`. This is a filter that takes its input and\n          produces it unchanged as output.\n\n          Since jq by default pretty-prints all output, this trivial\n          program can be a useful way of formatting JSON output from,\n          say, `curl`.\n\n        examples:\n          - program: '.'\n            input: '\"Hello, world!\"'\n            output: ['\"Hello, world!\"']\n\n      - title: \"`.foo`, `.foo.bar`\"\n        body: |\n\n          The simplest *useful* filter is `.foo`. When given a\n          JSON object (aka dictionary or hash) as input, it produces\n          the value at the key \"foo\", or null if there's none present.\n\n          If the key contains special characters or starts with a digit,\n          you need to surround it with double quotes like this: `.\"foo$\"`.\n\n          A filter of the form `.foo.bar` is equivalent to `.foo|.bar`.\n\n        examples:\n          - program: '.foo'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n          - program: '.foo'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n          - program: '.[\"foo\"]'\n            input: '{\"foo\": 42}'\n            output: ['42']\n\n      - title: \"`.foo?`\"\n        body: |\n\n          Just like `.foo`, but does not output an error when `.` is not an\n          object.\n\n        examples:\n          - program: '.foo?'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n          - program: '.foo?'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n          - program: '.[\"foo\"]?'\n            input: '{\"foo\": 42}'\n            output: ['42']\n          - program: '[.foo?]'\n            input: '[1,2]'\n            output: ['[]']\n\n      - title: \"`.[<string>]`, `.[<number>]`, `.[<number>:<number>]`\"\n        body: |\n\n          You can also look up fields of an object using syntax like\n          `.[\"foo\"]` (`.foo` above is a shorthand version of this). This\n          one works for arrays as well, if the key is an integer. Arrays\n          are zero-based, so `.[2]` returns the third element of the array.\n\n          The `.[10:15]` syntax can be used to return a subarray of an\n          array or substring of a string. The array returned by\n          `.[10:15]` will be of length 5, containing the elements from\n          index 10 (inclusive) to index 15 (exclusive). Either index may\n          be negative (in which case it counts backwards from the end of\n          the array), or omitted (in which case it refers to the start\n          or end of the array). Indices are zero-based.\n\n          The `?` \"operator\" can also be used with the slice operator,\n          as in `.[10:15]?`, which outputs values where the inputs are\n          slice-able.\n\n        examples:\n          - program: '.[0]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['{\"name\":\"JSON\", \"good\":true}']\n\n          - program: '.[2]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['null']\n\n          - program: '.[2:4]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"c\", \"d\"]']\n\n          - program: '.[2:4]'\n            input: '\"abcdefghi\"'\n            output: ['\"cd\"']\n\n          - program: '.[:3]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"a\", \"b\", \"c\"]']\n\n          - program: '.[-2:]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"d\", \"e\"]']\n\n      - title: \"`.[]`\"\n        body: |\n\n          If you use the `.[index]` syntax, but omit the index\n          entirely, it will return *all* of the elements of an\n          array. Running `.[]` with the input `[1,2,3]` will produce the\n          numbers as three separate results, rather than as a single\n          array.\n\n          You can also use this on an object, and it will return all\n          the values of the object.\n\n        examples:\n          - program: '.[]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output:\n              - '{\"name\":\"JSON\", \"good\":true}'\n              - '{\"name\":\"XML\", \"good\":false}'\n\n          - program: '.[]'\n            input: '[]'\n            output: []\n\n          - program: '.[]'\n            input: '{\"a\": 1, \"b\": 1}'\n            output: ['1', '1']\n\n      - title: \"`.[]?`\"\n        body: |\n\n          Like `.[]`, but no errors will be output if . is not an array\n          or object.\n\n      - title: \"`,`\"\n        body: |\n\n          If two filters are separated by a comma, then the\n          input will be fed into both and there will be multiple\n          outputs: first, all of the outputs produced by the left\n          expression, and then all of the outputs produced by the\n          right. For instance, filter `.foo, .bar`, produces\n          both the \"foo\" fields and \"bar\" fields as separate outputs.\n\n        examples:\n          - program: '.foo, .bar'\n            input: '{\"foo\": 42, \"bar\": \"something else\", \"baz\": true}'\n            output: ['42', '\"something else\"']\n\n          - program: \".user, .projects[]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['\"stedolan\"', '\"jq\"', '\"wikiflow\"']\n\n          - program: '.[4,2]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['\"e\"', '\"c\"']\n\n      - title: \"`|`\"\n        body: |\n          The | operator combines two filters by feeding the output(s) of\n          the one on the left into the input of the one on the right. It's\n          pretty much the same as the Unix shell's pipe, if you're used to\n          that.\n\n          If the one on the left produces multiple results, the one on\n          the right will be run for each of those results. So, the\n          expression `.[] | .foo` retrieves the \"foo\" field of each\n          element of the input array.\n\n        examples:\n          - program: '.[] | .name'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['\"JSON\"', '\"XML\"']\n\n  - title: Types and Values\n    body: |\n\n      jq supports the same set of datatypes as JSON - numbers,\n      strings, booleans, arrays, objects (which in JSON-speak are\n      hashes with only string keys), and \"null\".\n\n      Booleans, null, strings and numbers are written the same way as\n      in JSON. Just like everything else in jq, these simple\n      values take an input and produce an output - `42` is a valid jq\n      expression that takes an input, ignores it, and returns 42\n      instead.\n\n    entries:\n      - title: \"Array construction: `[]`\"\n        body: |\n\n          As in JSON, `[]` is used to construct arrays, as in\n          `[1,2,3]`. The elements of the arrays can be any jq\n          expression. All of the results produced by all of the\n          expressions are collected into one big array. You can use it\n          to construct an array out of a known quantity of values (as\n          in `[.foo, .bar, .baz]`) or to \"collect\" all the results of a\n          filter into an array (as in `[.items[].name]`)\n\n          Once you understand the \",\" operator, you can look at jq's array\n          syntax in a different light: the expression `[1,2,3]` is not using a\n          built-in syntax for comma-separated arrays, but is instead applying\n          the `[]` operator (collect results) to the expression 1,2,3 (which\n          produces three different results).\n\n          If you have a filter `X` that produces four results,\n          then the expression `[X]` will produce a single result, an\n          array of four elements.\n\n        examples:\n          - program: \"[.user, .projects[]]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['[\"stedolan\", \"jq\", \"wikiflow\"]']\n      - title: \"Objects: `{}`\"\n        body: |\n\n          Like JSON, `{}` is for constructing objects (aka\n          dictionaries or hashes), as in: `{\"a\": 42, \"b\": 17}`.\n\n          If the keys are \"sensible\" (all alphabetic characters), then\n          the quotes can be left off. The value can be any expression\n          (although you may need to wrap it in parentheses if it's a\n          complicated one), which gets applied to the {} expression's\n          input (remember, all filters have an input and an\n          output).\n\n              {foo: .bar}\n\n          will produce the JSON object `{\"foo\": 42}` if given the JSON\n          object `{\"bar\":42, \"baz\":43}`. You can use this to select\n          particular fields of an object: if the input is an object\n          with \"user\", \"title\", \"id\", and \"content\" fields and you\n          just want \"user\" and \"title\", you can write\n\n              {user: .user, title: .title}\n\n          Because that's so common, there's a shortcut syntax: `{user, title}`.\n\n          If one of the expressions produces multiple results,\n          multiple dictionaries will be produced. If the input's\n\n              {\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n\n          then the expression\n\n              {user, title: .titles[]}\n\n          will produce two outputs:\n\n              {\"user\":\"stedolan\", \"title\": \"JQ Primer\"}\n              {\"user\":\"stedolan\", \"title\": \"More JQ\"}\n\n          Putting parentheses around the key means it will be evaluated as an\n          expression. With the same input as above,\n\n              {(.user): .titles}\n\n          produces\n\n              {\"stedolan\": [\"JQ Primer\", \"More JQ\"]}\n\n        examples:\n          - program: '{user, title: .titles[]}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output:\n              - '{\"user\":\"stedolan\", \"title\": \"JQ Primer\"}'\n              - '{\"user\":\"stedolan\", \"title\": \"More JQ\"}'\n          - program: '{(.user): .titles}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output: ['{\"stedolan\": [\"JQ Primer\", \"More JQ\"]}']\n\n  - title: Builtin operators and functions\n    body: |\n\n      Some jq operators (for instance, `+`) do different things\n      depending on the type of their arguments (arrays, numbers,\n      etc.). However, jq never does implicit type conversions. If you\n      try to add a string to an object you'll get an error message and\n      no result.\n\n    entries:\n      - title: \"Addition: `+`\"\n        body: |\n\n          The operator `+` takes two filters, applies them both\n          to the same input, and adds the results together. What\n          \"adding\" means depends on the types involved:\n\n          - **Numbers** are added by normal arithmetic.\n\n          - **Arrays** are added by being concatenated into a larger array.\n\n          - **Strings** are added by being joined into a larger string.\n\n          - **Objects** are added by merging, that is, inserting all\n              the key-value pairs from both objects into a single\n              combined object. If both objects contain a value for the\n              same key, the object on the right of the `+` wins. (For\n              recursive merge use the `*` operator.)\n\n          `null` can be added to any value, and returns the other\n          value unchanged.\n\n        examples:\n          - program: '.a + 1'\n            input: '{\"a\": 7}'\n            output: ['8']\n          - program: '.a + .b'\n            input: '{\"a\": [1,2], \"b\": [3,4]}'\n            output: ['[1,2,3,4]']\n          - program: '.a + null'\n            input: '{\"a\": 1}'\n            output: ['1']\n          - program: '.a + 1'\n            input: '{}'\n            output: ['1']\n          - program: '{a: 1} + {b: 2} + {c: 3} + {a: 42}'\n            input: 'null'\n            output: ['{\"a\": 42, \"b\": 2, \"c\": 3}']\n\n      - title: \"Subtraction: `-`\"\n        body: |\n\n          As well as normal arithmetic subtraction on numbers, the `-`\n          operator can be used on arrays to remove all occurrences of\n          the second array's elements from the first array.\n\n        examples:\n          - program: '4 - .a'\n            input: '{\"a\":3}'\n            output: ['1']\n          - program: . - [\"xml\", \"yaml\"]\n            input: '[\"xml\", \"yaml\", \"json\"]'\n            output: ['[\"json\"]']\n\n      - title: \"Multiplication, division, modulo: `*`, `/`, `%`\"\n        body: |\n\n          These operators only work on numbers, and do the expected.\n\n          Multiplying a string by a number produces the concatenation of\n          that string that many times.\n\n          Dividing a string by another splits the first using the second\n          as separators.\n\n          Multiplying two objects will merge them recursively: this works\n          like addition but if both objects contain a value for the\n          same key, and the values are objects, the two are merged with\n          the same strategy.\n\n        examples:\n          - program: '10 / . * 3'\n            input: '5'\n            output: ['6']\n          - program: '. / \", \"'\n            input: '\"a, b,c,d, e\"'\n            output: ['[\"a\",\"b,c,d\",\"e\"]']\n          - program: '{\"k\": {\"a\": 1, \"b\": 2}} * {\"k\": {\"a\": 0,\"c\": 3}}'\n            input: 'null'\n            output: ['{\"k\": {\"a\": 0, \"b\": 2, \"c\": 3}}']\n\n      - title: \"`length`\"\n        body: |\n\n          The builtin function `length` gets the length of various\n          different types of value:\n\n          - The length of a **string** is the number of Unicode\n            codepoints it contains (which will be the same as its\n            JSON-encoded length in bytes if it's pure ASCII).\n\n          - The length of an **array** is the number of elements.\n\n          - The length of an **object** is the number of key-value pairs.\n\n          - The length of **null** is zero.\n\n        examples:\n          - program: '.[] | length'\n            input: '[[1,2], \"string\", {\"a\":2}, null]'\n            output: ['2', '6', '1', '0']\n\n      - title: \"`keys`\"\n        body: |\n\n          The builtin function `keys`, when given an object, returns\n          its keys in an array.\n\n          The keys are sorted \"alphabetically\", by unicode codepoint\n          order. This is not an order that makes particular sense in\n          any particular language, but you can count on it being the\n          same for any two objects with the same set of keys,\n          regardless of locale settings.\n\n          When `keys` is given an array, it returns the valid indices\n          for that array: the integers from 0 to length-1.\n\n        examples:\n          - program: 'keys'\n            input: '{\"abc\": 1, \"abcd\": 2, \"Foo\": 3}'\n            output: ['[\"Foo\", \"abc\", \"abcd\"]']\n          - program: 'keys'\n            input: '[42,3,35]'\n            output: ['[0,1,2]']\n\n      - title: \"`has`\"\n        body: |\n\n          The builtin function `has` returns whether the input object\n          has the given key, or the input array has an element at the\n          given index.\n\n          `has($key)` has the same effect as checking whether `$key`\n          is a member of the array returned by `keys`, although `has`\n          will be faster.\n\n        examples:\n          - program: 'map(has(\"foo\"))'\n            input: '[{\"foo\": 42}, {}]'\n            output: ['[true, false]']\n          - program: 'map(has(2))'\n            input: '[[0,1], [\"a\",\"b\",\"c\"]]'\n            output: ['[false, true]']\n\n      - title: \"`del`\"\n        body: |\n\n          The builtin function `del` removes a key and its corresponding\n          value from an object.\n\n        examples:\n          - program: 'del(.foo)'\n            input: '{\"foo\": 42, \"bar\": 9001, \"baz\": 42}'\n            output: ['{\"bar\": 9001, \"baz\": 42}']\n          - program: 'del(.[1, 2])'\n            input: '[\"foo\", \"bar\", \"baz\"]'\n            output: ['[\"foo\"]']\n\n      - title: \"`to_entries`, `from_entries`, `with_entries(f)`\"\n        body: |\n\n          These functions convert between an object and an array of\n          key-value pairs. If `to_entries` is passed an object, then\n          for each `k: v` entry in the input, the output array\n          includes `{\"key\": k, \"value\": v}`.\n\n          `from_entries` does the opposite conversion, and\n          `with_entries(f)` is a shorthand for `to_entries | map(f) |\n          from_entries`, useful for doing some operation to all keys\n          and values of an object.\n\n        examples:\n          - program: 'to_entries'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]']\n          - program: 'from_entries'\n            input: '[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]'\n            output: ['{\"a\": 1, \"b\": 2}']\n          - program: 'with_entries(.key |= \"KEY_\" + .)'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['{\"KEY_a\": 1, \"KEY_b\": 2}']\n\n\n      - title: \"`select`\"\n        body: |\n\n          The function `select(foo)` produces its input unchanged if\n          `foo` returns true for that input, and produces no output\n          otherwise.\n\n          It's useful for filtering lists: `[1,2,3] | map(select(. >= 2))`\n          will give you `[2,3]`.\n\n        examples:\n          - program: 'map(select(. >= 2))'\n            input: '[1,5,3,0,7]'\n            output: ['[5,3,7]']\n\n\n      - title: \"`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `strings`, `nulls`, `values`, `scalars`\"\n        body: |\n\n          These built-ins select only inputs that are arrays, objects,\n          iterables (arrays or objects), booleans, numbers, strings,\n          null, non-null values, and non-iterables, respectively.\n\n        examples:\n          - program: '.[]|numbers'\n            input: '[[],{},1,\"foo\",null,true,false]'\n            output: ['1']\n\n      - title: \"`empty`\"\n        body: |\n\n          `empty` returns no results. None at all. Not even `null`.\n\n          It's useful on occasion. You'll know if you need it :)\n\n        examples:\n          - program: '1, empty, 2'\n            input: 'null'\n            output: ['1', '2']\n          - program: '[1,2,empty,3]'\n            input: 'null'\n            output: ['[1,2,3]']\n\n      - title: \"`map(f)`\"\n        body: |\n\n          For any filter `f`, `map(f)` will run that filter for each\n          element of the input array, and produce the outputs a new\n          array. `map(.+1)` will increment each element of an array of numbers.\n\n          `map(f)` is equivalent to `[.[] | f]`. In fact, this is how\n          it's defined.\n\n        examples:\n          - program: 'map(.+1)'\n            input: '[1,2,3]'\n            output: ['[2,3,4]']\n\n      - title: \"`paths`\"\n        body: |\n\n          Outputs the paths to all the elements in its input (except it\n          does not output the empty list, representing . itself).\n\n          `paths` is equivalent to\n\n              def paths: path(recurse(if (type|. == \"array\" or . == \"object\") then .[] else empty end))|select(length > 0);\n\n        examples:\n          - program: '[paths]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1],[1,0],[1,1],[1,1,\"a\"]]']\n\n      - title: \"`leaf_paths`\"\n        body: |\n\n          Outputs the paths to all the leaves (non-array, non-object\n          elements) in its input.\n\n        examples:\n          - program: '[leaf_paths]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1,1,\"a\"]]']\n\n      - title: \"`add`\"\n        body: |\n\n          The filter `add` takes as input an array, and produces as\n          output the elements of the array added together. This might\n          mean summed, concatenated or merged depending on the types\n          of the elements of the input array - the rules are the same\n          as those for the `+` operator (described above).\n\n          If the input is an empty array, `add` returns `null`.\n\n        examples:\n          - program: add\n            input: '[\"a\",\"b\",\"c\"]'\n            output: ['\"abc\"']\n          - program: add\n            input: '[1, 2, 3]'\n            output: ['6']\n          - program: add\n            input: '[]'\n            output: [\"null\"]\n\n      - title: \"`any`\"\n        body: |\n\n          The filter `any` takes as input an array of boolean values,\n          and produces `true` as output if any of the elements of\n          the array are `true`.\n\n          If the input is an empty array, `any` returns `false`.\n\n        examples:\n          - program: any\n            input: '[true, false]'\n            output: [\"true\"]\n          - program: any\n            input: '[false, false]'\n            output: [\"false\"]\n          - program: any\n            input: '[]'\n            output: [\"false\"]\n\n      - title: \"`all`\"\n        body: |\n\n          The filter `all` takes as input an array of boolean values,\n          and produces `true` as output if all of the elements of\n          the array are `true`.\n\n          If the input is an empty array, `all` returns `true`.\n\n        examples:\n          - program: all\n            input: '[true, false]'\n            output: [\"false\"]\n          - program: all\n            input: '[true, true]'\n            output: [\"true\"]\n          - program: all\n            input: '[]'\n            output: [\"true\"]\n\n      - title: \"`range`\"\n        body: |\n\n          The `range` function produces a range of numbers. `range(4;10)`\n          produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers\n          are produced as separate outputs. Use `[range(4;10)]` to get a range as\n          an array.\n\n        examples:\n          - program: 'range(2;4)'\n            input: 'null'\n            output: ['2', '3']\n          - program: '[range(2;4)]'\n            input: 'null'\n            output: ['[2,3]']\n\n      - title: \"`floor`\"\n        body: |\n\n          The `floor` function returns the floor of its numeric input.\n\n        examples:\n          - program: 'floor'\n            input: '3.14159'\n            output: ['3']\n\n      - title: \"`sqrt`\"\n        body: |\n\n          The `sqrt` function returns the square root of its numeric input.\n\n        examples:\n          - program: 'sqrt'\n            input: '9'\n            output: ['3']\n\n      - title: \"`tonumber`\"\n        body: |\n\n          The `tonumber` function parses its input as a number. It\n          will convert correctly-formatted strings to their numeric\n          equivalent, leave numbers alone, and give an error on all other input.\n\n        examples:\n          - program: '.[] | tonumber'\n            input: '[1, \"1\"]'\n            output: ['1', '1']\n\n      - title: \"`tostring`\"\n        body: |\n\n          The `tostring` function prints its input as a\n          string. Strings are left unchanged, and all other values are\n          JSON-encoded.\n\n        examples:\n          - program: '.[] | tostring'\n            input: '[1, \"1\", [1]]'\n            output: ['\"1\"', '\"1\"', '\"[1]\"']\n\n      - title: \"`type`\"\n        body: |\n\n          The `type` function returns the type of its argument as a\n          string, which is one of null, boolean, number, string, array\n          or object.\n\n        examples:\n          - program: 'map(type)'\n            input: '[0, false, [], {}, null, \"hello\"]'\n            output: ['[\"number\", \"boolean\", \"array\", \"object\", \"null\", \"string\"]']\n\n      - title: \"`sort`, `sort_by`\"\n        body: |\n\n          The `sort` functions sorts its input, which must be an\n          array. Values are sorted in the following order:\n\n          * `null`\n          * `false`\n          * `true`\n          * numbers\n          * strings, in alphabetical order (by unicode codepoint value)\n          * arrays, in lexical order\n          * objects\n\n          The ordering for objects is a little complex: first they're\n          compared by comparing their sets of keys (as arrays in\n          sorted order), and if their keys are equal then the values\n          are compared key by key.\n\n          `sort_by` may be used to sort by a particular field of an\n          object, or by applying any jq filter. `sort_by(foo)`\n          compares two elements by comparing the result of `foo` on\n          each element.\n\n        examples:\n          - program: 'sort'\n            input: '[8,3,null,6]'\n            output: ['[null,3,6,8]']\n          - program: 'sort_by(.foo)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":100}, {\"foo\":2, \"bar\":1}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":100}, {\"foo\":4, \"bar\":10}]']\n\n      - title: \"`group_by`\"\n        body: |\n\n          `group_by(.foo)` takes as input an array, groups the\n          elements having the same `.foo` field into separate arrays,\n          and produces all of these arrays as elements of a larger\n          array, sorted by the value of the `.foo` field.\n\n          Any jq expression, not just a field access, may be used in\n          place of `.foo`. The sorting order is the same as described\n          in the `sort` function above.\n\n        examples:\n          - program: 'group_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":10}, {\"foo\":3, \"bar\":100}, {\"foo\":1, \"bar\":1}]'\n            output: ['[[{\"foo\":1, \"bar\":10}, {\"foo\":1, \"bar\":1}], [{\"foo\":3, \"bar\":100}]]']\n\n      - title: \"`min`, `max`, `min_by`, `max_by`\"\n        body: |\n\n          Find the minimum or maximum element of the input array. The\n          `_by` versions allow you to specify a particular field or\n          property to examine, e.g. `min_by(.foo)` finds the object\n          with the smallest `foo` field.\n\n        examples:\n          - program: 'min'\n            input: '[5,4,2,7]'\n            output: ['2']\n          - program: 'max_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":14}, {\"foo\":2, \"bar\":3}]'\n            output: ['{\"foo\":2, \"bar\":3}']\n\n      - title: \"`unique`\"\n        body: |\n\n          The `unique` function takes as input an array and produces\n          an array of the same elements, in sorted order, with\n          duplicates removed.\n\n        examples:\n          - program: 'unique'\n            input: '[1,2,5,3,5,3,1,3]'\n            output: ['[1,2,3,5]']\n\n      - title: \"`unique_by`\"\n        body: |\n\n          The `unique_by(.foo)` function takes as input an array and produces\n          an array of the same elements, in sorted order, with\n          elements with a duplicate `.foo` field removed. Think of it as making\n          an array by taking one element out of every group produced by\n          `group_by`.\n\n        examples:\n          - program: 'unique_by(.foo)'\n            input: '[{\"foo\": 1, \"bar\": 2}, {\"foo\": 1, \"bar\": 3}, {\"foo\": 4, \"bar\": 5}]'\n            output: ['[{\"foo\": 1, \"bar\": 2}, {\"foo\": 4, \"bar\": 5}]']\n          - program: 'unique_by(length)'\n            input: '[\"chunky\", \"bacon\", \"kitten\", \"cicada\", \"asparagus\"]'\n            output: ['[\"bacon\", \"chunky\", \"asparagus\"]']\n\n\n      - title: \"`reverse`\"\n        body: |\n\n          This function reverses an array.\n\n        examples:\n          - program: 'reverse'\n            input: '[1,2,3,4]'\n            output: ['[4,3,2,1]']\n\n      - title: \"`contains`\"\n        body: |\n\n          The filter `contains(b)` will produce true if b is\n          completely contained within the input. A string B is\n          contained in a string A if B is a substring of A. An array B\n          is contained in an array A is all elements in B are\n          contained in any element in A. An object B is contained in\n          object A if all of the values in B are contained in the\n          value in A with the same key. All other types are assumed to\n          be contained in each other if they are equal.\n\n        examples:\n          - program: 'contains(\"bar\")'\n            input: '\"foobar\"'\n            output: ['true']\n          - program: 'contains([\"baz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['true']\n          - program: 'contains([\"bazzzzz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['false']\n          - program: 'contains({foo: 12, bar: [{barp: 12}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['true']\n          - program: 'contains({foo: 12, bar: [{barp: 15}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['false']\n\n      - title: \"`indices(s)`\"\n        body: |\n\n          Outputs an array containing the indices in `.` where `s`\n          occurs.  The input may be an array, in which case if `s` is an\n          array then the indices output will be those where all elements\n          in `.` match those of `s`.\n\n        examples:\n          - program: 'indices(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['[3,7,12]']\n          - program: 'indices(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['[1,3,5]']\n          - program: 'indices([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['[1,8]']\n\n      - title: \"`index(s)`, `rindex(s)`\"\n        body: |\n\n          Outputs the index of the first (`index`) or last (`rindex`)\n          occurrence of `s` in the input.\n\n        examples:\n          - program: 'index(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['3']\n          - program: 'rindex(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['12']\n\n      - title: \"`startswith`\"\n        body: |\n\n          Outputs `true` if . starts with the given string argument.\n\n        examples:\n          - program: '[.[]|startswith(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"barfoob\"]'\n            output: ['[false, true, false, true, false]']\n\n      - title: \"`endswith`\"\n        body: |\n\n          Outputs `true` if . ends with the given string argument.\n\n        examples:\n          - program: '[.[]|endswith(\"foo\")]'\n            input: '[\"foobar\", \"barfoo\"]'\n            output: ['[false, true]']\n\n      - title: \"`ltrimstr`\"\n        body: |\n\n          Outputs its input with the given prefix string removed, if it\n          starts with it.\n\n        examples:\n          - program: '[.[]|ltrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"afoo\"]'\n            output: ['[\"fo\",\"\",\"barfoo\",\"bar\",\"afoo\"]']\n\n      - title: \"`rtrimstr`\"\n        body: |\n\n          Outputs its input with the given suffix string removed, if it\n          starts with it.\n\n        examples:\n          - program: '[.[]|rtrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"foob\"]'\n            output: ['[\"fo\",\"\",\"bar\",\"foobar\",\"foob\"]']\n\n      - title: \"`explode`\"\n        body: |\n\n          Converts an input string into an array of the string's\n          codepoint numbers.\n\n        examples:\n          - program: 'explode'\n            input: '\"foobar\"'\n            output: ['[102,111,111,98,97,114]']\n\n      - title: \"`implode`\"\n        body: |\n\n          The inverse of explode.\n\n        examples:\n          - program: 'implode'\n            input: '[65, 66, 67]'\n            output: ['\"ABC\"']\n\n      - title: \"`split`\"\n        body: |\n\n          Splits an input string on the separator argument.\n\n        examples:\n          - program: 'split(\", \")'\n            input: '\"a, b,c,d, e\"'\n            output: ['[\"a\",\"b,c,d\",\"e\"]']\n\n      - title: \"`join`\"\n        body: |\n\n          Joins the array of elements given as input, using the\n          argument as separator. It is the inverse of `split`: that is,\n          running `split(\"foo\") | join(\"foo\")` over any input string\n          returns said input string.\n\n        examples:\n          - program: 'join(\", \")'\n            input: '[\"a\",\"b,c,d\",\"e\"]'\n            output: ['\"a, b,c,d, e\"']\n\n\n      - title: \"`recurse`\"\n        body: |\n\n          The `recurse` function allows you to search through a\n          recursive structure, and extract interesting data from all\n          levels. Suppose your input represents a filesystem:\n\n              {\"name\": \"/\", \"children\": [\n                {\"name\": \"/bin\", \"children\": [\n                  {\"name\": \"/bin/ls\", \"children\": []},\n                  {\"name\": \"/bin/sh\", \"children\": []}]},\n                {\"name\": \"/home\", \"children\": [\n                  {\"name\": \"/home/stephen\", \"children\": [\n                    {\"name\": \"/home/stephen/jq\", \"children\": []}]}]}]}\n\n          Now suppose you want to extract all of the filenames\n          present. You need to retrieve `.name`, `.children[].name`,\n          `.children[].children[].name`, and so on. You can do this\n          with:\n\n              recurse(.children[]) | .name\n\n        examples:\n          - program: 'recurse(.foo[])'\n            input: '{\"foo\":[{\"foo\": []}, {\"foo\":[{\"foo\":[]}]}]}'\n            output:\n              - '{\"foo\":[{\"foo\":[]},{\"foo\":[{\"foo\":[]}]}]}'\n              - '{\"foo\":[]}'\n              - '{\"foo\":[{\"foo\":[]}]}'\n              - '{\"foo\":[]}'\n\n      - title: \"`recurse_down`\"\n        body: |\n\n          A quieter version of `recurse(.[])`, equivalent to:\n\n              def recurse_down: recurse(.[]?);\n\n      - title: \"`..`\"\n        body: |\n\n          Short-hand for `recurse_down`.  This is intended to resemble\n          the XPath `//` operator.  Note that `..a` does not work; use\n          `..|a` instead.\n\n        examples:\n          - program: '..|.a?'\n            input: '[[{\"a\":1}]]'\n            output: ['1']\n\n      - title: \"String interpolation: `\\\\(exp)`\"\n        body: |\n\n          Inside a string, you can put an expression inside parens\n          after a backslash. Whatever the expression returns will be\n          interpolated into the string.\n\n        examples:\n          - program: '\"The input was \\(.), which is one less than \\(.+1)\"'\n            input: '42'\n            output: ['\"The input was 42, which is one less than 43\"']\n\n      - title: \"Convert to/from JSON\"\n        body: |\n\n          The `tojson` and `fromjson` builtins dump values as JSON texts\n          or parse JSON texts into values, respectively.  The tojson\n          builtin differs from tostring in that tostring returns strings\n          unmodified, while tojson encodes strings as JSON strings.\n\n        examples:\n          - program: '[.[]|tostring]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"foo\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"\\\"foo\\\"\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson|fromjson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[1,\"foo\",[\"foo\"]]']\n\n      - title: \"Format strings and escaping\"\n        body: |\n\n          The `@foo` syntax is used to format and escape strings,\n          which is useful for building URLs, documents in a language\n          like HTML or XML, and so forth. `@foo` can be used as a\n          filter on its own, the possible escapings are:\n\n          * `@text`:\n\n            Calls `tostring`, see that function for details.\n\n          * `@json`:\n\n            Serialises the input as JSON.\n\n          * `@html`:\n\n            Applies HTML/XML escaping, by mapping the characters\n            `<>&'\"` to their entity equivalents `&lt;`, `&gt;`,\n            `&amp;`, `&apos;`, `&quot;`.\n\n          * `@uri`:\n\n            Applies percent-encoding, by mapping all reserved URI\n            characters to a `%xx` sequence.\n\n          * `@csv`:\n\n            The input must be an array, and it is rendered as CSV\n            with double quotes for strings, and quotes escaped by\n            repetition.\n\n          * `@sh`:\n\n            The input is escaped suitable for use in a command-line\n            for a POSIX shell. If the input is an array, the output\n            will be a series of space-separated strings.\n\n          * `@base64`:\n\n            The input is converted to base64 as specified by RFC 4648.\n\n          This syntax can be combined with string interpolation in a\n          useful way. You can follow a `@foo` token with a string\n          literal. The contents of the string literal will *not* be\n          escaped. However, all interpolations made inside that string\n          literal will be escaped. For instance,\n\n              @uri \"https://www.google.com/search?q=\\(.search)\"\n\n          will produce the following output for the input\n          `{\"search\":\"what is jq?\"}`:\n\n              \"https://www.google.com/search?q=what%20is%20jq%3f\"\n\n          Note that the slashes, question mark, etc. in the URL are\n          not escaped, as they were part of the string literal.\n\n        examples:\n          - program: '@html'\n            input: '\"This works if x < y\"'\n            output: ['\"This works if x &lt; y\"']\n\n          - program: '@sh \"echo \\(.)\"'\n            input: \"\\\"O'Hara's Ale\\\"\"\n            output: [\"\\\"echo 'O'\\\\\\\\''Hara'\\\\\\\\''s Ale'\\\"\"]\n\n  - title: Conditionals and Comparisons\n    entries:\n      - title: \"`==`, `!=`\"\n        body: |\n\n          The expression 'a == b' will produce 'true' if the result of a and b\n          are equal (that is, if they represent equivalent JSON documents) and\n          'false' otherwise. In particular, strings are never considered equal\n          to numbers. If you're coming from JavaScript, jq's == is like\n          JavaScript's === - considering values equal only when they have the\n          same type as well as the same value.\n\n          != is \"not equal\", and 'a != b' returns the opposite value of 'a == b'\n\n        examples:\n          - program: '.[] == 1'\n            input: '[1, 1.0, \"1\", \"banana\"]'\n            output: ['true', 'true', 'false', 'false']\n\n      - title: if-then-else-end\n        body: |\n\n          `if A then B else C end` will act the same as `B` if `A`\n          produces a value other than false or null, but act the same\n          as `C` otherwise.\n\n          Checking for false or null is a simpler notion of\n          \"truthiness\" than is found in JavaScript or Python, but it\n          means that you'll sometimes have to be more explicit about\n          the condition you want: you can't test whether, e.g. a\n          string is empty using `if .name then A else B end`, you'll\n          need something more like `if (.name | length) > 0 then A else\n          B end` instead.\n\n          If the condition `A` produces multiple results, then `B` is evaluated\n          once for each result that is not false or null, and `C` is evaluated\n          once for each false or null.\n\n          More cases can be added to an if using `elif A then B` syntax.\n\n        examples:\n          - program: |-\n              if . == 0 then\n                \"zero\"\n              elif . == 1 then\n                \"one\"\n              else\n                \"many\"\n              end\n            input: '2'\n            output: ['\"many\"']\n\n      - title: \"`>`, `>=`, `<=`, `<`\"\n        body: |\n\n          The comparison operators `>`, `>=`, `<=`, `<` return whether\n          their left argument is greater than, greater than or equal\n          to, less than or equal to or less than their right argument\n          (respectively).\n\n          The ordering is the same as that described for `sort`, above.\n\n        examples:\n          - program: '. < 5'\n            input: '2'\n            output: ['true']\n\n      - title: \"`and`, `or`, `not`\"\n        body: |\n\n          jq supports the normal Boolean operators `and`, `or`, `not`.\n          They have the same standard of truth as if expressions -\n          `false` and `null` are considered \"false values\", and\n          anything else is a \"true value\".\n\n          If an operand of one of these operators produces multiple\n          results, the operator itself will produce a result for each input.\n\n          `not` is in fact a builtin function rather than an operator,\n          so it is called as a filter to which things can be piped\n          rather than with special syntax, as in `.foo and .bar |\n          not`.\n\n          These three only produce the values `true` and `false`, and\n          so are only useful for genuine Boolean operations, rather\n          than the common Perl/Python/Ruby idiom of\n          \"value_that_may_be_null or default\". If you want to use this\n          form of \"or\", picking between two values rather than\n          evaluating a condition, see the `//` operator below.\n\n        examples:\n          - program: '42 and \"a string\"'\n            input: 'null'\n            output: ['true']\n          - program: '(true, false) or false'\n            input: 'null'\n            output: ['true', 'false']\n          - program: '(true, true) and (true, false)'\n            input: 'null'\n            output: ['true', 'false', 'true', 'false']\n          - program: '[true, false | not]'\n            input: 'null'\n            output: ['[false, true]']\n\n      - title: \"Alternative operator: `//`\"\n        body: |\n\n          A filter of the form `a // b` produces the same\n          results as `a`, if `a` produces results other than `false`\n          and `null`. Otherwise, `a // b` produces the same results as `b`.\n\n          This is useful for providing defaults: `.foo // 1` will\n          evaluate to `1` if there's no `.foo` element in the\n          input. It's similar to how `or` is sometimes used in Python\n          (jq's `or` operator is reserved for strictly Boolean\n          operations).\n\n        examples:\n          - program: '.foo // 42'\n            input: '{\"foo\": 19}'\n            output: ['19']\n          - program: '.foo // 42'\n            input: '{}'\n            output: ['42']\n\n  - title: Advanced features\n    body: |\n      Variables are an absolute necessity in most programming languages, but\n      they're relegated to an \"advanced feature\" in jq.\n\n      In most languages, variables are the only means of passing around\n      data. If you calculate a value, and you want to use it more than once,\n      you'll need to store it in a variable. To pass a value to another part\n      of the program, you'll need that part of the program to define a\n      variable (as a function parameter, object member, or whatever) in\n      which to place the data.\n\n      It is also possible to define functions in jq, although this is\n      is a feature whose biggest use is defining jq's standard library\n      (many jq functions such as `map` and `select` are in fact written\n      in jq).\n\n      Finally, jq has a `reduce` operation, which is very powerful but a\n      bit tricky. Again, it's mostly used internally, to define some\n      useful bits of jq's standard library.\n\n    entries:\n      - title: Variables\n        body: |\n\n          In jq, all filters have an input and an output, so manual\n          plumbing is not necessary to pass a value from one part of a program\n          to the next. Many expressions, for instance `a + b`, pass their input\n          to two distinct subexpressions (here `a` and `b` are both passed the\n          same input), so variables aren't usually necessary in order to use a\n          value twice.\n\n          For instance, calculating the average value of an array of numbers\n          requires a few variables in most languages - at least one to hold the\n          array, perhaps one for each element or for a loop counter. In jq, it's\n          simply `add / length` - the `add` expression is given the array and\n          produces its sum, and the `length` expression is given the array and\n          produces its length.\n\n          So, there's generally a cleaner way to solve most problems in jq than\n          defining variables. Still, sometimes they do make things easier, so jq\n          lets you define variables using `expression as $variable`. All\n          variable names start with `$`. Here's a slightly uglier version of the\n          array-averaging example:\n\n              length as $array_length | add / $array_length\n\n          We'll need a more complicated problem to find a situation where using\n          variables actually makes our lives easier.\n\n\n          Suppose we have an array of blog posts, with \"author\" and \"title\"\n          fields, and another object which is used to map author usernames to\n          real names. Our input looks like:\n\n              {\"posts\": [{\"title\": \"First post\", \"author\": \"anon\"},\n                         {\"title\": \"A well-written article\", \"author\": \"person1\"}],\n               \"realnames\": {\"anon\": \"Anonymous Coward\",\n                             \"person1\": \"Person McPherson\"}}\n\n          We want to produce the posts with the author field containing a real\n          name, as in:\n\n              {\"title\": \"First post\", \"author\": \"Anonymous Coward\"}\n              {\"title\": \"A well-written article\", \"author\": \"Person McPherson\"}\n\n          We use a variable, $names, to store the realnames object, so that we\n          can refer to it later when looking up author usernames:\n\n              .realnames as $names | .posts[] | {title, author: $names[.author]}\n\n          The expression `exp as $x | ...` means: for each value of expression\n          `exp`, run the rest of the pipeline with the entire original input, and\n          with `$x` set to that value.  Thus `as` functions as something of a\n          foreach loop.\n\n          Variables are scoped over the rest of the expression that defines\n          them, so\n\n              .realnames as $names | (.posts[] | {title, author: $names[.author]})\n\n          will work, but\n\n              (.realnames as $names | .posts[]) | {title, author: $names[.author]}\n\n          won't.\n\n        examples:\n          - program: '.bar as $x | .foo | . + $x'\n            input: '{\"foo\":10, \"bar\":200}'\n            output: ['210']\n\n      - title: 'Defining Functions'\n        body: |\n\n          You can give a filter a name using \"def\" syntax:\n\n              def increment: . + 1;\n\n          From then on, `increment` is usable as a filter just like a\n          builtin function (in fact, this is how some of the builtins\n          are defined). A function may take arguments:\n\n              def map(f): [.[] | f];\n\n          Arguments are passed as filters, not as values. The\n          same argument may be referenced multiple times with\n          different inputs (here `f` is run for each element of the\n          input array). Arguments to a function work more like\n          callbacks than like value arguments.\n\n          If you want the value-argument behaviour for defining simple\n          functions, you can just use a variable:\n\n              def addvalue(f): f as $value | map(. + $value);\n\n          With that definition, `addvalue(.foo)` will add the current\n          input's `.foo` field to each element of the array.\n\n        examples:\n          - program: 'def addvalue(f): . + [f]; map(addvalue(.[0]))'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1], [10,20,10]]']\n          - program: 'def addvalue(f): f as $x | map(. + $x); addvalue(.[0])'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1,2], [10,20,1,2]]']\n\n      - title: \"`reduce`\"\n        body: |\n\n          The `reduce` syntax allows you to combine all of the results of\n          an expression by accumulating them into a single answer.\n          The form is `reduce EXP as $var (INIT; UPDATE)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              reduce .[] as $item (0; . + $item)\n\n          For each result that `.[]` produces, `. + $item` is run to\n          accumulate a running total, starting from 0 as the input value.\n          In this example, `.[]` produces the results `1`, `2`, and `3`,\n          so the effect is similar to running something like this:\n\n              0 | 1 as $item | . + $item |\n                  2 as $item | . + $item |\n                  3 as $item | . + $item\n\n        examples:\n          - program: 'reduce .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['15']\n\n  - title: Assignment\n    body: |\n\n      Assignment works a little differently in jq than in most\n      programming languages. jq doesn't distinguish between references\n      to and copies of something - two objects or arrays are either\n      equal or not equal, without any further notion of being \"the\n      same object\" or \"not the same object\".\n\n      If an object has two fields which are arrays, `.foo` and `.bar`,\n      and you append something to `.foo`, then `.bar` will not get\n      bigger. Even if you've just set `.bar = .foo`. If you're used to\n      programming in languages like Python, Java, Ruby, JavaScript,\n      etc. then you can think of it as though jq does a full deep copy\n      of every object before it does the assignment (for performance,\n      it doesn't actually do that, but that's the general idea).\n\n    entries:\n      - title: \"`=`\"\n        body: |\n\n          The filter `.foo = 1` will take as input an object\n          and produce as output an object with the \"foo\" field set to\n          1. There is no notion of \"modifying\" or \"changing\" something\n          in jq - all jq values are immutable. For instance,\n\n           .foo = .bar | .foo.baz = 1\n\n          will not have the side-effect of setting .bar.baz to be set\n          to 1, as the similar-looking program in JavaScript, Python,\n          Ruby or other languages would. Unlike these languages (but\n          like Haskell and some other functional languages), there is\n          no notion of two arrays or objects being \"the same array\" or\n          \"the same object\". They can be equal, or not equal, but if\n          we change one of them in no circumstances will the other\n          change behind our backs.\n\n          This means that it's impossible to build circular values in\n          jq (such as an array whose first element is itself). This is\n          quite intentional, and ensures that anything a jq program\n          can produce can be represented in JSON.\n\n      - title: \"`|=`\"\n        body: |\n          As well as the assignment operator '=', jq provides the \"update\"\n          operator '|=', which takes a filter on the right-hand side and\n          works out the new value for the property being assigned to by running\n          the old value through this expression. For instance, .foo |= .+1 will\n          build an object with the \"foo\" field set to the input's \"foo\" plus 1.\n\n          This example should show the difference between '=' and '|=':\n\n          Provide input '{\"a\": {\"b\": 10}, \"b\": 20}' to the programs:\n\n          .a = .b\n          .a |= .b\n\n          The former will set the \"a\" field of the input to the \"b\" field of the\n          input, and produce the output {\"a\": 20}. The latter will set the \"a\"\n          field of the input to the \"a\" field's \"b\" field, producing {\"a\": 10}.\n\n      - title: \"`+=`, `-=`, `*=`, `/=`, `%=`, `//=`\"\n        body: |\n\n          jq has a few operators of the form `a op= b`, which are all\n          equivalent to `a |= . op b`. So, `+= 1` can be used to increment values.\n\n        examples:\n          - program: .foo += 1\n            input: '{\"foo\": 42}'\n            output: ['{\"foo\": 43}']\n\n      - title: Complex assignments\n        body: |\n          Lots more things are allowed on the left-hand side of a jq assignment\n          than in most languages. We've already seen simple field accesses on\n          the left hand side, and it's no surprise that array accesses work just\n          as well:\n\n              .posts[0].title = \"JQ Manual\"\n\n          What may come as a surprise is that the expression on the left may\n          produce multiple results, referring to different points in the input\n          document:\n\n              .posts[].comments |= . + [\"this is great\"]\n\n          That example appends the string \"this is great\" to the \"comments\"\n          array of each post in the input (where the input is an object with a\n          field \"posts\" which is an array of posts).\n\n          When jq encounters an assignment like 'a = b', it records the \"path\"\n          taken to select a part of the input document while executing a. This\n          path is then used to find which part of the input to change while\n          executing the assignment. Any filter may be used on the\n          left-hand side of an equals - whichever paths it selects from the\n          input will be where the assignment is performed.\n\n          This is a very powerful operation. Suppose we wanted to add a comment\n          to blog posts, using the same \"blog\" input above. This time, we only\n          want to comment on the posts written by \"stedolan\". We can find those\n          posts using the \"select\" function described earlier:\n\n              .posts[] | select(.author == \"stedolan\")\n\n          The paths provided by this operation point to each of the posts that\n          \"stedolan\" wrote, and we can comment on each of them in the same way\n          that we did before:\n\n              (.posts[] | select(.author == \"stedolan\") | .comments) |=\n                  . + [\"terrible.\"]\n"
  },
  {
    "path": "docs/content/manual/v1.5/manual.yml",
    "content": "---\nheadline: jq 1.5 Manual\n\nbody: |\n\n  A jq program is a \"filter\": it takes an input, and produces an\n  output. There are a lot of builtin filters for extracting a\n  particular field of an object, or converting a number to a string,\n  or various other standard tasks.\n\n  Filters can be combined in various ways - you can pipe the output of\n  one filter into another filter, or collect the output of a filter\n  into an array.\n\n  Some filters produce multiple results, for instance there's one that\n  produces all the elements of its input array. Piping that filter\n  into a second runs the second filter for each element of the\n  array. Generally, things that would be done with loops and iteration\n  in other languages are just done by gluing filters together in jq.\n\n  It's important to remember that every filter has an input and an\n  output. Even literals like \"hello\" or 42 are filters - they take an\n  input but always produce the same literal as output. Operations that\n  combine two filters, like addition, generally feed the same input to\n  both and combine the results. So, you can implement an averaging\n  filter as `add / length` - feeding the input array both to the `add`\n  filter and the `length` filter and then performing the division.\n\n  But that's getting ahead of ourselves. :) Let's start with something\n  simpler:\n\nmanpage_intro: |\n  jq(1) -- Command-line JSON processor\n  ====================================\n\n  ## SYNOPSIS\n\n  `jq` [<options>...] <filter> [<files>...]\n\n  `jq` can transform JSON in various ways, by selecting, iterating,\n  reducing and otherwise mangling JSON documents. For instance,\n  running the command `jq 'map(.price) | add'` will take an array of\n  JSON objects as input and return the sum of their \"price\" fields.\n\n  `jq` can accept text input as well, but by default, `jq` reads a\n  stream of JSON entities (including numbers and other literals) from\n  `stdin`. Whitespace is only needed to separate entities such as 1\n  and 2, and true and false.  One or more <files> may be specified, in\n  which case `jq` will read input from those instead.\n\n  The <options> are described in the [INVOKING JQ] section; they\n  mostly concern input and output formatting. The <filter> is written\n  in the jq language and specifies how to transform the input\n  file or document.\n\n  ## FILTERS\n\nmanpage_epilogue: |\n  ## BUGS\n\n  Presumably. Report them or discuss them at:\n\n      https://github.com/jqlang/jq/issues\n\n  ## AUTHOR\n\n  Stephen Dolan `<mu@netsoc.tcd.ie>`\n\nsections:\n  - title: Invoking jq\n    body: |\n\n      jq filters run on a stream of JSON data. The input to jq is\n      parsed as a sequence of whitespace-separated JSON values which\n      are passed through the provided filter one at a time. The\n      output(s) of the filter are written to standard output, as a\n      sequence of newline-separated JSON data.\n\n      Note: it is important to mind the shell's quoting rules.  As a\n      general rule it's best to always quote (with single-quote\n      characters) the jq program, as too many characters with special\n      meaning to jq are also shell meta-characters.  For example, `jq\n      \"foo\"` will fail on most Unix shells because that will be the same\n      as `jq foo`, which will generally fail because `foo is not\n      defined`.  When using the Windows command shell (cmd.exe) it's\n      best to use double quotes around your jq program when given on the\n      command-line (instead of the `-f program-file` option), but then\n      double-quotes in the jq program need backslash escaping.\n\n      You can affect how jq reads and writes its input and output\n      using some command-line options:\n\n      * `--null-input` / `-n`:\n\n        Don't read any input at all. Instead, the filter is run once\n        using `null` as the input. This is useful when using jq as a\n        simple calculator or to construct JSON data from scratch.\n\n      * `--raw-input` / `-R`:\n\n        Don't parse the input as JSON. Instead, each line of text is\n        passed to the filter as a string. If combined with `--slurp`,\n        then the entire input is passed to the filter as a single long\n        string.\n\n      * `--slurp` / `-s`:\n\n        Instead of running the filter for each JSON object in the\n        input, read the entire input stream into a large array and run\n        the filter just once.\n\n      * `--compact-output` / `-c`:\n\n        By default, jq pretty-prints JSON output. Using this option\n        will result in more compact output by instead putting each\n        JSON object on a single line.\n\n      * `--raw-output` / `-r`:\n\n        With this option, if the filter's result is a string then it\n        will be written directly to standard output rather than being\n        formatted as a JSON string with quotes. This can be useful for\n        making jq filters talk to non-JSON-based systems.\n\n      * `--join-output` / `-j`:\n\n        Like `-r` but jq won't print a newline after each output.\n\n      * `--ascii-output` / `-a`:\n\n        jq usually outputs non-ASCII Unicode codepoints as UTF-8, even\n        if the input specified them as escape sequences (like\n        \"\\u03bc\"). Using this option, you can force jq to produce pure\n        ASCII output with every non-ASCII character replaced with the\n        equivalent escape sequence.\n\n      * `--sort-keys` / `-S`:\n\n        Output the fields of each object with the keys in sorted order.\n\n      * `--color-output` / `-C` and `--monochrome-output` / `-M`:\n\n        By default, jq outputs colored JSON if writing to a\n        terminal. You can force it to produce color even if writing to\n        a pipe or a file using `-C`, and disable color with `-M`.\n\n      * `--tab`:\n\n        Use a tab for each indentation level instead of two spaces.\n\n      * `--indent n`:\n\n        Use the given number of spaces (no more than 7) for indentation.\n\n      * `--unbuffered`:\n\n        Flush the output after each JSON object is printed (useful if\n        you're piping a slow data source into jq and piping jq's\n        output elsewhere).\n\n      * `--stream`:\n\n        Parse the input in streaming fashion, outputting arrays of path\n        and leaf values (scalars and empty arrays or empty objects).\n        For example, `\"a\"` becomes `[[],\"a\"]`, and `[[],\"a\",[\"b\"]]`\n        becomes `[[0],[]]`, `[[1],\"a\"]`, and `[[2,0],\"b\"]`.\n\n        This is useful for processing very large inputs.  Use this in\n        conjunction with filtering and the `reduce` and `foreach` syntax\n        to reduce large inputs incrementally.\n\n      * `--seq`:\n\n        Use the `application/json-seq` MIME type scheme for separating\n        JSON texts in jq's input and output.  This means that an ASCII\n        RS (record separator) character is printed before each value on\n        output and an ASCII LF (line feed) is printed after every\n        output.  Input JSON texts that fail to parse are ignored (but\n        warned about), discarding all subsequent input until the next\n        RS.  This mode also parses the output of jq without the `--seq`\n        option.\n\n      * `-f filename` / `--from-file filename`:\n\n        Read filter from the file rather than from a command line, like\n        awk's -f option. You can also use '#' to make comments.\n\n      * `-L directory`:\n\n        Prepend `directory` to the search list for modules.  If this\n        option is used then no builtin search list is used.  See the\n        section on modules below.\n\n      * `--arg name value`:\n\n        This option passes a value to the jq program as a predefined\n        variable. If you run jq with `--arg foo bar`, then `$foo` is\n        available in the program and has the value `\"bar\"`. Note that\n        `value` will be treated as a string, so `--arg foo 123` will\n        bind `$foo` to `\"123\"`.\n\n      * `--argjson name JSON-text`:\n\n        This option passes a JSON-encoded value to the jq program as a\n        predefined variable. If you run jq with `--argjson foo 123`, then\n        `$foo` is available in the program and has the value `123`.\n\n      * `--slurpfile variable-name filename`:\n\n        This option reads all the JSON texts in the named file and binds\n        an array of the parsed JSON values to the given global variable.\n        If you run jq with `--slurpfile foo bar`, then `$foo` is available\n        in the program and has an array whose elements correspond to the\n        texts in the file named `bar`.\n\n      * `--argfile variable-name filename`:\n\n        Do not use.  Use `--slurpfile` instead.\n\n        (This option is like `--slurpfile`, but when the file has just\n        one text, then that is used, else an array of texts is used as\n        in `--slurpfile`.)\n\n      * `--exit-status` / `-e`:\n\n        Sets the exit status of jq to 0 if the last output value was\n        neither `false` nor `null`, 1 if the last output value was\n        either `false` or `null`, or 4 if no valid result was ever\n        produced.  Normally jq exits with 2 if there was any usage\n        problem or system error, 3 if there was a jq program compile\n        error, or 0 if the jq program ran.\n\n      * `--version` / `-V`:\n\n        Output the jq version and exit with zero.\n\n      * `--help` / `-h`:\n\n        Output the jq help and exit with zero.\n\n      * `--run-tests [filename]`:\n\n        Runs the tests in the given file or standard input.  This must\n        be the last option given and does not honor all preceding\n        options.  The input consists of comment lines, empty lines, and\n        program lines followed by one input line, as many lines of\n        output as are expected (one per output), and a terminating empty\n        line.  Compilation failure tests start with a line containing\n        only `%%FAIL`, then a line containing the program to compile,\n        then a line containing an error message to compare to the\n        actual.\n\n        Be warned that this option can change backwards-incompatibly.\n\n  - title: Basic filters\n    entries:\n      - title: \"`.`\"\n        body: |\n\n          The absolute simplest (and least interesting) filter\n          is `.`. This is a filter that takes its input and\n          produces it unchanged as output.\n\n          Since jq by default pretty-prints all output, this trivial\n          program can be a useful way of formatting JSON output from,\n          say, `curl`.\n\n        examples:\n          - program: '.'\n            input: '\"Hello, world!\"'\n            output: ['\"Hello, world!\"']\n\n      - title: \"`.foo`, `.foo.bar`\"\n        body: |\n\n          The simplest *useful* filter is `.foo`. When given a\n          JSON object (aka dictionary or hash) as input, it produces\n          the value at the key \"foo\", or null if there's none present.\n\n          If the key contains special characters or starts with a digit,\n          you need to surround it with double quotes like this: `.\"foo$\"`.\n\n          A filter of the form `.foo.bar` is equivalent to `.foo|.bar`.\n\n        examples:\n          - program: '.foo'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n          - program: '.foo'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n          - program: '.[\"foo\"]'\n            input: '{\"foo\": 42}'\n            output: ['42']\n\n      - title: \"`.foo?`\"\n        body: |\n\n          Just like `.foo`, but does not output an error when `.` is not an\n          object.\n\n        examples:\n          - program: '.foo?'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n          - program: '.foo?'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n          - program: '.[\"foo\"]?'\n            input: '{\"foo\": 42}'\n            output: ['42']\n          - program: '[.foo?]'\n            input: '[1,2]'\n            output: ['[]']\n\n      - title: \"`.[<string>]`, `.[<number>]`, `.[<number>:<number>]`\"\n        body: |\n\n          You can also look up fields of an object using syntax like\n          `.[\"foo\"]` (`.foo` above is a shorthand version of this). This\n          one works for arrays as well, if the key is an integer. Arrays\n          are zero-based, so `.[2]` returns the third element of the array.\n\n          The `.[10:15]` syntax can be used to return a subarray of an\n          array or substring of a string. The array returned by\n          `.[10:15]` will be of length 5, containing the elements from\n          index 10 (inclusive) to index 15 (exclusive). Either index may\n          be negative (in which case it counts backwards from the end of\n          the array), or omitted (in which case it refers to the start\n          or end of the array). Indices are zero-based.\n\n          The `.[2]` syntax can be used to return the element at the\n          given index.  Negative indices are allowed, with -1 referring\n          to the last element, -2 referring to the next to last element,\n          and so on.\n\n          The `.foo` syntax only works for simple keys i.e. keys that\n          are all alphanumeric characters. `.[<string>]` works with\n          keys that contain special characters such as colons and dots.\n          For example `.[\"foo::bar\"]` and `.[\"foo.bar\"]` work while\n          `.foo::bar` and `.foo.bar` would not.\n\n          The `?` \"operator\" can also be used with the slice operator,\n          as in `.[10:15]?`, which outputs values where the inputs are\n          slice-able.\n\n        examples:\n          - program: '.[0]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['{\"name\":\"JSON\", \"good\":true}']\n\n          - program: '.[2]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['null']\n\n          - program: '.[2:4]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"c\", \"d\"]']\n\n          - program: '.[2:4]'\n            input: '\"abcdefghi\"'\n            output: ['\"cd\"']\n\n          - program: '.[:3]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"a\", \"b\", \"c\"]']\n\n          - program: '.[-2:]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"d\", \"e\"]']\n\n          - program: '.[-2]'\n            input: '[1,2,3]'\n            output: ['2']\n\n      - title: \"`.[]`\"\n        body: |\n\n          If you use the `.[index]` syntax, but omit the index\n          entirely, it will return *all* of the elements of an\n          array. Running `.[]` with the input `[1,2,3]` will produce the\n          numbers as three separate results, rather than as a single\n          array. A filter of the form `.foo[]` is equivalent to\n          `.foo | .[]`.\n\n          You can also use this on an object, and it will return all\n          the values of the object.\n\n        examples:\n          - program: '.[]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output:\n              - '{\"name\":\"JSON\", \"good\":true}'\n              - '{\"name\":\"XML\", \"good\":false}'\n\n          - program: '.[]'\n            input: '[]'\n            output: []\n\n          - program: '.foo[]'\n            input: '{\"foo\":[1,2,3]}'\n            output: ['1','2','3']\n\n          - program: '.[]'\n            input: '{\"a\": 1, \"b\": 1}'\n            output: ['1', '1']\n\n      - title: \"`.[]?`\"\n        body: |\n\n          Like `.[]`, but no errors will be output if . is not an array\n          or object. A filter of the form `.foo[]?` is equivalent to\n          `.foo | .[]?`.\n\n      - title: \"`,`\"\n        body: |\n\n          If two filters are separated by a comma, then the\n          input will be fed into both and there will be multiple\n          outputs: first, all of the outputs produced by the left\n          expression, and then all of the outputs produced by the\n          right. For instance, filter `.foo, .bar`, produces\n          both the \"foo\" fields and \"bar\" fields as separate outputs.\n\n        examples:\n          - program: '.foo, .bar'\n            input: '{\"foo\": 42, \"bar\": \"something else\", \"baz\": true}'\n            output: ['42', '\"something else\"']\n\n          - program: \".user, .projects[]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['\"stedolan\"', '\"jq\"', '\"wikiflow\"']\n\n          - program: '.[4,2]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['\"e\"', '\"c\"']\n\n      - title: \"`|`\"\n        body: |\n          The | operator combines two filters by feeding the output(s) of\n          the one on the left into the input of the one on the right. It's\n          pretty much the same as the Unix shell's pipe, if you're used to\n          that.\n\n          If the one on the left produces multiple results, the one on\n          the right will be run for each of those results. So, the\n          expression `.[] | .foo` retrieves the \"foo\" field of each\n          element of the input array.\n\n        examples:\n          - program: '.[] | .name'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['\"JSON\"', '\"XML\"']\n\n  - title: Types and Values\n    body: |\n\n      jq supports the same set of datatypes as JSON - numbers,\n      strings, booleans, arrays, objects (which in JSON-speak are\n      hashes with only string keys), and \"null\".\n\n      Booleans, null, strings and numbers are written the same way as\n      in JSON. Just like everything else in jq, these simple\n      values take an input and produce an output - `42` is a valid jq\n      expression that takes an input, ignores it, and returns 42\n      instead.\n\n    entries:\n      - title: \"Array construction: `[]`\"\n        body: |\n\n          As in JSON, `[]` is used to construct arrays, as in\n          `[1,2,3]`. The elements of the arrays can be any jq\n          expression. All of the results produced by all of the\n          expressions are collected into one big array. You can use it\n          to construct an array out of a known quantity of values (as\n          in `[.foo, .bar, .baz]`) or to \"collect\" all the results of a\n          filter into an array (as in `[.items[].name]`)\n\n          Once you understand the \",\" operator, you can look at jq's array\n          syntax in a different light: the expression `[1,2,3]` is not using a\n          built-in syntax for comma-separated arrays, but is instead applying\n          the `[]` operator (collect results) to the expression 1,2,3 (which\n          produces three different results).\n\n          If you have a filter `X` that produces four results,\n          then the expression `[X]` will produce a single result, an\n          array of four elements.\n\n        examples:\n          - program: \"[.user, .projects[]]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['[\"stedolan\", \"jq\", \"wikiflow\"]']\n      - title: \"Objects: `{}`\"\n        body: |\n\n          Like JSON, `{}` is for constructing objects (aka\n          dictionaries or hashes), as in: `{\"a\": 42, \"b\": 17}`.\n\n          If the keys are \"sensible\" (all alphabetic characters), then\n          the quotes can be left off. The value can be any expression\n          (although you may need to wrap it in parentheses if it's a\n          complicated one), which gets applied to the {} expression's\n          input (remember, all filters have an input and an\n          output).\n\n              {foo: .bar}\n\n          will produce the JSON object `{\"foo\": 42}` if given the JSON\n          object `{\"bar\":42, \"baz\":43}`. You can use this to select\n          particular fields of an object: if the input is an object\n          with \"user\", \"title\", \"id\", and \"content\" fields and you\n          just want \"user\" and \"title\", you can write\n\n              {user: .user, title: .title}\n\n          Because that's so common, there's a shortcut syntax: `{user, title}`.\n\n          If one of the expressions produces multiple results,\n          multiple dictionaries will be produced. If the input's\n\n              {\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n\n          then the expression\n\n              {user, title: .titles[]}\n\n          will produce two outputs:\n\n              {\"user\":\"stedolan\", \"title\": \"JQ Primer\"}\n              {\"user\":\"stedolan\", \"title\": \"More JQ\"}\n\n          Putting parentheses around the key means it will be evaluated as an\n          expression. With the same input as above,\n\n              {(.user): .titles}\n\n          produces\n\n              {\"stedolan\": [\"JQ Primer\", \"More JQ\"]}\n\n        examples:\n          - program: '{user, title: .titles[]}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output:\n              - '{\"user\":\"stedolan\", \"title\": \"JQ Primer\"}'\n              - '{\"user\":\"stedolan\", \"title\": \"More JQ\"}'\n          - program: '{(.user): .titles}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output: ['{\"stedolan\": [\"JQ Primer\", \"More JQ\"]}']\n\n  - title: Builtin operators and functions\n    body: |\n\n      Some jq operators (for instance, `+`) do different things\n      depending on the type of their arguments (arrays, numbers,\n      etc.). However, jq never does implicit type conversions. If you\n      try to add a string to an object you'll get an error message and\n      no result.\n\n    entries:\n      - title: \"Addition: `+`\"\n        body: |\n\n          The operator `+` takes two filters, applies them both\n          to the same input, and adds the results together. What\n          \"adding\" means depends on the types involved:\n\n          - **Numbers** are added by normal arithmetic.\n\n          - **Arrays** are added by being concatenated into a larger array.\n\n          - **Strings** are added by being joined into a larger string.\n\n          - **Objects** are added by merging, that is, inserting all\n              the key-value pairs from both objects into a single\n              combined object. If both objects contain a value for the\n              same key, the object on the right of the `+` wins. (For\n              recursive merge use the `*` operator.)\n\n          `null` can be added to any value, and returns the other\n          value unchanged.\n\n        examples:\n          - program: '.a + 1'\n            input: '{\"a\": 7}'\n            output: ['8']\n          - program: '.a + .b'\n            input: '{\"a\": [1,2], \"b\": [3,4]}'\n            output: ['[1,2,3,4]']\n          - program: '.a + null'\n            input: '{\"a\": 1}'\n            output: ['1']\n          - program: '.a + 1'\n            input: '{}'\n            output: ['1']\n          - program: '{a: 1} + {b: 2} + {c: 3} + {a: 42}'\n            input: 'null'\n            output: ['{\"a\": 42, \"b\": 2, \"c\": 3}']\n\n      - title: \"Subtraction: `-`\"\n        body: |\n\n          As well as normal arithmetic subtraction on numbers, the `-`\n          operator can be used on arrays to remove all occurrences of\n          the second array's elements from the first array.\n\n        examples:\n          - program: '4 - .a'\n            input: '{\"a\":3}'\n            output: ['1']\n          - program: . - [\"xml\", \"yaml\"]\n            input: '[\"xml\", \"yaml\", \"json\"]'\n            output: ['[\"json\"]']\n\n      - title: \"Multiplication, division, modulo: `*`, `/`, `%`\"\n        body: |\n\n          These infix operators behave as expected when given two numbers.\n          Division by zero raises an error. `x % y` computes x modulo y.\n\n          Multiplying a string by a number produces the concatenation of\n          that string that many times. `\"x\" * 0` produces **null**.\n\n          Dividing a string by another splits the first using the second\n          as separators.\n\n          Multiplying two objects will merge them recursively: this works\n          like addition but if both objects contain a value for the\n          same key, and the values are objects, the two are merged with\n          the same strategy.\n\n        examples:\n          - program: '10 / . * 3'\n            input: '5'\n            output: ['6']\n          - program: '. / \", \"'\n            input: '\"a, b,c,d, e\"'\n            output: ['[\"a\",\"b,c,d\",\"e\"]']\n          - program: '{\"k\": {\"a\": 1, \"b\": 2}} * {\"k\": {\"a\": 0,\"c\": 3}}'\n            input: 'null'\n            output: ['{\"k\": {\"a\": 0, \"b\": 2, \"c\": 3}}']\n          - program: '.[] | (1 / .)?'\n            input: '[1,0,-1]'\n            output: ['1', '-1']\n\n\n      - title: \"`length`\"\n        body: |\n\n          The builtin function `length` gets the length of various\n          different types of value:\n\n          - The length of a **string** is the number of Unicode\n            codepoints it contains (which will be the same as its\n            JSON-encoded length in bytes if it's pure ASCII).\n\n          - The length of an **array** is the number of elements.\n\n          - The length of an **object** is the number of key-value pairs.\n\n          - The length of **null** is zero.\n\n        examples:\n          - program: '.[] | length'\n            input: '[[1,2], \"string\", {\"a\":2}, null]'\n            output: ['2', '6', '1', '0']\n\n      - title: \"`keys`, `keys_unsorted`\"\n        body: |\n\n          The builtin function `keys`, when given an object, returns\n          its keys in an array.\n\n          The keys are sorted \"alphabetically\", by unicode codepoint\n          order. This is not an order that makes particular sense in\n          any particular language, but you can count on it being the\n          same for any two objects with the same set of keys,\n          regardless of locale settings.\n\n          When `keys` is given an array, it returns the valid indices\n          for that array: the integers from 0 to length-1.\n\n          The `keys_unsorted` function is just like `keys`, but if\n          the input is an object then the keys will not be sorted,\n          instead the keys will roughly be in insertion order.\n\n        examples:\n          - program: 'keys'\n            input: '{\"abc\": 1, \"abcd\": 2, \"Foo\": 3}'\n            output: ['[\"Foo\", \"abc\", \"abcd\"]']\n          - program: 'keys'\n            input: '[42,3,35]'\n            output: ['[0,1,2]']\n\n      - title: \"`has(key)`\"\n        body: |\n\n          The builtin function `has` returns whether the input object\n          has the given key, or the input array has an element at the\n          given index.\n\n          `has($key)` has the same effect as checking whether `$key`\n          is a member of the array returned by `keys`, although `has`\n          will be faster.\n\n        examples:\n          - program: 'map(has(\"foo\"))'\n            input: '[{\"foo\": 42}, {}]'\n            output: ['[true, false]']\n          - program: 'map(has(2))'\n            input: '[[0,1], [\"a\",\"b\",\"c\"]]'\n            output: ['[false, true]']\n\n      - title: \"`in`\"\n        body: |\n\n          The builtin function `in` returns whether or not the input key is in the\n          given object, or the input index corresponds to an element\n          in the given array. It is, essentially, an inversed version\n          of `has`.\n\n        examples:\n          - program: '.[] | in({\"foo\": 42})'\n            input: '[\"foo\", \"bar\"]'\n            output: ['true', 'false']\n          - program: 'map(in([0,1]))'\n            input: '[2, 0]'\n            output: ['[false, true]']\n\n      - title: \"`path(path_expression)`\"\n        body: |\n\n          Outputs array representations of the given path expression\n          in `.`.  The outputs are arrays of strings (object keys)\n          and/or numbers (array indices).\n\n          Path expressions are jq expressions like `.a`, but also `.[]`.\n          There are two types of path expressions: ones that can match\n          exactly, and ones that cannot.  For example, `.a.b.c` is an\n          exact match path expression, while `.a[].b` is not.\n\n          `path(exact_path_expression)` will produce the array\n          representation of the path expression even if it does not\n          exist in `.`, if `.` is `null` or an array or an object.\n\n          `path(pattern)` will produce array representations of the\n          paths matching `pattern` if the paths exist in `.`.\n\n          Note that the path expressions are not different from normal\n          expressions.  The expression\n          `path(..|select(type==\"boolean\"))` outputs all the paths to\n          boolean values in `.`, and only those paths.\n\n        examples:\n          - program: 'path(.a[0].b)'\n            input: 'null'\n            output: ['[\"a\",0,\"b\"]']\n          - program: '[path(..)]'\n            input: '{\"a\":[{\"b\":1}]}'\n            output: ['[[],[\"a\"],[\"a\",0],[\"a\",0,\"b\"]]']\n\n      - title: \"`del(path_expression)`\"\n        body: |\n\n          The builtin function `del` removes a key and its corresponding\n          value from an object.\n\n        examples:\n          - program: 'del(.foo)'\n            input: '{\"foo\": 42, \"bar\": 9001, \"baz\": 42}'\n            output: ['{\"bar\": 9001, \"baz\": 42}']\n          - program: 'del(.[1, 2])'\n            input: '[\"foo\", \"bar\", \"baz\"]'\n            output: ['[\"foo\"]']\n\n      - title: \"`to_entries`, `from_entries`, `with_entries(f)`\"\n        body: |\n\n          These functions convert between an object and an array of\n          key-value pairs. If `to_entries` is passed an object, then\n          for each `k: v` entry in the input, the output array\n          includes `{\"key\": k, \"value\": v}`.\n\n          `from_entries` does the opposite conversion, and\n          `with_entries(f)` is a shorthand for `to_entries | map(f) |\n          from_entries`, useful for doing some operation to all keys\n          and values of an object. `from_entries` accepts `\"key\"`,\n          `\"Key\"`, `\"Name\"`, `\"value\"`, and `\"Value\"` as keys.\n\n        examples:\n          - program: 'to_entries'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]']\n          - program: 'from_entries'\n            input: '[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]'\n            output: ['{\"a\": 1, \"b\": 2}']\n          - program: 'with_entries(.key |= \"KEY_\" + .)'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['{\"KEY_a\": 1, \"KEY_b\": 2}']\n\n\n      - title: \"`select(boolean_expression)`\"\n        body: |\n\n          The function `select(f)` produces its input unchanged if\n          `f` returns true for that input, and produces no output\n          otherwise.\n\n          It's useful for filtering lists: `[1,2,3] | map(select(. >= 2))`\n          will give you `[2,3]`.\n\n        examples:\n          - program: 'map(select(. >= 2))'\n            input: '[1,5,3,0,7]'\n            output: ['[5,3,7]']\n          - program: '.[] | select(.id == \"second\")'\n            input: '[{\"id\": \"first\", \"val\": 1}, {\"id\": \"second\", \"val\": 2}]'\n            output: ['{\"id\": \"second\", \"val\": 2}']\n\n\n      - title: \"`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `normals`, `finites`, `strings`, `nulls`, `values`, `scalars`\"\n        body: |\n\n          These built-ins select only inputs that are arrays, objects,\n          iterables (arrays or objects), booleans, numbers, normal\n          numbers, finite numbers, strings, null, non-null values, and\n          non-iterables, respectively.\n\n        examples:\n          - program: '.[]|numbers'\n            input: '[[],{},1,\"foo\",null,true,false]'\n            output: ['1']\n\n      - title: \"`empty`\"\n        body: |\n\n          `empty` returns no results. None at all. Not even `null`.\n\n          It's useful on occasion. You'll know if you need it :)\n\n        examples:\n          - program: '1, empty, 2'\n            input: 'null'\n            output: ['1', '2']\n          - program: '[1,2,empty,3]'\n            input: 'null'\n            output: ['[1,2,3]']\n\n      - title: \"`error`, `error(message)`\"\n        body: |\n\n          Produces an error with the input value, or with the message\n          given as the argument. Errors can be caught with try/catch;\n          see below.\n\n          When the error value is `null`, it produces nothing and works\n          just like `empty`. So `[null | error]` and `[error(null)]` both\n          emit `[]`.\n\n        examples:\n          - program: 'try error catch .'\n            input: '\"error message\"'\n            output: ['\"error message\"']\n\n          - program: 'try error(\"invalid value: \\(.)\") catch .'\n            input: '42'\n            output: ['\"invalid value: 42\"']\n\n      - title: \"`$__loc__`\"\n        body: |\n\n          Produces an object with a \"file\" key and a \"line\" key, with\n          the filename and line number where `$__loc__` occurs, as\n          values.\n\n        examples:\n          - program: 'try error(\"\\($__loc__)\") catch .'\n            input: 'null'\n            output: ['\"{\\\"file\\\":\\\"<top-level>\\\",\\\"line\\\":1}\"']\n\n      - title: \"`map(f)`, `map_values(f)`\"\n        body: |\n\n          For any filter `f`, `map(f)` will run that filter for each\n          element of the input array, and return the outputs in a new\n          array. `map(.+1)` will increment each element of an array of numbers.\n\n          Similarly, `map_values(f)` will run that filter for each element,\n          but it will return an object when an object is passed.\n\n          `map(f)` is equivalent to `[.[] | f]`. In fact, this is how\n          it's defined. Similarly, `map_values(f)` is defined as `.[] |= f`.\n\n        examples:\n          - program: 'map(.+1)'\n            input: '[1,2,3]'\n            output: ['[2,3,4]']\n\n          - program: 'map_values(.+1)'\n            input: '{\"a\": 1, \"b\": 2, \"c\": 3}'\n            output: ['{\"a\": 2, \"b\": 3, \"c\": 4}']\n\n      - title: \"`paths`, `paths(node_filter)`, `leaf_paths`\"\n        body: |\n\n          `paths` outputs the paths to all the elements in its input\n          (except it does not output the empty list, representing .\n          itself).\n\n          `paths(f)` outputs the paths to any values for which `f` is `true`.\n          That is, `paths(type == \"number\")` outputs the paths to all numeric\n          values.\n\n          `leaf_paths` is an alias of `paths(scalars)`; `leaf_paths` is\n          *deprecated* and will be removed in the next major release.\n\n        examples:\n          - program: '[paths]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1],[1,0],[1,1],[1,1,\"a\"]]']\n          - program: '[paths(type == \"number\")]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1,1,\"a\"]]']\n\n      - title: \"`add`\"\n        body: |\n\n          The filter `add` takes as input an array, and produces as\n          output the elements of the array added together. This might\n          mean summed, concatenated or merged depending on the types\n          of the elements of the input array - the rules are the same\n          as those for the `+` operator (described above).\n\n          If the input is an empty array, `add` returns `null`.\n\n        examples:\n          - program: add\n            input: '[\"a\",\"b\",\"c\"]'\n            output: ['\"abc\"']\n          - program: add\n            input: '[1, 2, 3]'\n            output: ['6']\n          - program: add\n            input: '[]'\n            output: [\"null\"]\n\n      - title: \"`any`, `any(condition)`, `any(generator; condition)`\"\n        body: |\n\n          The filter `any` takes as input an array of boolean values,\n          and produces `true` as output if any of the elements of\n          the array are `true`.\n\n          If the input is an empty array, `any` returns `false`.\n\n          The `any(condition)` form applies the given condition to the\n          elements of the input array.\n\n          The `any(generator; condition)` form applies the given\n          condition to all the outputs of the given generator.\n\n        examples:\n          - program: any\n            input: '[true, false]'\n            output: [\"true\"]\n          - program: any\n            input: '[false, false]'\n            output: [\"false\"]\n          - program: any\n            input: '[]'\n            output: [\"false\"]\n\n      - title: \"`all`, `all(condition)`, `all(generator; condition)`\"\n        body: |\n\n          The filter `all` takes as input an array of boolean values,\n          and produces `true` as output if all of the elements of\n          the array are `true`.\n\n          The `all(condition)` form applies the given condition to the\n          elements of the input array.\n\n          The `all(generator; condition)` form applies the given\n          condition to all the outputs of the given generator.\n\n          If the input is an empty array, `all` returns `true`.\n\n        examples:\n          - program: all\n            input: '[true, false]'\n            output: [\"false\"]\n          - program: all\n            input: '[true, true]'\n            output: [\"true\"]\n          - program: all\n            input: '[]'\n            output: [\"true\"]\n\n      - title: \"`flatten`, `flatten(depth)`\"\n        body: |\n\n          The filter `flatten` takes as input an array of nested arrays,\n          and produces a flat array in which all arrays inside the original\n          array have been recursively replaced by their values. You can pass\n          an argument to it to specify how many levels of nesting to flatten.\n\n          `flatten(2)` is like `flatten`, but going only up to two\n          levels deep.\n\n        examples:\n          - program: flatten\n            input: '[1, [2], [[3]]]'\n            output: [\"[1, 2, 3]\"]\n          - program: flatten(1)\n            input: '[1, [2], [[3]]]'\n            output: [\"[1, 2, [3]]\"]\n          - program: flatten\n            input: '[[]]'\n            output: [\"[]\"]\n          - program: flatten\n            input: '[{\"foo\": \"bar\"}, [{\"foo\": \"baz\"}]]'\n            output: ['[{\"foo\": \"bar\"}, {\"foo\": \"baz\"}]']\n\n      - title: \"`range(upto)`, `range(from; upto)`, `range(from; upto; by)`\"\n        body: |\n\n          The `range` function produces a range of numbers. `range(4; 10)`\n          produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers\n          are produced as separate outputs. Use `[range(4; 10)]` to get a range as\n          an array.\n\n          The one argument form generates numbers from 0 to the given\n          number, with an increment of 1.\n\n          The two argument form generates numbers from `from` to `upto`\n          with an increment of 1.\n\n          The three argument form generates numbers `from` to `upto`\n          with an increment of `by`.\n\n        examples:\n          - program: 'range(2; 4)'\n            input: 'null'\n            output: ['2', '3']\n          - program: '[range(2; 4)]'\n            input: 'null'\n            output: ['[2,3]']\n          - program: '[range(4)]'\n            input: 'null'\n            output: ['[0,1,2,3]']\n          - program: '[range(0; 10; 3)]'\n            input: 'null'\n            output: ['[0,3,6,9]']\n          - program: '[range(0; 10; -1)]'\n            input: 'null'\n            output: ['[]']\n          - program: '[range(0; -5; -1)]'\n            input: 'null'\n            output: ['[0,-1,-2,-3,-4]']\n\n      - title: \"`floor`\"\n        body: |\n\n          The `floor` function returns the floor of its numeric input.\n\n        examples:\n          - program: 'floor'\n            input: '3.14159'\n            output: ['3']\n\n      - title: \"`sqrt`\"\n        body: |\n\n          The `sqrt` function returns the square root of its numeric input.\n\n        examples:\n          - program: 'sqrt'\n            input: '9'\n            output: ['3']\n\n      - title: \"`tonumber`\"\n        body: |\n\n          The `tonumber` function parses its input as a number. It\n          will convert correctly-formatted strings to their numeric\n          equivalent, leave numbers alone, and give an error on all other input.\n\n        examples:\n          - program: '.[] | tonumber'\n            input: '[1, \"1\"]'\n            output: ['1', '1']\n\n      - title: \"`tostring`\"\n        body: |\n\n          The `tostring` function prints its input as a\n          string. Strings are left unchanged, and all other values are\n          JSON-encoded.\n\n        examples:\n          - program: '.[] | tostring'\n            input: '[1, \"1\", [1]]'\n            output: ['\"1\"', '\"1\"', '\"[1]\"']\n\n      - title: \"`type`\"\n        body: |\n\n          The `type` function returns the type of its argument as a\n          string, which is one of null, boolean, number, string, array\n          or object.\n\n        examples:\n          - program: 'map(type)'\n            input: '[0, false, [], {}, null, \"hello\"]'\n            output: ['[\"number\", \"boolean\", \"array\", \"object\", \"null\", \"string\"]']\n\n      - title: \"`infinite`, `nan`, `isinfinite`, `isnan`, `isfinite`, `isnormal`\"\n        body: |\n\n          Some arithmetic operations can yield infinities and \"not a\n          number\" (NaN) values.  The `isinfinite` builtin returns `true`\n          if its input is infinite.  The `isnan` builtin returns `true`\n          if its input is a NaN.  The `infinite` builtin returns a\n          positive infinite value.  The `nan` builtin returns a NaN.\n          The `isnormal` builtin returns true if its input is a normal\n          number.\n\n          Note that division by zero raises an error.\n\n          Currently most arithmetic operations operating on infinities,\n          NaNs, and sub-normals do not raise errors.\n\n        examples:\n          - program: '.[] | (infinite * .) < 0'\n            input: '[-1, 1]'\n            output: ['true', 'false']\n          - program: 'infinite, nan | type'\n            input: 'null'\n            output: ['\"number\"', '\"number\"']\n\n      - title: \"`sort`, `sort_by(path_expression)`\"\n        body: |\n\n          The `sort` functions sorts its input, which must be an\n          array. Values are sorted in the following order:\n\n          * `null`\n          * `false`\n          * `true`\n          * numbers\n          * strings, in alphabetical order (by unicode codepoint value)\n          * arrays, in lexical order\n          * objects\n\n          The ordering for objects is a little complex: first they're\n          compared by comparing their sets of keys (as arrays in\n          sorted order), and if their keys are equal then the values\n          are compared key by key.\n\n          `sort_by` may be used to sort by a particular field of an\n          object, or by applying any jq filter. `sort_by(f)` compares\n          two elements by comparing the result of `f` on each element.\n          When `f` produces multiple values, it firstly compares the\n          first values, and the second values if the first values are\n          equal, and so on.\n\n        examples:\n          - program: 'sort'\n            input: '[8,3,null,6]'\n            output: ['[null,3,6,8]']\n\n          - program: 'sort_by(.foo)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":10}, {\"foo\":2, \"bar\":1}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":4, \"bar\":10}]']\n\n          - program: 'sort_by(.foo, .bar)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":4, \"bar\":10}]']\n\n      - title: \"`group_by(path_expression)`\"\n        body: |\n\n          `group_by(.foo)` takes as input an array, groups the\n          elements having the same `.foo` field into separate arrays,\n          and produces all of these arrays as elements of a larger\n          array, sorted by the value of the `.foo` field.\n\n          Any jq expression, not just a field access, may be used in\n          place of `.foo`. The sorting order is the same as described\n          in the `sort` function above.\n\n        examples:\n          - program: 'group_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":10}, {\"foo\":3, \"bar\":100}, {\"foo\":1, \"bar\":1}]'\n            output: ['[[{\"foo\":1, \"bar\":10}, {\"foo\":1, \"bar\":1}], [{\"foo\":3, \"bar\":100}]]']\n\n      - title: \"`min`, `max`, `min_by(path_exp)`, `max_by(path_exp)`\"\n        body: |\n\n          Find the minimum or maximum element of the input array.\n\n          The `min_by(path_exp)` and `max_by(path_exp)` functions allow\n          you to specify a particular field or property to examine, e.g.\n          `min_by(.foo)` finds the object with the smallest `foo` field.\n\n        examples:\n          - program: 'min'\n            input: '[5,4,2,7]'\n            output: ['2']\n          - program: 'max_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":14}, {\"foo\":2, \"bar\":3}]'\n            output: ['{\"foo\":2, \"bar\":3}']\n\n      - title: \"`unique`, `unique_by(path_exp)`\"\n        body: |\n\n          The `unique` function takes as input an array and produces\n          an array of the same elements, in sorted order, with\n          duplicates removed.\n\n          The `unique_by(path_exp)` function will keep only one element\n          for each value obtained by applying the argument. Think of it\n          as making an array by taking one element out of every group\n          produced by `group`.\n\n        examples:\n          - program: 'unique'\n            input: '[1,2,5,3,5,3,1,3]'\n            output: ['[1,2,3,5]']\n          - program: 'unique_by(.foo)'\n            input: '[{\"foo\": 1, \"bar\": 2}, {\"foo\": 1, \"bar\": 3}, {\"foo\": 4, \"bar\": 5}]'\n            output: ['[{\"foo\": 1, \"bar\": 2}, {\"foo\": 4, \"bar\": 5}]']\n          - program: 'unique_by(length)'\n            input: '[\"chunky\", \"bacon\", \"kitten\", \"cicada\", \"asparagus\"]'\n            output: ['[\"bacon\", \"chunky\", \"asparagus\"]']\n\n      - title: \"`reverse`\"\n        body: |\n\n          This function reverses an array.\n\n        examples:\n          - program: 'reverse'\n            input: '[1,2,3,4]'\n            output: ['[4,3,2,1]']\n\n      - title: \"`contains(element)`\"\n        body: |\n\n          The filter `contains(b)` will produce true if b is\n          completely contained within the input. A string B is\n          contained in a string A if B is a substring of A. An array B\n          is contained in an array A if all elements in B are\n          contained in any element in A. An object B is contained in\n          object A if all of the values in B are contained in the\n          value in A with the same key. All other types are assumed to\n          be contained in each other if they are equal.\n\n        examples:\n          - program: 'contains(\"bar\")'\n            input: '\"foobar\"'\n            output: ['true']\n          - program: 'contains([\"baz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['true']\n          - program: 'contains([\"bazzzzz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['false']\n          - program: 'contains({foo: 12, bar: [{barp: 12}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['true']\n          - program: 'contains({foo: 12, bar: [{barp: 15}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['false']\n\n      - title: \"`indices(s)`\"\n        body: |\n\n          Outputs an array containing the indices in `.` where `s`\n          occurs.  The input may be an array, in which case if `s` is an\n          array then the indices output will be those where all elements\n          in `.` match those of `s`.\n\n        examples:\n          - program: 'indices(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['[3,7,12]']\n          - program: 'indices(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['[1,3,5]']\n          - program: 'indices([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['[1,8]']\n\n      - title: \"`index(s)`, `rindex(s)`\"\n        body: |\n\n          Outputs the index of the first (`index`) or last (`rindex`)\n          occurrence of `s` in the input.\n\n        examples:\n          - program: 'index(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['3']\n          - program: 'index(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['1']\n          - program: 'index([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['1']\n          - program: 'rindex(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['12']\n          - program: 'rindex(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['5']\n          - program: 'rindex([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['8']\n\n      - title: \"`inside`\"\n        body: |\n\n          The filter `inside(b)` will produce true if the input is\n          completely contained within b. It is, essentially, an\n          inversed version of `contains`.\n\n        examples:\n          - program: 'inside(\"foobar\")'\n            input: '\"bar\"'\n            output: ['true']\n          - program: 'inside([\"foobar\", \"foobaz\", \"blarp\"])'\n            input: '[\"baz\", \"bar\"]'\n            output: ['true']\n          - program: 'inside([\"foobar\", \"foobaz\", \"blarp\"])'\n            input: '[\"bazzzzz\", \"bar\"]'\n            output: ['false']\n          - program: 'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})'\n            input: '{\"foo\": 12, \"bar\": [{\"barp\": 12}]}'\n            output: ['true']\n          - program: 'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})'\n            input: '{\"foo\": 12, \"bar\": [{\"barp\": 15}]}'\n            output: ['false']\n\n      - title: \"`startswith(str)`\"\n        body: |\n\n          Outputs `true` if . starts with the given string argument.\n\n        examples:\n          - program: '[.[]|startswith(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"barfoob\"]'\n            output: ['[false, true, false, true, false]']\n\n      - title: \"`endswith(str)`\"\n        body: |\n\n          Outputs `true` if . ends with the given string argument.\n\n        examples:\n          - program: '[.[]|endswith(\"foo\")]'\n            input: '[\"foobar\", \"barfoo\"]'\n            output: ['[false, true]']\n\n      - title: \"`combinations`, `combinations(n)`\"\n        body: |\n\n          Outputs all combinations of the elements of the arrays in the\n          input array. If given an argument `n`, it outputs all combinations\n          of `n` repetitions of the input array.\n\n        examples:\n          - program: 'combinations'\n            input: '[[1,2], [3, 4]]'\n            output: ['[1, 3]', '[1, 4]', '[2, 3]', '[2, 4]']\n          - program: 'combinations(2)'\n            input: '[0, 1]'\n            output: ['[0, 0]', '[0, 1]', '[1, 0]', '[1, 1]']\n\n      - title: \"`ltrimstr(str)`\"\n        body: |\n\n          Outputs its input with the given prefix string removed, if it\n          starts with it.\n\n        examples:\n          - program: '[.[]|ltrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"afoo\"]'\n            output: ['[\"fo\",\"\",\"barfoo\",\"bar\",\"afoo\"]']\n\n      - title: \"`rtrimstr(str)`\"\n        body: |\n\n          Outputs its input with the given suffix string removed, if it\n          ends with it.\n\n        examples:\n          - program: '[.[]|rtrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"foob\"]'\n            output: ['[\"fo\",\"\",\"bar\",\"foobar\",\"foob\"]']\n\n      - title: \"`explode`\"\n        body: |\n\n          Converts an input string into an array of the string's\n          codepoint numbers.\n\n        examples:\n          - program: 'explode'\n            input: '\"foobar\"'\n            output: ['[102,111,111,98,97,114]']\n\n      - title: \"`implode`\"\n        body: |\n\n          The inverse of explode.\n\n        examples:\n          - program: 'implode'\n            input: '[65, 66, 67]'\n            output: ['\"ABC\"']\n\n      - title: \"`split`\"\n        body: |\n\n          Splits an input string on the separator argument.\n\n        examples:\n          - program: 'split(\", \")'\n            input: '\"a, b,c,d, e, \"'\n            output: ['[\"a\",\"b,c,d\",\"e\",\"\"]']\n\n      - title: \"`join(str)`\"\n        body: |\n\n          Joins the array of elements given as input, using the\n          argument as separator. It is the inverse of `split`: that is,\n          running `split(\"foo\") | join(\"foo\")` over any input string\n          returns said input string.\n\n        examples:\n          - program: 'join(\", \")'\n            input: '[\"a\",\"b,c,d\",\"e\"]'\n            output: ['\"a, b,c,d, e\"']\n\n\n      - title: \"`ascii_downcase`, `ascii_upcase`\"\n        body: |\n\n          Emit a copy of the input string with its alphabetic characters (a-z and A-Z)\n          converted to the specified case.\n\n        examples:\n          - program: 'ascii_upcase'\n            input: '\"useful but not for é\"'\n            output: ['\"USEFUL BUT NOT FOR é\"']\n\n      - title: \"`while(cond; update)`\"\n        body: |\n\n          The `while(cond; update)` function allows you to repeatedly\n          apply an update to `.` until `cond` is false.\n\n          Note that `while(cond; update)` is internally defined as a\n          recursive jq function.  Recursive calls within `while` will\n          not consume additional memory if `update` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[while(.<100; .*2)]'\n            input: '1'\n            output: ['[1,2,4,8,16,32,64]']\n\n      - title: \"`until(cond; next)`\"\n        body: |\n\n          The `until(cond; next)` function allows you to repeatedly\n          apply the expression `next`, initially to `.` then to its own\n          output, until `cond` is true.  For example, this can be used\n          to implement a factorial function (see below).\n\n          Note that `until(cond; next)` is internally defined as a\n          recursive jq function.  Recursive calls within `until()` will\n          not consume additional memory if `next` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]'\n            input: '4'\n            output: ['24']\n\n\n      - title: \"`recurse(f)`, `recurse`, `recurse(f; condition)`, `recurse_down`\"\n        body: |\n\n          The `recurse(f)` function allows you to search through a\n          recursive structure, and extract interesting data from all\n          levels. Suppose your input represents a filesystem:\n\n              {\"name\": \"/\", \"children\": [\n                {\"name\": \"/bin\", \"children\": [\n                  {\"name\": \"/bin/ls\", \"children\": []},\n                  {\"name\": \"/bin/sh\", \"children\": []}]},\n                {\"name\": \"/home\", \"children\": [\n                  {\"name\": \"/home/stephen\", \"children\": [\n                    {\"name\": \"/home/stephen/jq\", \"children\": []}]}]}]}\n\n          Now suppose you want to extract all of the filenames\n          present. You need to retrieve `.name`, `.children[].name`,\n          `.children[].children[].name`, and so on. You can do this\n          with:\n\n              recurse(.children[]) | .name\n\n          When called without an argument, `recurse` is equivalent to\n          `recurse(.[]?)`.\n\n          `recurse(f)` is identical to `recurse(f; . != null)` and can be\n          used without concerns about recursion depth.\n\n          `recurse(f; condition)` is a generator which begins by\n          emitting . and then emits in turn .|f, .|f|f, .|f|f|f, ...  so long\n          as the computed value satisfies the condition. For example,\n          to generate all the integers, at least in principle, one\n          could write `recurse(.+1; true)`.\n\n          For legacy reasons, `recurse_down` exists as an alias to\n          calling `recurse` without arguments. This alias is considered\n          *deprecated* and will be removed in the next major release.\n\n          The recursive calls in `recurse` will not consume additional\n          memory whenever `f` produces at most a single output for each\n          input.\n\n        examples:\n          - program: 'recurse(.foo[])'\n            input: '{\"foo\":[{\"foo\": []}, {\"foo\":[{\"foo\":[]}]}]}'\n            output:\n              - '{\"foo\":[{\"foo\":[]},{\"foo\":[{\"foo\":[]}]}]}'\n              - '{\"foo\":[]}'\n              - '{\"foo\":[{\"foo\":[]}]}'\n              - '{\"foo\":[]}'\n\n          - program: 'recurse'\n            input: '{\"a\":0,\"b\":[1]}'\n            output:\n              - '{\"a\":0,\"b\":[1]}'\n              - '0'\n              - '[1]'\n              - '1'\n\n          - program: 'recurse(. * .; . < 20)'\n            input: '2'\n            output: ['2', '4', '16']\n\n      - title: \"`..`\"\n        body: |\n\n          Short-hand for `recurse` without arguments.  This is intended\n          to resemble the XPath `//` operator.  Note that `..a` does not\n          work; use `..|a` instead.  In the example below we use\n          `..|.a?` to find all the values of object keys \"a\" in any\n          object found \"below\" `.`.\n\n        examples:\n          - program: '..|.a?'\n            input: '[[{\"a\":1}]]'\n            output: ['1']\n\n      - title: \"`env`\"\n        body: |\n\n          Outputs an object representing jq's environment.\n\n        examples:\n          - program: 'env.PAGER'\n            input: 'null'\n            output: ['\"less\"']\n\n      - title: \"`transpose`\"\n        body: |\n\n          Transpose a possibly jagged matrix (an array of arrays).\n          Rows are padded with nulls so the result is always rectangular.\n\n        examples:\n          - program: 'transpose'\n            input: '[[1], [2,3]]'\n            output: ['[[1,2],[null,3]]']\n\n      - title: \"`bsearch(x)`\"\n        body: |\n\n          `bsearch(x)` conducts a binary search for x in the input\n          array.  If the input is sorted and contains x, then\n          `bsearch(x)` will return its index in the array; otherwise, if\n          the array is sorted, it will return (-1 - ix) where ix is an\n          insertion point such that the array would still be sorted\n          after the insertion of x at ix.  If the array is not sorted,\n          `bsearch(x)` will return an integer that is probably of no\n          interest.\n\n        examples:\n          - program: 'bsearch(0)'\n            input: '[0,1]'\n            output: ['0']\n          - program: 'bsearch(0)'\n            input: '[1,2,3]'\n            output: ['-1']\n          - program: 'bsearch(4) as $ix | if $ix < 0 then .[-(1+$ix)] = 4 else . end'\n            input: '[1,2,3]'\n            output: ['[1,2,3,4]']\n\n      - title: \"String interpolation: `\\\\(exp)`\"\n        body: |\n\n          Inside a string, you can put an expression inside parens\n          after a backslash. Whatever the expression returns will be\n          interpolated into the string.\n\n        examples:\n          - program: '\"The input was \\(.), which is one less than \\(.+1)\"'\n            input: '42'\n            output: ['\"The input was 42, which is one less than 43\"']\n\n      - title: \"Convert to/from JSON\"\n        body: |\n\n          The `tojson` and `fromjson` builtins dump values as JSON texts\n          or parse JSON texts into values, respectively.  The tojson\n          builtin differs from tostring in that tostring returns strings\n          unmodified, while tojson encodes strings as JSON strings.\n\n        examples:\n          - program: '[.[]|tostring]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"foo\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"\\\"foo\\\"\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson|fromjson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[1,\"foo\",[\"foo\"]]']\n\n      - title: \"Format strings and escaping\"\n        body: |\n\n          The `@foo` syntax is used to format and escape strings,\n          which is useful for building URLs, documents in a language\n          like HTML or XML, and so forth. `@foo` can be used as a\n          filter on its own, the possible escapings are:\n\n          * `@text`:\n\n            Calls `tostring`, see that function for details.\n\n          * `@json`:\n\n            Serializes the input as JSON.\n\n          * `@html`:\n\n            Applies HTML/XML escaping, by mapping the characters\n            `<>&'\"` to their entity equivalents `&lt;`, `&gt;`,\n            `&amp;`, `&apos;`, `&quot;`.\n\n          * `@uri`:\n\n            Applies percent-encoding, by mapping all reserved URI\n            characters to a `%XX` sequence.\n\n          * `@csv`:\n\n            The input must be an array, and it is rendered as CSV\n            with double quotes for strings, and quotes escaped by\n            repetition.\n\n          * `@tsv`:\n\n            The input must be an array, and it is rendered as TSV\n            (tab-separated values). Each input array will be printed as\n            a single line. Fields are separated by a single\n            tab (ascii `0x09`). Input characters line-feed (ascii `0x0a`),\n            carriage-return (ascii `0x0d`), tab (ascii `0x09`) and\n            backslash (ascii `0x5c`) will be output as escape sequences\n            `\\n`, `\\r`, `\\t`, `\\\\` respectively.\n\n          * `@sh`:\n\n            The input is escaped suitable for use in a command-line\n            for a POSIX shell. If the input is an array, the output\n            will be a series of space-separated strings.\n\n          * `@base64`:\n\n            The input is converted to base64 as specified by RFC 4648.\n\n          This syntax can be combined with string interpolation in a\n          useful way. You can follow a `@foo` token with a string\n          literal. The contents of the string literal will *not* be\n          escaped. However, all interpolations made inside that string\n          literal will be escaped. For instance,\n\n              @uri \"https://www.google.com/search?q=\\(.search)\"\n\n          will produce the following output for the input\n          `{\"search\":\"what is jq?\"}`:\n\n              \"https://www.google.com/search?q=what%20is%20jq%3F\"\n\n          Note that the slashes, question mark, etc. in the URL are\n          not escaped, as they were part of the string literal.\n\n        examples:\n          - program: '@html'\n            input: '\"This works if x < y\"'\n            output: ['\"This works if x &lt; y\"']\n\n          - program: '@sh \"echo \\(.)\"'\n            input: \"\\\"O'Hara's Ale\\\"\"\n            output: [\"\\\"echo 'O'\\\\\\\\''Hara'\\\\\\\\''s Ale'\\\"\"]\n\n      - title: \"Dates\"\n        body: |\n\n          jq provides some basic date handling functionality, with some\n          high-level and low-level builtins.  In all cases these\n          builtins deal exclusively with time in UTC.\n\n          The `fromdateiso8601` builtin parses datetimes in the ISO 8601\n          format to a number of seconds since the Unix epoch\n          (1970-01-01T00:00:00Z).  The `todateiso8601` builtin does the\n          inverse.\n\n          The `fromdate` builtin parses datetime strings.  Currently\n          `fromdate` only supports ISO 8601 datetime strings, but in the\n          future it will attempt to parse datetime strings in more\n          formats.\n\n          The `todate` builtin is an alias for `todateiso8601`.\n\n          The `now` builtin outputs the current time, in seconds since\n          the Unix epoch.\n\n          Low-level jq interfaces to the C-library time functions are\n          also provided: `strptime`, `strftime`, `mktime`, and `gmtime`.\n          Refer to your host operating system's documentation for the\n          format strings used by `strptime` and `strftime`.  Note: these\n          are not necessarily stable interfaces in jq, particularly as\n          to their localization functionality.\n\n          The `gmtime` builtin consumes a number of seconds since the\n          Unix epoch and outputs a \"broken down time\" representation of\n          time as an array of numbers representing (in this order): the\n          year, the month (zero-based), the day of the month, the hour\n          of the day, the minute of the hour, the second of the minute,\n          the day of the week, and the day of the year -- all one-based\n          unless otherwise stated.\n\n          The `mktime` builtin consumes \"broken down time\"\n          representations of time output by `gmtime` and `strptime`.\n\n          The `strptime(fmt)` builtin parses input strings matching the\n          `fmt` argument.  The output is in the \"broken down time\"\n          representation consumed by `mktime` and output by `gmtime`.\n\n          The `strftime(fmt)` builtin formats a time with the given\n          format.\n\n          The format strings for `strptime` and `strftime` are described\n          in typical C library documentation.  The format string for ISO\n          8601 datetime is `\"%Y-%m-%dT%H:%M:%SZ\"`.\n\n          jq may not support some or all of this date functionality on\n          some systems.\n\n        examples:\n          - program: 'fromdate'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['1425599507']\n\n          - program: 'strptime(\"%Y-%m-%dT%H:%M:%SZ\")'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['[2015,2,5,23,51,47,4,63]']\n\n          - program: 'strptime(\"%Y-%m-%dT%H:%M:%SZ\")|mktime'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['1425599507']\n\n  - title: Conditionals and Comparisons\n    entries:\n      - title: \"`==`, `!=`\"\n        body: |\n\n          The expression 'a == b' will produce 'true' if the result of a and b\n          are equal (that is, if they represent equivalent JSON documents) and\n          'false' otherwise. In particular, strings are never considered equal\n          to numbers. If you're coming from JavaScript, jq's == is like\n          JavaScript's === - considering values equal only when they have the\n          same type as well as the same value.\n\n          != is \"not equal\", and 'a != b' returns the opposite value of 'a == b'\n\n        examples:\n          - program: '.[] == 1'\n            input: '[1, 1.0, \"1\", \"banana\"]'\n            output: ['true', 'true', 'false', 'false']\n\n      - title: if-then-else-end\n        body: |\n\n          `if A then B else C end` will act the same as `B` if `A`\n          produces a value other than false or null, but act the same\n          as `C` otherwise.\n\n          Checking for false or null is a simpler notion of\n          \"truthiness\" than is found in JavaScript or Python, but it\n          means that you'll sometimes have to be more explicit about\n          the condition you want: you can't test whether, e.g. a\n          string is empty using `if .name then A else B end`, you'll\n          need something more like `if (.name | length) > 0 then A else\n          B end` instead.\n\n          If the condition `A` produces multiple results, then `B` is evaluated\n          once for each result that is not false or null, and `C` is evaluated\n          once for each false or null.\n\n          More cases can be added to an if using `elif A then B` syntax.\n\n        examples:\n          - program: |-\n              if . == 0 then\n                \"zero\"\n              elif . == 1 then\n                \"one\"\n              else\n                \"many\"\n              end\n            input: '2'\n            output: ['\"many\"']\n\n      - title: \"`>`, `>=`, `<=`, `<`\"\n        body: |\n\n          The comparison operators `>`, `>=`, `<=`, `<` return whether\n          their left argument is greater than, greater than or equal\n          to, less than or equal to or less than their right argument\n          (respectively).\n\n          The ordering is the same as that described for `sort`, above.\n\n        examples:\n          - program: '. < 5'\n            input: '2'\n            output: ['true']\n\n      - title: \"`and`, `or`, `not`\"\n        body: |\n\n          jq supports the normal Boolean operators `and`, `or`, `not`.\n          They have the same standard of truth as if expressions -\n          `false` and `null` are considered \"false values\", and\n          anything else is a \"true value\".\n\n          If an operand of one of these operators produces multiple\n          results, the operator itself will produce a result for each input.\n\n          `not` is in fact a builtin function rather than an operator,\n          so it is called as a filter to which things can be piped\n          rather than with special syntax, as in `.foo and .bar |\n          not`.\n\n          These three only produce the values `true` and `false`, and\n          so are only useful for genuine Boolean operations, rather\n          than the common Perl/Python/Ruby idiom of\n          \"value_that_may_be_null or default\". If you want to use this\n          form of \"or\", picking between two values rather than\n          evaluating a condition, see the `//` operator below.\n\n        examples:\n          - program: '42 and \"a string\"'\n            input: 'null'\n            output: ['true']\n          - program: '(true, false) or false'\n            input: 'null'\n            output: ['true', 'false']\n          - program: '(true, true) and (true, false)'\n            input: 'null'\n            output: ['true', 'false', 'true', 'false']\n          - program: '[true, false | not]'\n            input: 'null'\n            output: ['[false, true]']\n\n      - title: \"Alternative operator: `//`\"\n        body: |\n\n          A filter of the form `a // b` produces the same\n          results as `a`, if `a` produces results other than `false`\n          and `null`. Otherwise, `a // b` produces the same results as `b`.\n\n          This is useful for providing defaults: `.foo // 1` will\n          evaluate to `1` if there's no `.foo` element in the\n          input. It's similar to how `or` is sometimes used in Python\n          (jq's `or` operator is reserved for strictly Boolean\n          operations).\n\n        examples:\n          - program: '.foo // 42'\n            input: '{\"foo\": 19}'\n            output: ['19']\n          - program: '.foo // 42'\n            input: '{}'\n            output: ['42']\n\n      - title: try-catch\n        body: |\n\n          Errors can be caught by using `try EXP catch EXP`.  The first\n          expression is executed, and if it fails then the second is\n          executed with the error message.  The output of the handler,\n          if any, is output as if it had been the output of the\n          expression to try.\n\n          The `try EXP` form uses `empty` as the exception handler.\n\n        examples:\n          - program: 'try .a catch \". is not an object\"'\n            input: 'true'\n            output: ['\". is not an object\"']\n          - program: '[.[]|try .a]'\n            input: '[{}, true, {\"a\":1}]'\n            output: ['[null, 1]']\n          - program: 'try error(\"some exception\") catch .'\n            input: 'true'\n            output: ['\"some exception\"']\n\n      - title: Breaking out of control structures\n        body: |\n\n          A convenient use of try/catch is to break out of control\n          structures like `reduce`, `foreach`, `while`, and so on.\n\n          For example:\n\n              # Repeat an expression until it raises \"break\" as an\n              # error, then stop repeating without re-raising the error.\n              # But if the error caught is not \"break\" then re-raise it.\n              try repeat(exp) catch if .==\"break\" then empty else error\n\n          jq has a syntax for named lexical labels to \"break\" or \"go (back) to\":\n\n              label $out | ... break $out ...\n\n          The `break $label_name` expression will cause the program to\n          act as though the nearest (to the left) `label $label_name`\n          produced `empty`.\n\n          The relationship between the `break` and corresponding `label`\n          is lexical: the label has to be \"visible\" from the break.\n\n          To break out of a `reduce`, for example:\n\n              label $out | reduce .[] as $item (null; if .==false then break $out else ... end)\n\n          The following jq program produces a syntax error:\n\n              break $out\n\n          because no label `$out` is visible.\n\n      - title: \"`?` operator\"\n        body: |\n\n          The `?` operator, used as `EXP?`, is shorthand for `try EXP`.\n\n        examples:\n          - program: '[.[]|(.a)?]'\n            input: '[{}, true, {\"a\":1}]'\n            output: ['[null, 1]']\n\n\n  - title: Regular expressions\n    body: |\n\n      jq uses the Oniguruma regular expression library, as do PHP,\n      Ruby, TextMate, Sublime Text, etc, so the description here\n      will focus on jq specifics.\n\n      The jq regex filters are defined so that they can be used using\n      one of these patterns:\n\n          STRING | FILTER(REGEX)\n          STRING | FILTER(REGEX; FLAGS)\n          STRING | FILTER([REGEX])\n          STRING | FILTER([REGEX, FLAGS])\n\n      where:\n\n      * STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;\n      * REGEX, after string interpolation, should be a valid regular expression;\n      * FILTER is one of `test`, `match`, or `capture`, as described below.\n\n      FLAGS is a string consisting of one of more of the supported flags:\n\n      * `g` - Global search (find all matches, not just the first)\n      * `i` - Case insensitive search\n      * `m` - Multi line mode (`.` will match newlines)\n      * `n` - Ignore empty matches\n      * `p` - Both s and m modes are enabled\n      * `s` - Single line mode (`^` -> `\\A`, `$` -> `\\Z`)\n      * `l` - Find longest possible matches\n      * `x` - Extended regex format (ignore whitespace and comments)\n\n      To match a whitespace with the `x` flag, use `\\s`, e.g.\n\n          jq -n '\"a b\" | test(\"a\\\\sb\"; \"x\")'\n\n      Note that certain flags may also be specified within REGEX, e.g.\n\n          jq -n '(\"test\", \"TEst\", \"teST\", \"TEST\") | test(\"(?i)te(?-i)st\")'\n\n      evaluates to: `true`, `true`, `false`, `false`.\n\n    entries:\n      - title: \"`test(val)`, `test(regex; flags)`\"\n        body: |\n\n          Like `match`, but does not return match objects, only `true` or `false`\n          for whether or not the regex matches the input.\n\n        examples:\n          - program: 'test(\"foo\")'\n            input: '\"foo\"'\n            output: ['true']\n          - program: '.[] | test(\"a b c # spaces are ignored\"; \"ix\")'\n            input: '[\"xabcd\", \"ABC\"]'\n            output: ['true', 'true']\n\n      - title: \"`match(val)`, `match(regex; flags)`\"\n        body: |\n\n          **match** outputs an object for each match it finds.  Matches have\n          the following fields:\n\n          * `offset` - offset in UTF-8 codepoints from the beginning of the input\n          * `length` - length in UTF-8 codepoints of the match\n          * `string` - the string that it matched\n          * `captures` - an array of objects representing capturing groups.\n\n          Capturing group objects have the following fields:\n\n          * `offset` - offset in UTF-8 codepoints from the beginning of the input\n          * `length` - length in UTF-8 codepoints of this capturing group\n          * `string` - the string that was captured\n          * `name` - the name of the capturing group (or `null` if it was unnamed)\n\n          Capturing groups that did not match anything return an offset of -1\n\n        examples:\n          - program: 'match(\"(abc)+\"; \"g\")'\n            input: '\"abc abc\"'\n            output:\n             - '{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"name\": null}]}'\n             - '{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"name\": null}]}'\n          - program: 'match(\"foo\")'\n            input: '\"foo bar foo\"'\n            output: ['{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}']\n          - program: 'match([\"foo\", \"ig\"])'\n            input: '\"foo bar FOO\"'\n            output:\n             - '{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}'\n             - '{\"offset\": 8, \"length\": 3, \"string\": \"FOO\", \"captures\": []}'\n          - program: 'match(\"foo (?<bar123>bar)? foo\"; \"ig\")'\n            input: '\"foo bar foo foo  foo\"'\n            output:\n             - '{\"offset\": 0, \"length\": 11, \"string\": \"foo bar foo\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"bar\", \"name\": \"bar123\"}]}'\n             - '{\"offset\": 12, \"length\": 8, \"string\": \"foo  foo\", \"captures\": [{\"offset\": -1, \"length\": 0, \"string\": null, \"name\": \"bar123\"}]}'\n\n          - program: '[ match(\".\"; \"g\")] | length'\n            input: '\"abc\"'\n            output: ['3']\n\n\n      - title: \"`capture(val)`, `capture(regex; flags)`\"\n        body: |\n\n         Collects the named captures in a JSON object, with the name\n         of each capture as the key, and the matched string as the\n         corresponding value.\n\n        examples:\n          - program: 'capture(\"(?<a>[a-z]+)-(?<n>[0-9]+)\")'\n            input: '\"xyzzy-14\"'\n            output: ['{ \"a\": \"xyzzy\", \"n\": \"14\" }']\n\n      - title: \"`scan(regex)`, `scan(regex; flags)`\"\n        body: |\n\n          Emit a stream of the non-overlapping substrings of the input\n          that match the regex in accordance with the flags, if any\n          have been specified.  If there is no match, the stream is empty.\n          To capture all the matches for each input string, use the idiom\n          `[ expr ]`, e.g. `[ scan(regex) ]`.\n\n        examples:\n          - program: 'scan(\"c\")'\n            input: '\"abcdefabc\"'\n            output: ['\"c\"', '\"c\"']\n\n      - title: \"`split(regex; flags)`\"\n        body: |\n\n          For backwards compatibility, `split` splits on a string, not a regex.\n\n        examples:\n          - program: 'split(\", *\"; null)'\n            input: '\"ab,cd, ef\"'\n            output: ['[\"ab\",\"cd\",\"ef\"]']\n\n\n      - title: \"`splits(regex)`, `splits(regex; flags)`\"\n        body: |\n\n          These provide the same results as their `split` counterparts,\n          but as a stream instead of an array.\n\n        examples:\n          - program: 'splits(\", *\")'\n            input: '\"ab,cd,   ef, gh\"'\n            output: ['\"ab\"','\"cd\"','\"ef\"','\"gh\"']\n\n      - title: \"`sub(regex; tostring)` `sub(regex; string; flags)`\"\n        body: |\n\n          Emit the string obtained by replacing the first match of regex in the\n          input string with `tostring`, after interpolation.  `tostring` should\n          be a jq string, and may contain references to named captures. The\n          named captures are, in effect, presented as a JSON object (as\n          constructed by `capture`) to `tostring`, so a reference to a captured\n          variable named \"x\" would take the form: `\"\\(.x)\"`.\n\n        examples:\n          - program: 'sub(\"[^a-z]*(?<x>[a-z]+)\"; \"Z\\(.x)\"; \"g\")'\n            input: '\"123abc456def\"'\n            output: ['\"ZabcZdef\"']\n\n\n      - title: \"`gsub(regex; string)`, `gsub(regex; string; flags)`\"\n        body: |\n\n          `gsub` is like `sub` but all the non-overlapping occurrences of the regex are\n          replaced by the string, after interpolation.\n\n        examples:\n          - program: 'gsub(\"(?<x>.)[^a]*\"; \"+\\(.x)-\")'\n            input: '\"Abcabc\"'\n            output: ['\"+A-+a-\"']\n\n\n  - title: Advanced features\n    body: |\n      Variables are an absolute necessity in most programming languages, but\n      they're relegated to an \"advanced feature\" in jq.\n\n      In most languages, variables are the only means of passing around\n      data. If you calculate a value, and you want to use it more than once,\n      you'll need to store it in a variable. To pass a value to another part\n      of the program, you'll need that part of the program to define a\n      variable (as a function parameter, object member, or whatever) in\n      which to place the data.\n\n      It is also possible to define functions in jq, although this is\n      is a feature whose biggest use is defining jq's standard library\n      (many jq functions such as `map` and `select` are in fact written\n      in jq).\n\n      jq has reduction operators, which are very powerful but a bit\n      tricky.  Again, these are mostly used internally, to define some\n      useful bits of jq's standard library.\n\n      It may not be obvious at first, but jq is all about generators\n      (yes, as often found in other languages).  Some utilities are\n      provided to help deal with generators.\n\n      Some minimal I/O support (besides reading JSON from standard\n      input, and writing JSON to standard output) is available.\n\n      Finally, there is a module/library system.\n\n    entries:\n      - title: Variables\n        body: |\n\n          In jq, all filters have an input and an output, so manual\n          plumbing is not necessary to pass a value from one part of a program\n          to the next. Many expressions, for instance `a + b`, pass their input\n          to two distinct subexpressions (here `a` and `b` are both passed the\n          same input), so variables aren't usually necessary in order to use a\n          value twice.\n\n          For instance, calculating the average value of an array of numbers\n          requires a few variables in most languages - at least one to hold the\n          array, perhaps one for each element or for a loop counter. In jq, it's\n          simply `add / length` - the `add` expression is given the array and\n          produces its sum, and the `length` expression is given the array and\n          produces its length.\n\n          So, there's generally a cleaner way to solve most problems in jq than\n          defining variables. Still, sometimes they do make things easier, so jq\n          lets you define variables using `expression as $variable`. All\n          variable names start with `$`. Here's a slightly uglier version of the\n          array-averaging example:\n\n              length as $array_length | add / $array_length\n\n          We'll need a more complicated problem to find a situation where using\n          variables actually makes our lives easier.\n\n\n          Suppose we have an array of blog posts, with \"author\" and \"title\"\n          fields, and another object which is used to map author usernames to\n          real names. Our input looks like:\n\n              {\"posts\": [{\"title\": \"First post\", \"author\": \"anon\"},\n                         {\"title\": \"A well-written article\", \"author\": \"person1\"}],\n               \"realnames\": {\"anon\": \"Anonymous Coward\",\n                             \"person1\": \"Person McPherson\"}}\n\n          We want to produce the posts with the author field containing a real\n          name, as in:\n\n              {\"title\": \"First post\", \"author\": \"Anonymous Coward\"}\n              {\"title\": \"A well-written article\", \"author\": \"Person McPherson\"}\n\n          We use a variable, $names, to store the realnames object, so that we\n          can refer to it later when looking up author usernames:\n\n              .realnames as $names | .posts[] | {title, author: $names[.author]}\n\n          The expression `exp as $x | ...` means: for each value of expression\n          `exp`, run the rest of the pipeline with the entire original input, and\n          with `$x` set to that value.  Thus `as` functions as something of a\n          foreach loop.\n\n          Just as `{foo}` is a handy way of writing `{foo: .foo}`, so\n          `{$foo}` is a handy way of writing `{foo: $foo}`.\n\n          Multiple variables may be declared using a single `as` expression by\n          providing a pattern that matches the structure of the input\n          (this is known as \"destructuring\"):\n\n              . as {realnames: $names, posts: [$first, $second]} | ...\n\n          The variable declarations in array patterns (e.g., `. as\n          [$first, $second]`) bind to the elements of the array in from\n          the element at index zero on up, in order.  When there is no\n          value at the index for an array pattern element, `null` is\n          bound to that variable.\n\n          Variables are scoped over the rest of the expression that defines\n          them, so\n\n              .realnames as $names | (.posts[] | {title, author: $names[.author]})\n\n          will work, but\n\n              (.realnames as $names | .posts[]) | {title, author: $names[.author]}\n\n          won't.\n\n          For programming language theorists, it's more accurate to\n          say that jq variables are lexically-scoped bindings.  In\n          particular there's no way to change the value of a binding;\n          one can only setup a new binding with the same name, but which\n          will not be visible where the old one was.\n\n        examples:\n          - program: '.bar as $x | .foo | . + $x'\n            input: '{\"foo\":10, \"bar\":200}'\n            output: ['210']\n          - program: '. as $i|[(.*2|. as $i| $i), $i]'\n            input: '5'\n            output: ['[10,5]']\n          - program: '. as [$a, $b, {c: $c}] | $a + $b + $c'\n            input: '[2, 3, {\"c\": 4, \"d\": 5}]'\n            output: ['9']\n          - program: '.[] as [$a, $b] | {a: $a, b: $b}'\n            input: '[[0], [0, 1], [2, 1, 0]]'\n            output: ['{\"a\":0,\"b\":null}', '{\"a\":0,\"b\":1}', '{\"a\":2,\"b\":1}']\n\n      - title: 'Defining Functions'\n        body: |\n\n          You can give a filter a name using \"def\" syntax:\n\n              def increment: . + 1;\n\n          From then on, `increment` is usable as a filter just like a\n          builtin function (in fact, this is how some of the builtins\n          are defined). A function may take arguments:\n\n              def map(f): [.[] | f];\n\n          Arguments are passed as filters, not as values. The\n          same argument may be referenced multiple times with\n          different inputs (here `f` is run for each element of the\n          input array). Arguments to a function work more like\n          callbacks than like value arguments.  This is important to\n          understand.  Consider:\n\n              def foo(f): f|f;\n              5|foo(.*2)\n\n          The result will be 20 because `f` is `.*2`, and during the\n          first invocation of `f` `.` will be 5, and the second time it\n          will be 10 (5 * 2), so the result will be 20.  Function\n          arguments are filters, and filters expect an input when\n          invoked.\n\n          If you want the value-argument behaviour for defining simple\n          functions, you can just use a variable:\n\n              def addvalue(f): f as $f | map(. + $f);\n\n          Or use the short-hand:\n\n              def addvalue($f): ...;\n\n          With either definition, `addvalue(.foo)` will add the current\n          input's `.foo` field to each element of the array.\n\n          Multiple definitions using the same function name are allowed.\n          Each re-definition replaces the previous one for the same\n          number of function arguments, but only for references from\n          functions (or main program) subsequent to the re-definition.\n\n        examples:\n          - program: 'def addvalue(f): . + [f]; map(addvalue(.[0]))'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1], [10,20,10]]']\n          - program: 'def addvalue(f): f as $x | map(. + $x); addvalue(.[0])'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1,2], [10,20,1,2]]']\n\n      - title: \"`limit(n; exp)`\"\n        body: |\n\n          The `limit` function extracts up to `n` outputs from `exp`.\n\n        examples:\n          - program: '[limit(3;.[])]'\n            input: '[0,1,2,3,4,5,6,7,8,9]'\n            output: ['[0,1,2]']\n\n      - title: \"`first(expr)`, `last(expr)`, `nth(n; expr)`\"\n        body: |\n\n          The `first(expr)` and `last(expr)` functions extract the first\n          and last values from `expr`, respectively.\n\n          The `nth(n; expr)` function extracts the nth value output by\n          `expr`.  This can be defined as `def nth(n; expr):\n          last(limit(n + 1; expr));`.  Note that `nth(n; expr)` doesn't\n          support negative values of `n`.\n\n        examples:\n          - program: '[first(range(.)), last(range(.)), nth(./2; range(.))]'\n            input: '10'\n            output: ['[0,9,5]']\n\n      - title: \"`first`, `last`, `nth(n)`\"\n        body: |\n\n          The `first` and `last` functions extract the first\n          and last values from any array at `.`.\n\n          The `nth(n)` function extracts the nth value of any array at `.`.\n\n        examples:\n          - program: '[range(.)]|[first, last, nth(5)]'\n            input: '10'\n            output: ['[0,9,5]']\n\n      - title: \"`reduce`\"\n        body: |\n\n          The `reduce` syntax allows you to combine all of the results of\n          an expression by accumulating them into a single answer.\n          The form is `reduce EXP as $var (INIT; UPDATE)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              reduce .[] as $item (0; . + $item)\n\n          For each result that `.[]` produces, `. + $item` is run to\n          accumulate a running total, starting from 0 as the input value.\n          In this example, `.[]` produces the results `1`, `2`, and `3`,\n          so the effect is similar to running something like this:\n\n              0 | 1 as $item | . + $item |\n                  2 as $item | . + $item |\n                  3 as $item | . + $item\n\n        examples:\n          - program: 'reduce .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['15']\n\n          - program: 'reduce .[] as [$i,$j] (0; . + $i * $j)'\n            input: '[[1,2],[3,4],[5,6]]'\n            output: ['44']\n\n          - program: 'reduce .[] as {$x,$y} (null; .x += $x | .y += [$y])'\n            input: '[{\"x\":\"a\",\"y\":1},{\"x\":\"b\",\"y\":2},{\"x\":\"c\",\"y\":3}]'\n            output: ['{\"x\":\"abc\",\"y\":[1,2,3]}']\n\n      - title: \"`foreach`\"\n        body: |\n\n          The `foreach` syntax is similar to `reduce`, but intended to\n          allow the construction of `limit` and reducers that produce\n          intermediate results.\n\n          The form is `foreach EXP as $var (INIT; UPDATE; EXTRACT)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              foreach .[] as $item (0; . + $item; [$item, . * 2])\n\n          Like the `reduce` syntax, `. + $item` is run for each result\n          that `.[]` produces, but `[$item, . * 2]` is run for each\n          intermediate values. In this example, since the intermediate\n          values are `1`, `3`, and `6`, the `foreach` expression produces\n          `[1,2]`, `[2,6]`, and `[3,12]`. So the effect is similar\n          to running something like this:\n\n              0 | 1 as $item | . + $item | [$item, . * 2],\n                  2 as $item | . + $item | [$item, . * 2],\n                  3 as $item | . + $item | [$item, . * 2]\n\n          When `EXTRACT` is omitted, the identity filter is used.\n          That is, it outputs the intermediate values as they are.\n\n        examples:\n          - program: 'foreach .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['1','3','6','10','15']\n\n          - program: 'foreach .[] as $item (0; . + $item; [$item, . * 2])'\n            input: '[1,2,3,4,5]'\n            output: ['[1,2]','[2,6]','[3,12]','[4,20]','[5,30]']\n\n          - program: 'foreach .[] as $item (0; . + 1; {index: ., $item})'\n            input: '[\"foo\", \"bar\", \"baz\"]'\n            output:\n              - '{\"index\":1,\"item\":\"foo\"}'\n              - '{\"index\":2,\"item\":\"bar\"}'\n              - '{\"index\":3,\"item\":\"baz\"}'\n\n      - title: Recursion\n        body: |\n\n          As described above, `recurse` uses recursion, and any jq\n          function can be recursive.  The `while` builtin is also\n          implemented in terms of recursion.\n\n          Tail calls are optimized whenever the expression to the left of\n          the recursive call outputs its last value.  In practice this\n          means that the expression to the left of the recursive call\n          should not produce more than one output for each input.\n\n          For example:\n\n              def recurse(f): def r: ., (f | select(. != null) | r); r;\n\n              def while(cond; update):\n                def _while:\n                  if cond then ., (update | _while) else empty end;\n                _while;\n\n              def repeat(exp):\n                def _repeat:\n                  exp, _repeat;\n                _repeat;\n\n      - title: Generators and iterators\n        body: |\n\n            Some jq operators and functions are actually generators in\n            that they can produce zero, one, or more values for each\n            input, just as one might expect in other programming\n            languages that have generators.  For example, `.[]`\n            generates all the values in its input (which must be an\n            array or an object), `range(0; 10)` generates the integers\n            between 0 and 10, and so on.\n\n            Even the comma operator is a generator, generating first the\n            values generated by the expression to the left of the comma,\n            then for each of those, the values generate by the\n            expression on the right of the comma.\n\n            The `empty` builtin is the generator that produces zero\n            outputs.  The `empty` builtin backtracks to the preceding\n            generator expression.\n\n            All jq functions can be generators just by using builtin\n            generators.  It is also possible to define new generators\n            using only recursion and the comma operator.  If the\n            recursive call(s) is(are) \"in tail position\" then the\n            generator will be efficient.  In the example below the\n            recursive call by `_range` to itself is in tail position.\n            The example shows off three advanced topics: tail recursion,\n            generator construction, and sub-functions.\n\n        examples:\n          - program: 'def range(init; upto; by):\n                    def _range:\n                        if (by > 0 and . < upto) or (by < 0 and . > upto)\n                        then ., ((.+by)|_range)\n                        else . end;\n                    if by == 0 then init else init|_range end |\n                    select((by > 0 and . < upto) or (by < 0 and . > upto));\n                range(0; 10; 3)'\n            input: 'null'\n            output: ['0', '3', '6', '9']\n          - program: 'def while(cond; update):\n                    def _while:\n                        if cond then ., (update | _while) else empty end;\n                    _while;\n                [while(.<100; .*2)]'\n            input: '1'\n            output: ['[1,2,4,8,16,32,64]']\n\n  - title: 'Math'\n    body: |\n\n      jq currently only has IEEE754 double-precision (64-bit) floating\n      point number support.\n\n      Besides simple arithmetic operators such as `+`, jq also has most\n      standard math functions from the C math library.  C math functions\n      that take a single input argument (e.g., `sin()`) are available as\n      zero-argument jq functions.  C math functions that take two input\n      arguments (e.g., `pow()`) are available as two-argument jq\n      functions that ignore `.`.\n\n      Availability of standard math functions depends on the\n      availability of the corresponding math functions in your operating\n      system and C math library.  Unavailable math functions will be\n      defined but will raise an error.\n\n  - title: 'I/O'\n    body: |\n\n      At this time jq has minimal support for I/O, mostly in the\n      form of control over when inputs are read.  Two builtins functions\n      are provided for this, `input` and `inputs`, that read from the\n      same sources (e.g., `stdin`, files named on the command-line) as\n      jq itself.  These two builtins, and jq's own reading actions, can\n      be interleaved with each other.\n\n      One builtin provides minimal output capabilities, `debug`.\n      (Recall that a jq program's output values are always output as\n      JSON texts on `stdout`.)  The `debug` builtin can have\n      application-specific behavior, such as for executables that use\n      the libjq C API but aren't the jq executable itself.\n\n    entries:\n      - title: \"`input`\"\n        body: |\n\n          Outputs one new input.\n\n              echo 1 2 3 4 | jq '[., input]' # [1,2] [3,4]\n\n      - title: \"`inputs`\"\n        body: |\n\n          Outputs all remaining inputs, one by one.\n\n          This is primarily useful for reductions over a program's\n          inputs.\n\n              echo 1 2 3 | jq -n 'reduce inputs as $i (0; . + $i)' # 6\n\n      - title: \"`debug`\"\n        body: |\n\n          Causes a debug message based on the input value to be\n          produced.  The jq executable wraps the input value with\n          `[\"DEBUG:\", <input-value>]` and prints that and a newline on\n          stderr, compactly.  This may change in the future.\n\n      - title: \"`input_filename`\"\n        body: |\n\n          Returns the name of the file whose input is currently being\n          filtered.  Note that this will not work well unless jq is\n          running in a UTF-8 locale.\n\n      - title: \"`input_line_number`\"\n        body: |\n\n          Returns the line number of the input currently being filtered.\n\n  - title: 'Streaming'\n    body: |\n\n      With the `--stream` option jq can parse input texts in a streaming\n      fashion, allowing jq programs to start processing large JSON texts\n      immediately rather than after the parse completes.  If you have a\n      single JSON text that is 1GB in size, streaming it will allow you\n      to process it much more quickly.\n\n      However, streaming isn't easy to deal with as the jq program will\n      have `[<path>, <leaf-value>]` (and a few other forms) as inputs.\n\n      Several builtins are provided to make handling streams easier.\n\n      The examples below use the streamed form of `[0,[1]]`, which\n      is `[[0],0],[[1,0],1],[[1,0]],[[1]]`.\n\n      Streaming forms include `[<path>, <leaf-value>]` (to indicate any\n      scalar value, empty array, or empty object), and `[<path>]` (to\n      indicate the end of an array or object).  Future versions of jq\n      run with `--stream` and `--seq` may output additional forms such\n      as `[\"error message\"]` when an input text fails to parse.\n\n    entries:\n      - title: \"`truncate_stream(stream_expression)`\"\n        body: |\n\n          Consumes a number as input and truncates the corresponding\n          number of path elements from the left of the outputs of the\n          given streaming expression.\n\n        examples:\n          - program: 'truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]])'\n            input: '1'\n            output: ['[[0],2]', '[[0]]']\n\n      - title: \"`fromstream(stream_expression)`\"\n        body: |\n\n          Outputs values corresponding to the stream expression's\n          outputs.\n\n        examples:\n          - program: 'fromstream(1|truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]]))'\n            input: 'null'\n            output: ['[2]']\n\n      - title: \"`tostream`\"\n        body: |\n\n          The `tostream` builtin outputs the streamed form of its input.\n\n        examples:\n          - program: '. as $dot|fromstream($dot|tostream)|.==$dot'\n            input: '[0,[1,{\"a\":1},{\"b\":2}]]'\n            output: ['true']\n\n  - title: Assignment\n    body: |\n\n      Assignment works a little differently in jq than in most\n      programming languages. jq doesn't distinguish between references\n      to and copies of something - two objects or arrays are either\n      equal or not equal, without any further notion of being \"the\n      same object\" or \"not the same object\".\n\n      If an object has two fields which are arrays, `.foo` and `.bar`,\n      and you append something to `.foo`, then `.bar` will not get\n      bigger. Even if you've just set `.bar = .foo`. If you're used to\n      programming in languages like Python, Java, Ruby, JavaScript,\n      etc. then you can think of it as though jq does a full deep copy\n      of every object before it does the assignment (for performance,\n      it doesn't actually do that, but that's the general idea).\n\n      All the assignment operators in jq have path expressions on the\n      left-hand side.\n\n    entries:\n      - title: \"`=`\"\n        body: |\n\n          The filter `.foo = 1` will take as input an object\n          and produce as output an object with the \"foo\" field set to\n          1. There is no notion of \"modifying\" or \"changing\" something\n          in jq - all jq values are immutable. For instance,\n\n           .foo = .bar | .foo.baz = 1\n\n          will not have the side-effect of setting .bar.baz to be set\n          to 1, as the similar-looking program in JavaScript, Python,\n          Ruby or other languages would. Unlike these languages (but\n          like Haskell and some other functional languages), there is\n          no notion of two arrays or objects being \"the same array\" or\n          \"the same object\". They can be equal, or not equal, but if\n          we change one of them in no circumstances will the other\n          change behind our backs.\n\n          This means that it's impossible to build circular values in\n          jq (such as an array whose first element is itself). This is\n          quite intentional, and ensures that anything a jq program\n          can produce can be represented in JSON.\n\n          Note that the left-hand side of '=' refers to a value in `.`.\n          Thus `$var.foo = 1` won't work as expected (`$var.foo` is not\n          a valid or useful path expression in `.`); use `$var | .foo =\n          1` instead.\n\n          If the right-hand side of '=' produces multiple values, then\n          for each such value jq will set the paths on the left-hand\n          side to the value and then it will output the modified `.`.\n          For example, `(.a,.b)=range(2)` outputs `{\"a\":0,\"b\":0}`, then\n          `{\"a\":1,\"b\":1}`.  The \"update\" assignment forms (see below) do\n          not do this.\n\n          Note too that `.a,.b=0` does not set `.a` and `.b`, but\n          `(.a,.b)=0` sets both.\n\n      - title: \"`|=`\"\n        body: |\n          As well as the assignment operator '=', jq provides the \"update\"\n          operator '|=', which takes a filter on the right-hand side and\n          works out the new value for the property of `.` being assigned\n          to by running the old value through this expression. For\n          instance, .foo |= .+1 will build an object with the \"foo\"\n          field set to the input's \"foo\" plus 1.\n\n          This example should show the difference between '=' and '|=':\n\n          Provide input '{\"a\": {\"b\": 10}, \"b\": 20}' to the programs:\n\n          .a = .b\n          .a |= .b\n\n          The former will set the \"a\" field of the input to the \"b\" field of the\n          input, and produce the output {\"a\": 20}. The latter will set the \"a\"\n          field of the input to the \"a\" field's \"b\" field, producing {\"a\": 10}.\n\n          The left-hand side can be any general path expression; see `path()`.\n\n          Note that the left-hand side of '|=' refers to a value in `.`.\n          Thus `$var.foo |= . + 1` won't work as expected (`$var.foo` is\n          not a valid or useful path expression in `.`); use `$var |\n          .foo |= . + 1` instead.\n\n          If the right-hand side outputs multiple values, only the last\n          one will be used.\n\n        examples:\n\n          - program: '(..|select(type==\"boolean\")) |= if . then 1 else 0 end'\n            input: '[true,false,[5,true,[true,[false]],false]]'\n            output: ['[1,0,[5,1,[1,[0]],0]]']\n\n      - title: \"`+=`, `-=`, `*=`, `/=`, `%=`, `//=`\"\n        body: |\n\n          jq has a few operators of the form `a op= b`, which are all\n          equivalent to `a |= . op b`. So, `+= 1` can be used to increment values.\n\n        examples:\n          - program: .foo += 1\n            input: '{\"foo\": 42}'\n            output: ['{\"foo\": 43}']\n\n      - title: Complex assignments\n        body: |\n          Lots more things are allowed on the left-hand side of a jq assignment\n          than in most languages. We've already seen simple field accesses on\n          the left hand side, and it's no surprise that array accesses work just\n          as well:\n\n              .posts[0].title = \"JQ Manual\"\n\n          What may come as a surprise is that the expression on the left may\n          produce multiple results, referring to different points in the input\n          document:\n\n              .posts[].comments |= . + [\"this is great\"]\n\n          That example appends the string \"this is great\" to the \"comments\"\n          array of each post in the input (where the input is an object with a\n          field \"posts\" which is an array of posts).\n\n          When jq encounters an assignment like 'a = b', it records the \"path\"\n          taken to select a part of the input document while executing a. This\n          path is then used to find which part of the input to change while\n          executing the assignment. Any filter may be used on the\n          left-hand side of an equals - whichever paths it selects from the\n          input will be where the assignment is performed.\n\n          This is a very powerful operation. Suppose we wanted to add a comment\n          to blog posts, using the same \"blog\" input above. This time, we only\n          want to comment on the posts written by \"stedolan\". We can find those\n          posts using the \"select\" function described earlier:\n\n              .posts[] | select(.author == \"stedolan\")\n\n          The paths provided by this operation point to each of the posts that\n          \"stedolan\" wrote, and we can comment on each of them in the same way\n          that we did before:\n\n              (.posts[] | select(.author == \"stedolan\") | .comments) |=\n                  . + [\"terrible.\"]\n\n  - title: Modules\n    body: |\n\n      jq has a library/module system.  Modules are files whose names end\n      in `.jq`.\n\n      Modules imported by a program are searched for in a default search\n      path (see below).  The `import` and `include` directives allow the\n      importer to alter this path.\n\n      Paths in the search path are subject to various substitutions.\n\n      For paths starting with \"~/\", the user's home directory is\n      substituted for \"~\".\n\n      For paths starting with \"$ORIGIN/\", the directory where the jq\n      executable is located is substituted for \"$ORIGIN\".\n\n      For paths starting with \"./\" or paths that are \".\", the path of\n      the including file is substituted for \".\".  For top-level programs\n      given on the command-line, the current directory is used.\n\n      Import directives can optionally specify a search path to which\n      the default is appended.\n\n      The default search path is the search path given to the `-L`\n      command-line option, else `[\"~/.jq\", \"$ORIGIN/../lib/jq\",\n      \"$ORIGIN/../lib\"]`.\n\n      Null and empty string path elements terminate search path\n      processing.\n\n      A dependency with relative path \"foo/bar\" would be searched for in\n      \"foo/bar.jq\" and \"foo/bar/bar.jq\" in the given search path. This\n      is intended to allow modules to be placed in a directory along\n      with, for example, version control files, README files, and so on,\n      but also to allow for single-file modules.\n\n      Consecutive components with the same name are not allowed to avoid\n      ambiguities (e.g., \"foo/foo\").\n\n      For example, with `-L$HOME/.jq` a module `foo` can be found in\n      `$HOME/.jq/foo.jq` and `$HOME/.jq/foo/foo.jq`.\n\n      If \"$HOME/.jq\" is a file, it is sourced into the main program.\n\n    entries:\n      - title: \"`import RelativePathString as NAME [<metadata>];`\"\n        body: |\n\n          Imports a module found at the given path relative to a\n          directory in a search path.  A \".jq\" suffix will be added to\n          the relative path string.  The module's symbols are prefixed\n          with \"NAME::\".\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like \"homepage\" and so on.  At\n          this time jq only uses the \"search\" key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n          The \"search\" key in the metadata, if present, should have a\n          string or array value (array of strings); this is the search\n          path to be prefixed to the top-level search path.\n\n      - title: \"`include RelativePathString [<metadata>];`\"\n        body: |\n\n          Imports a module found at the given path relative to a\n          directory in a search path as if it were included in place.  A\n          \".jq\" suffix will be added to the relative path string.  The\n          module's symbols are imported into the caller's namespace as\n          if the module's content had been included directly.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like \"homepage\" and so on.  At\n          this time jq only uses the \"search\" key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n      - title: \"`import RelativePathString as $NAME [<metadata>];`\"\n        body: |\n\n          Imports a JSON file found at the given path relative to a\n          directory in a search path.  A \".json\" suffix will be added to\n          the relative path string.  The file's data will be available\n          as `$NAME::NAME`.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like \"homepage\" and so on.  At\n          this time jq only uses the \"search\" key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n          The \"search\" key in the metadata, if present, should have a\n          string or array value (array of strings); this is the search\n          path to be prefixed to the top-level search path.\n\n      - title: \"`module <metadata>;`\"\n        body: |\n\n          This directive is entirely optional.  It's not required for\n          proper operation.  It serves only the purpose of providing\n          metadata that can be read with the `modulemeta` builtin.\n\n          The metadata must be a constant jq expression.  It should be\n          an object with keys like \"homepage\".  At this time jq doesn't\n          use this metadata, but it is made available to users via the\n          `modulemeta` builtin.\n\n      - title: \"`modulemeta`\"\n        body: |\n\n          Takes a module name as input and outputs the module's metadata\n          as an object, with the module's imports (including metadata)\n          as an array value for the \"deps\" key.\n\n          Programs can use this to query a module's metadata, which they\n          could then use to, for example, search for, download, and\n          install missing dependencies.\n\n"
  },
  {
    "path": "docs/content/manual/v1.6/manual.yml",
    "content": "---\nheadline: jq 1.6 Manual\n\nbody: |\n\n  A jq program is a \"filter\": it takes an input, and produces an\n  output. There are a lot of builtin filters for extracting a\n  particular field of an object, or converting a number to a string,\n  or various other standard tasks.\n\n  Filters can be combined in various ways - you can pipe the output of\n  one filter into another filter, or collect the output of a filter\n  into an array.\n\n  Some filters produce multiple results, for instance there's one that\n  produces all the elements of its input array. Piping that filter\n  into a second runs the second filter for each element of the\n  array. Generally, things that would be done with loops and iteration\n  in other languages are just done by gluing filters together in jq.\n\n  It's important to remember that every filter has an input and an\n  output. Even literals like \"hello\" or 42 are filters - they take an\n  input but always produce the same literal as output. Operations that\n  combine two filters, like addition, generally feed the same input to\n  both and combine the results. So, you can implement an averaging\n  filter as `add / length` - feeding the input array both to the `add`\n  filter and the `length` filter and then performing the division.\n\n  But that's getting ahead of ourselves. :) Let's start with something\n  simpler:\n\nmanpage_intro: |\n  jq(1) -- Command-line JSON processor\n  ====================================\n\n  ## SYNOPSIS\n\n  `jq` [<options>...] <filter> [<files>...]\n\n  `jq` can transform JSON in various ways, by selecting, iterating,\n  reducing and otherwise mangling JSON documents. For instance,\n  running the command `jq 'map(.price) | add'` will take an array of\n  JSON objects as input and return the sum of their \"price\" fields.\n\n  `jq` can accept text input as well, but by default, `jq` reads a\n  stream of JSON entities (including numbers and other literals) from\n  `stdin`. Whitespace is only needed to separate entities such as 1\n  and 2, and true and false.  One or more <files> may be specified, in\n  which case `jq` will read input from those instead.\n\n  The <options> are described in the [INVOKING JQ] section; they\n  mostly concern input and output formatting. The <filter> is written\n  in the jq language and specifies how to transform the input\n  file or document.\n\n  ## FILTERS\n\nmanpage_epilogue: |\n  ## BUGS\n\n  Presumably. Report them or discuss them at:\n\n      https://github.com/jqlang/jq/issues\n\n  ## AUTHOR\n\n  Stephen Dolan `<mu@netsoc.tcd.ie>`\n\nsections:\n  - title: Invoking jq\n    body: |\n\n      jq filters run on a stream of JSON data. The input to jq is\n      parsed as a sequence of whitespace-separated JSON values which\n      are passed through the provided filter one at a time. The\n      output(s) of the filter are written to standard output, as a\n      sequence of newline-separated JSON data.\n\n      Note: it is important to mind the shell's quoting rules.  As a\n      general rule it's best to always quote (with single-quote\n      characters) the jq program, as too many characters with special\n      meaning to jq are also shell meta-characters.  For example, `jq\n      \"foo\"` will fail on most Unix shells because that will be the same\n      as `jq foo`, which will generally fail because `foo is not\n      defined`.  When using the Windows command shell (cmd.exe) it's\n      best to use double quotes around your jq program when given on the\n      command-line (instead of the `-f program-file` option), but then\n      double-quotes in the jq program need backslash escaping. When using\n      the Powershell (`powershell.exe`) or the Powershell Core\n      (`pwsh`/`pwsh.exe`), use single-quote characters around the jq\n      program and backslash-escaped double-quotes (`\\\"`) inside the jq\n      program.\n\n      * Unix shells: `jq '.[\"foo\"]'`\n      * Powershell: `jq '.[\\\"foo\\\"]'`\n      * Windows command shell: `jq \".[\\\"foo\\\"]\"`\n\n      You can affect how jq reads and writes its input and output\n      using some command-line options:\n\n      * `--null-input` / `-n`:\n\n        Don't read any input at all. Instead, the filter is run once\n        using `null` as the input. This is useful when using jq as a\n        simple calculator or to construct JSON data from scratch.\n\n      * `--raw-input` / `-R`:\n\n        Don't parse the input as JSON. Instead, each line of text is\n        passed to the filter as a string. If combined with `--slurp`,\n        then the entire input is passed to the filter as a single long\n        string.\n\n      * `--slurp` / `-s`:\n\n        Instead of running the filter for each JSON object in the\n        input, read the entire input stream into a large array and run\n        the filter just once.\n\n      * `--compact-output` / `-c`:\n\n        By default, jq pretty-prints JSON output. Using this option\n        will result in more compact output by instead putting each\n        JSON object on a single line.\n\n      * `--raw-output` / `-r`:\n\n        With this option, if the filter's result is a string then it\n        will be written directly to standard output rather than being\n        formatted as a JSON string with quotes. This can be useful for\n        making jq filters talk to non-JSON-based systems.\n\n      * `--join-output` / `-j`:\n\n        Like `-r` but jq won't print a newline after each output.\n\n      * `--ascii-output` / `-a`:\n\n        jq usually outputs non-ASCII Unicode codepoints as UTF-8, even\n        if the input specified them as escape sequences (like\n        \"\\u03bc\"). Using this option, you can force jq to produce pure\n        ASCII output with every non-ASCII character replaced with the\n        equivalent escape sequence.\n\n      * `--sort-keys` / `-S`:\n\n        Output the fields of each object with the keys in sorted order.\n\n      * `--color-output` / `-C` and `--monochrome-output` / `-M`:\n\n        By default, jq outputs colored JSON if writing to a\n        terminal. You can force it to produce color even if writing to\n        a pipe or a file using `-C`, and disable color with `-M`.\n\n        Colors can be configured with the `JQ_COLORS` environment\n        variable (see below).\n\n      * `--tab`:\n\n        Use a tab for each indentation level instead of two spaces.\n\n      * `--indent n`:\n\n        Use the given number of spaces (no more than 7) for indentation.\n\n      * `--unbuffered`:\n\n        Flush the output after each JSON object is printed (useful if\n        you're piping a slow data source into jq and piping jq's\n        output elsewhere).\n\n      * `--stream`:\n\n        Parse the input in streaming fashion, outputting arrays of path\n        and leaf values (scalars and empty arrays or empty objects).\n        For example, `\"a\"` becomes `[[],\"a\"]`, and `[[],\"a\",[\"b\"]]`\n        becomes `[[0],[]]`, `[[1],\"a\"]`, and `[[2,0],\"b\"]`.\n\n        This is useful for processing very large inputs.  Use this in\n        conjunction with filtering and the `reduce` and `foreach` syntax\n        to reduce large inputs incrementally.\n\n      * `--seq`:\n\n        Use the `application/json-seq` MIME type scheme for separating\n        JSON texts in jq's input and output.  This means that an ASCII\n        RS (record separator) character is printed before each value on\n        output and an ASCII LF (line feed) is printed after every\n        output.  Input JSON texts that fail to parse are ignored (but\n        warned about), discarding all subsequent input until the next\n        RS.  This mode also parses the output of jq without the `--seq`\n        option.\n\n      * `-f filename` / `--from-file filename`:\n\n        Read filter from the file rather than from a command line, like\n        awk's -f option. You can also use '#' to make comments.\n\n      * `-L directory`:\n\n        Prepend `directory` to the search list for modules.  If this\n        option is used then no builtin search list is used.  See the\n        section on modules below.\n\n      * `--arg name value`:\n\n        This option passes a value to the jq program as a predefined\n        variable. If you run jq with `--arg foo bar`, then `$foo` is\n        available in the program and has the value `\"bar\"`. Note that\n        `value` will be treated as a string, so `--arg foo 123` will\n        bind `$foo` to `\"123\"`.\n\n        Named arguments are also available to the jq program as\n        `$ARGS.named`.\n\n      * `--argjson name JSON-text`:\n\n        This option passes a JSON-encoded value to the jq program as a\n        predefined variable. If you run jq with `--argjson foo 123`, then\n        `$foo` is available in the program and has the value `123`.\n\n      * `--slurpfile variable-name filename`:\n\n        This option reads all the JSON texts in the named file and binds\n        an array of the parsed JSON values to the given global variable.\n        If you run jq with `--slurpfile foo bar`, then `$foo` is available\n        in the program and has an array whose elements correspond to the\n        texts in the file named `bar`.\n\n      * `--rawfile variable-name filename`:\n\n        This option reads in the named file and binds its content to the given\n        global variable.  If you run jq with `--rawfile foo bar`, then `$foo` is\n        available in the program and has a string whose content is set to the text\n        in the file named `bar`.\n\n      * `--argfile variable-name filename`:\n\n        Do not use.  Use `--slurpfile` instead.\n\n        (This option is like `--slurpfile`, but when the file has just\n        one text, then that is used, else an array of texts is used as\n        in `--slurpfile`.)\n\n      * `--args`:\n\n        Remaining arguments are positional string arguments.  These are\n        available to the jq program as `$ARGS.positional[]`.\n\n      * `--jsonargs`:\n\n        Remaining arguments are positional JSON text arguments.  These\n        are available to the jq program as `$ARGS.positional[]`.\n\n      * `--exit-status` / `-e`:\n\n        Sets the exit status of jq to 0 if the last output value was\n        neither `false` nor `null`, 1 if the last output value was\n        either `false` or `null`, or 4 if no valid result was ever\n        produced.  Normally jq exits with 2 if there was any usage\n        problem or system error, 3 if there was a jq program compile\n        error, or 0 if the jq program ran.\n\n        Another way to set the exit status is with the `halt_error`\n        builtin function.\n\n      * `--version` / `-V`:\n\n        Output the jq version and exit with zero.\n\n      * `--help` / `-h`:\n\n        Output the jq help and exit with zero.\n\n      * `--run-tests [filename]`:\n\n        Runs the tests in the given file or standard input.  This must\n        be the last option given and does not honor all preceding\n        options.  The input consists of comment lines, empty lines, and\n        program lines followed by one input line, as many lines of\n        output as are expected (one per output), and a terminating empty\n        line.  Compilation failure tests start with a line containing\n        only `%%FAIL`, then a line containing the program to compile,\n        then a line containing an error message to compare to the\n        actual.\n\n        Be warned that this option can change backwards-incompatibly.\n\n  - title: Basic filters\n    entries:\n      - title: \"Identity: `.`\"\n        body: |\n\n          The absolute simplest filter is `.` .  This is a filter that\n          takes its input and produces it unchanged as output.  That is,\n          this is the identity operator.\n\n          Since jq by default pretty-prints all output, this trivial\n          program can be a useful way of formatting JSON output from,\n          say, `curl`.\n\n        examples:\n          - program: '.'\n            input: '\"Hello, world!\"'\n            output: ['\"Hello, world!\"']\n\n\n      - title: \"Object Identifier-Index: `.foo`, `.foo.bar`\"\n        body: |\n\n          The simplest *useful* filter is `.foo`. When given a\n          JSON object (aka dictionary or hash) as input, it produces\n          the value at the key \"foo\", or null if there's none present.\n\n          A filter of the form `.foo.bar` is equivalent to `.foo|.bar`.\n\n          This syntax only works for simple, identifier-like keys, that\n          is, keys that are all made of alphanumeric characters and\n          underscore, and which do not start with a digit.\n\n          If the key contains special characters or starts with a digit,\n          you need to surround it with double quotes like this:\n          `.\"foo$\"`, or else `.[\"foo$\"]`.\n\n          For example `.[\"foo::bar\"]` and `.[\"foo.bar\"]` work while\n          `.foo::bar` does not, and `.foo.bar` means `.[\"foo\"].[\"bar\"]`.\n\n        examples:\n          - program: '.foo'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n          - program: '.foo'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n          - program: '.[\"foo\"]'\n            input: '{\"foo\": 42}'\n            output: ['42']\n\n      - title: \"Optional Object Identifier-Index: `.foo?`\"\n        body: |\n\n          Just like `.foo`, but does not output an error when `.` is not an\n          object.\n\n        examples:\n          - program: '.foo?'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n          - program: '.foo?'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n          - program: '.[\"foo\"]?'\n            input: '{\"foo\": 42}'\n            output: ['42']\n          - program: '[.foo?]'\n            input: '[1,2]'\n            output: ['[]']\n\n      - title: \"Object Index: `.[<string>]`\"\n        body: |\n\n          You can also look up fields of an object using syntax like\n          `.[\"foo\"]` (`.foo` above is a shorthand version of this, but\n          only for identifier-like strings).\n\n      - title: \"Array Index: `.[<number>]`\"\n        body: |\n\n          When the index value is an integer, `.[<number>]` can index\n          arrays.  Arrays are zero-based, so `.[2]` returns the third\n          element.\n\n          Negative indices are allowed, with -1 referring to the last\n          element, -2 referring to the next to last element, and so on.\n\n        examples:\n          - program: '.[0]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['{\"name\":\"JSON\", \"good\":true}']\n\n          - program: '.[2]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['null']\n\n          - program: '.[-2]'\n            input: '[1,2,3]'\n            output: ['2']\n\n      - title: \"Array/String Slice: `.[<number>:<number>]`\"\n        body: |\n\n          The `.[<number>:<number>]` syntax can be used to return a\n          subarray of an array or substring of a string. The array\n          returned by `.[10:15]` will be of length 5, containing the\n          elements from index 10 (inclusive) to index 15 (exclusive).\n          Either index may be negative (in which case it counts\n          backwards from the end of the array), or omitted (in which\n          case it refers to the start or end of the array).\n          Indices are zero-based.\n\n        examples:\n          - program: '.[2:4]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"c\", \"d\"]']\n\n          - program: '.[2:4]'\n            input: '\"abcdefghi\"'\n            output: ['\"cd\"']\n\n          - program: '.[:3]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"a\", \"b\", \"c\"]']\n\n          - program: '.[-2:]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"d\", \"e\"]']\n\n      - title: \"Array/Object Value Iterator: `.[]`\"\n        body: |\n\n          If you use the `.[index]` syntax, but omit the index\n          entirely, it will return *all* of the elements of an\n          array. Running `.[]` with the input `[1,2,3]` will produce the\n          numbers as three separate results, rather than as a single\n          array. A filter of the form `.foo[]` is equivalent to\n          `.foo | .[]`.\n\n          You can also use this on an object, and it will return all\n          the values of the object.\n\n        examples:\n          - program: '.[]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output:\n              - '{\"name\":\"JSON\", \"good\":true}'\n              - '{\"name\":\"XML\", \"good\":false}'\n\n          - program: '.[]'\n            input: '[]'\n            output: []\n\n          - program: '.foo[]'\n            input: '{\"foo\":[1,2,3]}'\n            output: ['1','2','3']\n\n          - program: '.[]'\n            input: '{\"a\": 1, \"b\": 1}'\n            output: ['1', '1']\n\n      - title: \"`.[]?`\"\n        body: |\n\n          Like `.[]`, but no errors will be output if . is not an array\n          or object. A filter of the form `.foo[]?` is equivalent to\n          `.foo | .[]?`.\n\n      - title: \"Comma: `,`\"\n        body: |\n\n          If two filters are separated by a comma, then the\n          same input will be fed into both and the two filters' output\n          value streams will be concatenated in order: first, all of the\n          outputs produced by the left expression, and then all of the\n          outputs produced by the right. For instance, filter `.foo,\n          .bar`, produces both the \"foo\" fields and \"bar\" fields as\n          separate outputs.\n\n        examples:\n          - program: '.foo, .bar'\n            input: '{\"foo\": 42, \"bar\": \"something else\", \"baz\": true}'\n            output: ['42', '\"something else\"']\n\n          - program: \".user, .projects[]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['\"stedolan\"', '\"jq\"', '\"wikiflow\"']\n\n          - program: '.[4,2]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['\"e\"', '\"c\"']\n\n      - title: \"Pipe: `|`\"\n        body: |\n\n          The | operator combines two filters by feeding the output(s) of\n          the one on the left into the input of the one on the right. It's\n          pretty much the same as the Unix shell's pipe, if you're used to\n          that.\n\n          If the one on the left produces multiple results, the one on\n          the right will be run for each of those results. So, the\n          expression `.[] | .foo` retrieves the \"foo\" field of each\n          element of the input array.\n\n          Note that `.a.b.c` is the same as `.a | .b | .c`.\n\n          Note too that `.` is the input value at the particular stage\n          in a \"pipeline\", specifically: where the `.` expression appears.\n          Thus `.a | . | .b` is the same as `.a.b`, as the `.` in the\n          middle refers to whatever value `.a` produced.\n\n        examples:\n          - program: '.[] | .name'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['\"JSON\"', '\"XML\"']\n\n      - title: \"Parenthesis\"\n        body: |\n\n          Parenthesis work as a grouping operator just as in any typical\n          programming language.\n\n        examples:\n          - program: '(. + 2) * 5'\n            input: '1'\n            output: ['15']\n\n  - title: Types and Values\n    body: |\n\n      jq supports the same set of datatypes as JSON - numbers,\n      strings, booleans, arrays, objects (which in JSON-speak are\n      hashes with only string keys), and \"null\".\n\n      Booleans, null, strings and numbers are written the same way as\n      in JSON. Just like everything else in jq, these simple\n      values take an input and produce an output - `42` is a valid jq\n      expression that takes an input, ignores it, and returns 42\n      instead.\n\n    entries:\n      - title: \"Array construction: `[]`\"\n        body: |\n\n          As in JSON, `[]` is used to construct arrays, as in\n          `[1,2,3]`. The elements of the arrays can be any jq\n          expression, including a pipeline. All of the results produced\n          by all of the expressions are collected into one big array.\n          You can use it to construct an array out of a known quantity\n          of values (as in `[.foo, .bar, .baz]`) or to \"collect\" all the\n          results of a filter into an array (as in `[.items[].name]`)\n\n          Once you understand the \",\" operator, you can look at jq's array\n          syntax in a different light: the expression `[1,2,3]` is not using a\n          built-in syntax for comma-separated arrays, but is instead applying\n          the `[]` operator (collect results) to the expression 1,2,3 (which\n          produces three different results).\n\n          If you have a filter `X` that produces four results,\n          then the expression `[X]` will produce a single result, an\n          array of four elements.\n\n        examples:\n          - program: \"[.user, .projects[]]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['[\"stedolan\", \"jq\", \"wikiflow\"]']\n          - program: \"[ .[] | . * 2]\"\n            input: '[1, 2, 3]'\n            output: ['[2, 4, 6]']\n\n      - title: \"Object Construction: `{}`\"\n        body: |\n\n          Like JSON, `{}` is for constructing objects (aka\n          dictionaries or hashes), as in: `{\"a\": 42, \"b\": 17}`.\n\n          If the keys are \"identifier-like\", then the quotes can be left\n          off, as in `{a:42, b:17}`.  Keys generated by expressions need\n          to be parenthesized, e.g., `{(\"a\"+\"b\"):59}`.\n\n          The value can be any expression (although you may need to\n          wrap it in parentheses if it's a complicated one), which gets\n          applied to the {} expression's input (remember, all filters\n          have an input and an output).\n\n              {foo: .bar}\n\n          will produce the JSON object `{\"foo\": 42}` if given the JSON\n          object `{\"bar\":42, \"baz\":43}` as its input. You can use this\n          to select particular fields of an object: if the input is an\n          object with \"user\", \"title\", \"id\", and \"content\" fields and\n          you just want \"user\" and \"title\", you can write\n\n              {user: .user, title: .title}\n\n          Because that is so common, there's a shortcut syntax for it:\n          `{user, title}`.\n\n          If one of the expressions produces multiple results,\n          multiple dictionaries will be produced. If the input's\n\n              {\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n\n          then the expression\n\n              {user, title: .titles[]}\n\n          will produce two outputs:\n\n              {\"user\":\"stedolan\", \"title\": \"JQ Primer\"}\n              {\"user\":\"stedolan\", \"title\": \"More JQ\"}\n\n          Putting parentheses around the key means it will be evaluated as an\n          expression. With the same input as above,\n\n              {(.user): .titles}\n\n          produces\n\n              {\"stedolan\": [\"JQ Primer\", \"More JQ\"]}\n\n        examples:\n          - program: '{user, title: .titles[]}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output:\n              - '{\"user\":\"stedolan\", \"title\": \"JQ Primer\"}'\n              - '{\"user\":\"stedolan\", \"title\": \"More JQ\"}'\n          - program: '{(.user): .titles}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output: ['{\"stedolan\": [\"JQ Primer\", \"More JQ\"]}']\n\n      - title: \"Recursive Descent: `..`\"\n        body: |\n\n          Recursively descends `.`, producing every value.  This is the\n          same as the zero-argument `recurse` builtin (see below).  This\n          is intended to resemble the XPath `//` operator.  Note that\n          `..a` does not work; use `.. | .a` instead.  In the example\n          below we use `.. | .a?` to find all the values of object keys\n          \"a\" in any object found \"below\" `.`.\n\n          This is particularly useful in conjunction with `path(EXP)`\n          (also see below) and the `?` operator.\n\n        examples:\n          - program: '.. | .a?'\n            input: '[[{\"a\":1}]]'\n            output: ['1']\n\n  - title: Builtin operators and functions\n    body: |\n\n      Some jq operators (for instance, `+`) do different things\n      depending on the type of their arguments (arrays, numbers,\n      etc.). However, jq never does implicit type conversions. If you\n      try to add a string to an object you'll get an error message and\n      no result.\n\n    entries:\n      - title: \"Addition: `+`\"\n        body: |\n\n          The operator `+` takes two filters, applies them both\n          to the same input, and adds the results together. What\n          \"adding\" means depends on the types involved:\n\n          - **Numbers** are added by normal arithmetic.\n\n          - **Arrays** are added by being concatenated into a larger array.\n\n          - **Strings** are added by being joined into a larger string.\n\n          - **Objects** are added by merging, that is, inserting all\n            the key-value pairs from both objects into a single\n            combined object. If both objects contain a value for the\n            same key, the object on the right of the `+` wins. (For\n            recursive merge use the `*` operator.)\n\n          `null` can be added to any value, and returns the other\n          value unchanged.\n\n        examples:\n          - program: '.a + 1'\n            input: '{\"a\": 7}'\n            output: ['8']\n          - program: '.a + .b'\n            input: '{\"a\": [1,2], \"b\": [3,4]}'\n            output: ['[1,2,3,4]']\n          - program: '.a + null'\n            input: '{\"a\": 1}'\n            output: ['1']\n          - program: '.a + 1'\n            input: '{}'\n            output: ['1']\n          - program: '{a: 1} + {b: 2} + {c: 3} + {a: 42}'\n            input: 'null'\n            output: ['{\"a\": 42, \"b\": 2, \"c\": 3}']\n\n      - title: \"Subtraction: `-`\"\n        body: |\n\n          As well as normal arithmetic subtraction on numbers, the `-`\n          operator can be used on arrays to remove all occurrences of\n          the second array's elements from the first array.\n\n        examples:\n          - program: '4 - .a'\n            input: '{\"a\":3}'\n            output: ['1']\n          - program: . - [\"xml\", \"yaml\"]\n            input: '[\"xml\", \"yaml\", \"json\"]'\n            output: ['[\"json\"]']\n\n      - title: \"Multiplication, division, modulo: `*`, `/`, `%`\"\n        body: |\n\n          These infix operators behave as expected when given two numbers.\n          Division by zero raises an error. `x % y` computes x modulo y.\n\n          Multiplying a string by a number produces the concatenation of\n          that string that many times. `\"x\" * 0` produces **null**.\n\n          Dividing a string by another splits the first using the second\n          as separators.\n\n          Multiplying two objects will merge them recursively: this works\n          like addition but if both objects contain a value for the\n          same key, and the values are objects, the two are merged with\n          the same strategy.\n\n        examples:\n          - program: '10 / . * 3'\n            input: '5'\n            output: ['6']\n          - program: '. / \", \"'\n            input: '\"a, b,c,d, e\"'\n            output: ['[\"a\",\"b,c,d\",\"e\"]']\n          - program: '{\"k\": {\"a\": 1, \"b\": 2}} * {\"k\": {\"a\": 0,\"c\": 3}}'\n            input: 'null'\n            output: ['{\"k\": {\"a\": 0, \"b\": 2, \"c\": 3}}']\n          - program: '.[] | (1 / .)?'\n            input: '[1,0,-1]'\n            output: ['1', '-1']\n\n\n      - title: \"`length`\"\n        body: |\n\n          The builtin function `length` gets the length of various\n          different types of value:\n\n          - The length of a **string** is the number of Unicode\n            codepoints it contains (which will be the same as its\n            JSON-encoded length in bytes if it's pure ASCII).\n\n          - The length of a **number** is its absolute value.\n\n          - The length of an **array** is the number of elements.\n\n          - The length of an **object** is the number of key-value pairs.\n\n          - The length of **null** is zero.\n\n          - It is an error to use `length` on a **boolean**.\n\n        examples:\n          - program: '.[] | length'\n            input: '[[1,2], \"string\", {\"a\":2}, null, -5]'\n            output: ['2', '6', '1', '0', '5']\n\n\n      - title: \"`utf8bytelength`\"\n        body: |\n\n          The builtin function `utf8bytelength` outputs the number of\n          bytes used to encode a string in UTF-8.\n\n        examples:\n          - program: 'utf8bytelength'\n            input: '\"\\u03bc\"'\n            output: ['2']\n\n      - title: \"`keys`, `keys_unsorted`\"\n        body: |\n\n          The builtin function `keys`, when given an object, returns\n          its keys in an array.\n\n          The keys are sorted \"alphabetically\", by unicode codepoint\n          order. This is not an order that makes particular sense in\n          any particular language, but you can count on it being the\n          same for any two objects with the same set of keys,\n          regardless of locale settings.\n\n          When `keys` is given an array, it returns the valid indices\n          for that array: the integers from 0 to length-1.\n\n          The `keys_unsorted` function is just like `keys`, but if\n          the input is an object then the keys will not be sorted,\n          instead the keys will roughly be in insertion order.\n\n        examples:\n          - program: 'keys'\n            input: '{\"abc\": 1, \"abcd\": 2, \"Foo\": 3}'\n            output: ['[\"Foo\", \"abc\", \"abcd\"]']\n          - program: 'keys'\n            input: '[42,3,35]'\n            output: ['[0,1,2]']\n\n      - title: \"`has(key)`\"\n        body: |\n\n          The builtin function `has` returns whether the input object\n          has the given key, or the input array has an element at the\n          given index.\n\n          `has($key)` has the same effect as checking whether `$key`\n          is a member of the array returned by `keys`, although `has`\n          will be faster.\n\n        examples:\n          - program: 'map(has(\"foo\"))'\n            input: '[{\"foo\": 42}, {}]'\n            output: ['[true, false]']\n          - program: 'map(has(2))'\n            input: '[[0,1], [\"a\",\"b\",\"c\"]]'\n            output: ['[false, true]']\n\n      - title: \"`in`\"\n        body: |\n\n          The builtin function `in` returns whether or not the input key is in the\n          given object, or the input index corresponds to an element\n          in the given array. It is, essentially, an inversed version\n          of `has`.\n\n        examples:\n          - program: '.[] | in({\"foo\": 42})'\n            input: '[\"foo\", \"bar\"]'\n            output: ['true', 'false']\n          - program: 'map(in([0,1]))'\n            input: '[2, 0]'\n            output: ['[false, true]']\n\n      - title: \"`map(f)`, `map_values(f)`\"\n        body: |\n\n          For any filter `f`, `map(f)` will run that filter for each\n          element of the input array, and return the outputs in a new\n          array. `map(.+1)` will increment each element of an array of numbers.\n\n          Similarly, `map_values(f)` will run that filter for each element,\n          but it will return an object when an object is passed.\n\n          `map(f)` is equivalent to `[.[] | f]`. In fact, this is how\n          it's defined. Similarly, `map_values(f)` is defined as `.[] |= f`.\n\n        examples:\n          - program: 'map(.+1)'\n            input: '[1,2,3]'\n            output: ['[2,3,4]']\n\n          - program: 'map_values(.+1)'\n            input: '{\"a\": 1, \"b\": 2, \"c\": 3}'\n            output: ['{\"a\": 2, \"b\": 3, \"c\": 4}']\n\n      - title: \"`path(path_expression)`\"\n        body: |\n\n          Outputs array representations of the given path expression\n          in `.`.  The outputs are arrays of strings (object keys)\n          and/or numbers (array indices).\n\n          Path expressions are jq expressions like `.a`, but also `.[]`.\n          There are two types of path expressions: ones that can match\n          exactly, and ones that cannot.  For example, `.a.b.c` is an\n          exact match path expression, while `.a[].b` is not.\n\n          `path(exact_path_expression)` will produce the array\n          representation of the path expression even if it does not\n          exist in `.`, if `.` is `null` or an array or an object.\n\n          `path(pattern)` will produce array representations of the\n          paths matching `pattern` if the paths exist in `.`.\n\n          Note that the path expressions are not different from normal\n          expressions.  The expression\n          `path(..|select(type==\"boolean\"))` outputs all the paths to\n          boolean values in `.`, and only those paths.\n\n        examples:\n          - program: 'path(.a[0].b)'\n            input: 'null'\n            output: ['[\"a\",0,\"b\"]']\n          - program: '[path(..)]'\n            input: '{\"a\":[{\"b\":1}]}'\n            output: ['[[],[\"a\"],[\"a\",0],[\"a\",0,\"b\"]]']\n\n      - title: \"`del(path_expression)`\"\n        body: |\n\n          The builtin function `del` removes a key and its corresponding\n          value from an object.\n\n        examples:\n          - program: 'del(.foo)'\n            input: '{\"foo\": 42, \"bar\": 9001, \"baz\": 42}'\n            output: ['{\"bar\": 9001, \"baz\": 42}']\n          - program: 'del(.[1, 2])'\n            input: '[\"foo\", \"bar\", \"baz\"]'\n            output: ['[\"foo\"]']\n\n      - title: \"`getpath(PATHS)`\"\n        body: |\n\n          The builtin function `getpath` outputs the values in `.` found\n          at each path in `PATHS`.\n\n        examples:\n          - program: 'getpath([\"a\",\"b\"])'\n            input: 'null'\n            output: ['null']\n          - program: '[getpath([\"a\",\"b\"], [\"a\",\"c\"])]'\n            input: '{\"a\":{\"b\":0, \"c\":1}}'\n            output: ['[0, 1]']\n\n      - title: \"`setpath(PATHS; VALUE)`\"\n        body: |\n\n          The builtin function `setpath` sets the `PATHS` in `.` to `VALUE`.\n\n        examples:\n          - program: 'setpath([\"a\",\"b\"]; 1)'\n            input: 'null'\n            output: ['{\"a\": {\"b\": 1}}']\n          - program: 'setpath([\"a\",\"b\"]; 1)'\n            input: '{\"a\":{\"b\":0}}'\n            output: ['{\"a\": {\"b\": 1}}']\n          - program: 'setpath([0,\"a\"]; 1)'\n            input: 'null'\n            output: ['[{\"a\":1}]']\n\n      - title: \"`delpaths(PATHS)`\"\n        body: |\n\n          The builtin function `delpaths` sets the `PATHS` in `.`.\n          `PATHS` must be an array of paths, where each path is an array\n          of strings and numbers.\n\n        examples:\n          - program: 'delpaths([[\"a\",\"b\"]])'\n            input: '{\"a\":{\"b\":1},\"x\":{\"y\":2}}'\n            output: ['{\"a\":{},\"x\":{\"y\":2}}']\n\n      - title: \"`to_entries`, `from_entries`, `with_entries(f)`\"\n        body: |\n\n          These functions convert between an object and an array of\n          key-value pairs. If `to_entries` is passed an object, then\n          for each `k: v` entry in the input, the output array\n          includes `{\"key\": k, \"value\": v}`.\n\n          `from_entries` does the opposite conversion, and `with_entries(f)`\n          is a shorthand for `to_entries | map(f) | from_entries`, useful for\n          doing some operation to all keys and values of an object.\n          `from_entries` accepts `\"key\"`, `\"Key\"`, `\"name\"`, `\"Name\"`,\n          `\"value\"`, and `\"Value\"` as keys.\n\n        examples:\n          - program: 'to_entries'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]']\n          - program: 'from_entries'\n            input: '[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]'\n            output: ['{\"a\": 1, \"b\": 2}']\n          - program: 'with_entries(.key |= \"KEY_\" + .)'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['{\"KEY_a\": 1, \"KEY_b\": 2}']\n\n\n      - title: \"`select(boolean_expression)`\"\n        body: |\n\n          The function `select(f)` produces its input unchanged if\n          `f` returns true for that input, and produces no output\n          otherwise.\n\n          It's useful for filtering lists: `[1,2,3] | map(select(. >= 2))`\n          will give you `[2,3]`.\n\n        examples:\n          - program: 'map(select(. >= 2))'\n            input: '[1,5,3,0,7]'\n            output: ['[5,3,7]']\n          - program: '.[] | select(.id == \"second\")'\n            input: '[{\"id\": \"first\", \"val\": 1}, {\"id\": \"second\", \"val\": 2}]'\n            output: ['{\"id\": \"second\", \"val\": 2}']\n\n\n      - title: \"`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `normals`, `finites`, `strings`, `nulls`, `values`, `scalars`\"\n        body: |\n\n          These built-ins select only inputs that are arrays, objects,\n          iterables (arrays or objects), booleans, numbers, normal\n          numbers, finite numbers, strings, null, non-null values, and\n          non-iterables, respectively.\n\n        examples:\n          - program: '.[]|numbers'\n            input: '[[],{},1,\"foo\",null,true,false]'\n            output: ['1']\n\n      - title: \"`empty`\"\n        body: |\n\n          `empty` returns no results. None at all. Not even `null`.\n\n          It's useful on occasion. You'll know if you need it :)\n\n        examples:\n          - program: '1, empty, 2'\n            input: 'null'\n            output: ['1', '2']\n          - program: '[1,2,empty,3]'\n            input: 'null'\n            output: ['[1,2,3]']\n\n      - title: \"`error`, `error(message)`\"\n        body: |\n\n          Produces an error with the input value, or with the message\n          given as the argument. Errors can be caught with try/catch;\n          see below.\n\n          When the error value is `null`, it produces nothing and works\n          just like `empty`. So `[null | error]` and `[error(null)]` both\n          emit `[]`.\n\n        examples:\n          - program: 'try error catch .'\n            input: '\"error message\"'\n            output: ['\"error message\"']\n\n          - program: 'try error(\"invalid value: \\(.)\") catch .'\n            input: '42'\n            output: ['\"invalid value: 42\"']\n\n      - title: \"`halt`\"\n        body: |\n\n          Stops the jq program with no further outputs.  jq will exit\n          with exit status `0`.\n\n      - title: \"`halt_error`, `halt_error(exit_code)`\"\n        body: |\n\n          Stops the jq program with no further outputs.  The input will\n          be printed on `stderr` as raw output (i.e., strings will not\n          have double quotes) with no decoration, not even a newline.\n\n          The given `exit_code` (defaulting to `5`) will be jq's exit\n          status.\n\n          For example, `\"Error: something went wrong\\n\"|halt_error(1)`.\n\n      - title: \"`$__loc__`\"\n        body: |\n\n          Produces an object with a \"file\" key and a \"line\" key, with\n          the filename and line number where `$__loc__` occurs, as\n          values.\n\n        examples:\n          - program: 'try error(\"\\($__loc__)\") catch .'\n            input: 'null'\n            output: ['\"{\\\"file\\\":\\\"<top-level>\\\",\\\"line\\\":1}\"']\n\n      - title: \"`paths`, `paths(node_filter)`, `leaf_paths`\"\n        body: |\n\n          `paths` outputs the paths to all the elements in its input\n          (except it does not output the empty list, representing .\n          itself).\n\n          `paths(f)` outputs the paths to any values for which `f` is `true`.\n          That is, `paths(type == \"number\")` outputs the paths to all numeric\n          values.\n\n          `leaf_paths` is an alias of `paths(scalars)`; `leaf_paths` is\n          *deprecated* and will be removed in the next major release.\n\n        examples:\n          - program: '[paths]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1],[1,0],[1,1],[1,1,\"a\"]]']\n          - program: '[paths(type == \"number\")]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1,1,\"a\"]]']\n\n      - title: \"`add`\"\n        body: |\n\n          The filter `add` takes as input an array, and produces as\n          output the elements of the array added together. This might\n          mean summed, concatenated or merged depending on the types\n          of the elements of the input array - the rules are the same\n          as those for the `+` operator (described above).\n\n          If the input is an empty array, `add` returns `null`.\n\n        examples:\n          - program: add\n            input: '[\"a\",\"b\",\"c\"]'\n            output: ['\"abc\"']\n          - program: add\n            input: '[1, 2, 3]'\n            output: ['6']\n          - program: add\n            input: '[]'\n            output: [\"null\"]\n\n      - title: \"`any`, `any(condition)`, `any(generator; condition)`\"\n        body: |\n\n          The filter `any` takes as input an array of boolean values,\n          and produces `true` as output if any of the elements of\n          the array are `true`.\n\n          If the input is an empty array, `any` returns `false`.\n\n          The `any(condition)` form applies the given condition to the\n          elements of the input array.\n\n          The `any(generator; condition)` form applies the given\n          condition to all the outputs of the given generator.\n\n        examples:\n          - program: any\n            input: '[true, false]'\n            output: [\"true\"]\n          - program: any\n            input: '[false, false]'\n            output: [\"false\"]\n          - program: any\n            input: '[]'\n            output: [\"false\"]\n\n      - title: \"`all`, `all(condition)`, `all(generator; condition)`\"\n        body: |\n\n          The filter `all` takes as input an array of boolean values,\n          and produces `true` as output if all of the elements of\n          the array are `true`.\n\n          The `all(condition)` form applies the given condition to the\n          elements of the input array.\n\n          The `all(generator; condition)` form applies the given\n          condition to all the outputs of the given generator.\n\n          If the input is an empty array, `all` returns `true`.\n\n        examples:\n          - program: all\n            input: '[true, false]'\n            output: [\"false\"]\n          - program: all\n            input: '[true, true]'\n            output: [\"true\"]\n          - program: all\n            input: '[]'\n            output: [\"true\"]\n\n      - title: \"`flatten`, `flatten(depth)`\"\n        body: |\n\n          The filter `flatten` takes as input an array of nested arrays,\n          and produces a flat array in which all arrays inside the original\n          array have been recursively replaced by their values. You can pass\n          an argument to it to specify how many levels of nesting to flatten.\n\n          `flatten(2)` is like `flatten`, but going only up to two\n          levels deep.\n\n        examples:\n          - program: flatten\n            input: '[1, [2], [[3]]]'\n            output: [\"[1, 2, 3]\"]\n          - program: flatten(1)\n            input: '[1, [2], [[3]]]'\n            output: [\"[1, 2, [3]]\"]\n          - program: flatten\n            input: '[[]]'\n            output: [\"[]\"]\n          - program: flatten\n            input: '[{\"foo\": \"bar\"}, [{\"foo\": \"baz\"}]]'\n            output: ['[{\"foo\": \"bar\"}, {\"foo\": \"baz\"}]']\n\n      - title: \"`range(upto)`, `range(from; upto)`, `range(from; upto; by)`\"\n        body: |\n\n          The `range` function produces a range of numbers. `range(4; 10)`\n          produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers\n          are produced as separate outputs. Use `[range(4; 10)]` to get a range as\n          an array.\n\n          The one argument form generates numbers from 0 to the given\n          number, with an increment of 1.\n\n          The two argument form generates numbers from `from` to `upto`\n          with an increment of 1.\n\n          The three argument form generates numbers `from` to `upto`\n          with an increment of `by`.\n\n        examples:\n          - program: 'range(2; 4)'\n            input: 'null'\n            output: ['2', '3']\n          - program: '[range(2; 4)]'\n            input: 'null'\n            output: ['[2,3]']\n          - program: '[range(4)]'\n            input: 'null'\n            output: ['[0,1,2,3]']\n          - program: '[range(0; 10; 3)]'\n            input: 'null'\n            output: ['[0,3,6,9]']\n          - program: '[range(0; 10; -1)]'\n            input: 'null'\n            output: ['[]']\n          - program: '[range(0; -5; -1)]'\n            input: 'null'\n            output: ['[0,-1,-2,-3,-4]']\n\n      - title: \"`floor`\"\n        body: |\n\n          The `floor` function returns the floor of its numeric input.\n\n        examples:\n          - program: 'floor'\n            input: '3.14159'\n            output: ['3']\n\n      - title: \"`sqrt`\"\n        body: |\n\n          The `sqrt` function returns the square root of its numeric input.\n\n        examples:\n          - program: 'sqrt'\n            input: '9'\n            output: ['3']\n\n      - title: \"`tonumber`\"\n        body: |\n\n          The `tonumber` function parses its input as a number. It\n          will convert correctly-formatted strings to their numeric\n          equivalent, leave numbers alone, and give an error on all other input.\n\n        examples:\n          - program: '.[] | tonumber'\n            input: '[1, \"1\"]'\n            output: ['1', '1']\n\n      - title: \"`tostring`\"\n        body: |\n\n          The `tostring` function prints its input as a\n          string. Strings are left unchanged, and all other values are\n          JSON-encoded.\n\n        examples:\n          - program: '.[] | tostring'\n            input: '[1, \"1\", [1]]'\n            output: ['\"1\"', '\"1\"', '\"[1]\"']\n\n      - title: \"`type`\"\n        body: |\n\n          The `type` function returns the type of its argument as a\n          string, which is one of null, boolean, number, string, array\n          or object.\n\n        examples:\n          - program: 'map(type)'\n            input: '[0, false, [], {}, null, \"hello\"]'\n            output: ['[\"number\", \"boolean\", \"array\", \"object\", \"null\", \"string\"]']\n\n      - title: \"`infinite`, `nan`, `isinfinite`, `isnan`, `isfinite`, `isnormal`\"\n        body: |\n\n          Some arithmetic operations can yield infinities and \"not a\n          number\" (NaN) values.  The `isinfinite` builtin returns `true`\n          if its input is infinite.  The `isnan` builtin returns `true`\n          if its input is a NaN.  The `infinite` builtin returns a\n          positive infinite value.  The `nan` builtin returns a NaN.\n          The `isnormal` builtin returns true if its input is a normal\n          number.\n\n          Note that division by zero raises an error.\n\n          Currently most arithmetic operations operating on infinities,\n          NaNs, and sub-normals do not raise errors.\n\n        examples:\n          - program: '.[] | (infinite * .) < 0'\n            input: '[-1, 1]'\n            output: ['true', 'false']\n          - program: 'infinite, nan | type'\n            input: 'null'\n            output: ['\"number\"', '\"number\"']\n\n      - title: \"`sort`, `sort_by(path_expression)`\"\n        body: |\n\n          The `sort` functions sorts its input, which must be an\n          array. Values are sorted in the following order:\n\n          * `null`\n          * `false`\n          * `true`\n          * numbers\n          * strings, in alphabetical order (by unicode codepoint value)\n          * arrays, in lexical order\n          * objects\n\n          The ordering for objects is a little complex: first they're\n          compared by comparing their sets of keys (as arrays in\n          sorted order), and if their keys are equal then the values\n          are compared key by key.\n\n          `sort_by` may be used to sort by a particular field of an\n          object, or by applying any jq filter. `sort_by(f)` compares\n          two elements by comparing the result of `f` on each element.\n          When `f` produces multiple values, it firstly compares the\n          first values, and the second values if the first values are\n          equal, and so on.\n\n        examples:\n          - program: 'sort'\n            input: '[8,3,null,6]'\n            output: ['[null,3,6,8]']\n\n          - program: 'sort_by(.foo)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":10}, {\"foo\":2, \"bar\":1}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":4, \"bar\":10}]']\n\n          - program: 'sort_by(.foo, .bar)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":4, \"bar\":10}]']\n\n      - title: \"`group_by(path_expression)`\"\n        body: |\n\n          `group_by(.foo)` takes as input an array, groups the\n          elements having the same `.foo` field into separate arrays,\n          and produces all of these arrays as elements of a larger\n          array, sorted by the value of the `.foo` field.\n\n          Any jq expression, not just a field access, may be used in\n          place of `.foo`. The sorting order is the same as described\n          in the `sort` function above.\n\n        examples:\n          - program: 'group_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":10}, {\"foo\":3, \"bar\":100}, {\"foo\":1, \"bar\":1}]'\n            output: ['[[{\"foo\":1, \"bar\":10}, {\"foo\":1, \"bar\":1}], [{\"foo\":3, \"bar\":100}]]']\n\n      - title: \"`min`, `max`, `min_by(path_exp)`, `max_by(path_exp)`\"\n        body: |\n\n          Find the minimum or maximum element of the input array.\n\n          The `min_by(path_exp)` and `max_by(path_exp)` functions allow\n          you to specify a particular field or property to examine, e.g.\n          `min_by(.foo)` finds the object with the smallest `foo` field.\n\n        examples:\n          - program: 'min'\n            input: '[5,4,2,7]'\n            output: ['2']\n          - program: 'max_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":14}, {\"foo\":2, \"bar\":3}]'\n            output: ['{\"foo\":2, \"bar\":3}']\n\n      - title: \"`unique`, `unique_by(path_exp)`\"\n        body: |\n\n          The `unique` function takes as input an array and produces\n          an array of the same elements, in sorted order, with\n          duplicates removed.\n\n          The `unique_by(path_exp)` function will keep only one element\n          for each value obtained by applying the argument. Think of it\n          as making an array by taking one element out of every group\n          produced by `group`.\n\n        examples:\n          - program: 'unique'\n            input: '[1,2,5,3,5,3,1,3]'\n            output: ['[1,2,3,5]']\n          - program: 'unique_by(.foo)'\n            input: '[{\"foo\": 1, \"bar\": 2}, {\"foo\": 1, \"bar\": 3}, {\"foo\": 4, \"bar\": 5}]'\n            output: ['[{\"foo\": 1, \"bar\": 2}, {\"foo\": 4, \"bar\": 5}]']\n          - program: 'unique_by(length)'\n            input: '[\"chunky\", \"bacon\", \"kitten\", \"cicada\", \"asparagus\"]'\n            output: ['[\"bacon\", \"chunky\", \"asparagus\"]']\n\n      - title: \"`reverse`\"\n        body: |\n\n          This function reverses an array.\n\n        examples:\n          - program: 'reverse'\n            input: '[1,2,3,4]'\n            output: ['[4,3,2,1]']\n\n      - title: \"`contains(element)`\"\n        body: |\n\n          The filter `contains(b)` will produce true if b is\n          completely contained within the input. A string B is\n          contained in a string A if B is a substring of A. An array B\n          is contained in an array A if all elements in B are\n          contained in any element in A. An object B is contained in\n          object A if all of the values in B are contained in the\n          value in A with the same key. All other types are assumed to\n          be contained in each other if they are equal.\n\n        examples:\n          - program: 'contains(\"bar\")'\n            input: '\"foobar\"'\n            output: ['true']\n          - program: 'contains([\"baz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['true']\n          - program: 'contains([\"bazzzzz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['false']\n          - program: 'contains({foo: 12, bar: [{barp: 12}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['true']\n          - program: 'contains({foo: 12, bar: [{barp: 15}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['false']\n\n      - title: \"`indices(s)`\"\n        body: |\n\n          Outputs an array containing the indices in `.` where `s`\n          occurs.  The input may be an array, in which case if `s` is an\n          array then the indices output will be those where all elements\n          in `.` match those of `s`.\n\n        examples:\n          - program: 'indices(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['[3,7,12]']\n          - program: 'indices(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['[1,3,5]']\n          - program: 'indices([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['[1,8]']\n\n      - title: \"`index(s)`, `rindex(s)`\"\n        body: |\n\n          Outputs the index of the first (`index`) or last (`rindex`)\n          occurrence of `s` in the input.\n\n        examples:\n          - program: 'index(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['3']\n          - program: 'index(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['1']\n          - program: 'index([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['1']\n          - program: 'rindex(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['12']\n          - program: 'rindex(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['5']\n          - program: 'rindex([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['8']\n\n      - title: \"`inside`\"\n        body: |\n\n          The filter `inside(b)` will produce true if the input is\n          completely contained within b. It is, essentially, an\n          inversed version of `contains`.\n\n        examples:\n          - program: 'inside(\"foobar\")'\n            input: '\"bar\"'\n            output: ['true']\n          - program: 'inside([\"foobar\", \"foobaz\", \"blarp\"])'\n            input: '[\"baz\", \"bar\"]'\n            output: ['true']\n          - program: 'inside([\"foobar\", \"foobaz\", \"blarp\"])'\n            input: '[\"bazzzzz\", \"bar\"]'\n            output: ['false']\n          - program: 'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})'\n            input: '{\"foo\": 12, \"bar\": [{\"barp\": 12}]}'\n            output: ['true']\n          - program: 'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})'\n            input: '{\"foo\": 12, \"bar\": [{\"barp\": 15}]}'\n            output: ['false']\n\n      - title: \"`startswith(str)`\"\n        body: |\n\n          Outputs `true` if . starts with the given string argument.\n\n        examples:\n          - program: '[.[]|startswith(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"barfoob\"]'\n            output: ['[false, true, false, true, false]']\n\n      - title: \"`endswith(str)`\"\n        body: |\n\n          Outputs `true` if . ends with the given string argument.\n\n        examples:\n          - program: '[.[]|endswith(\"foo\")]'\n            input: '[\"foobar\", \"barfoo\"]'\n            output: ['[false, true]']\n\n      - title: \"`combinations`, `combinations(n)`\"\n        body: |\n\n          Outputs all combinations of the elements of the arrays in the\n          input array. If given an argument `n`, it outputs all combinations\n          of `n` repetitions of the input array.\n\n        examples:\n          - program: 'combinations'\n            input: '[[1,2], [3, 4]]'\n            output: ['[1, 3]', '[1, 4]', '[2, 3]', '[2, 4]']\n          - program: 'combinations(2)'\n            input: '[0, 1]'\n            output: ['[0, 0]', '[0, 1]', '[1, 0]', '[1, 1]']\n\n      - title: \"`ltrimstr(str)`\"\n        body: |\n\n          Outputs its input with the given prefix string removed, if it\n          starts with it.\n\n        examples:\n          - program: '[.[]|ltrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"afoo\"]'\n            output: ['[\"fo\",\"\",\"barfoo\",\"bar\",\"afoo\"]']\n\n      - title: \"`rtrimstr(str)`\"\n        body: |\n\n          Outputs its input with the given suffix string removed, if it\n          ends with it.\n\n        examples:\n          - program: '[.[]|rtrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"foob\"]'\n            output: ['[\"fo\",\"\",\"bar\",\"foobar\",\"foob\"]']\n\n      - title: \"`explode`\"\n        body: |\n\n          Converts an input string into an array of the string's\n          codepoint numbers.\n\n        examples:\n          - program: 'explode'\n            input: '\"foobar\"'\n            output: ['[102,111,111,98,97,114]']\n\n      - title: \"`implode`\"\n        body: |\n\n          The inverse of explode.\n\n        examples:\n          - program: 'implode'\n            input: '[65, 66, 67]'\n            output: ['\"ABC\"']\n\n      - title: \"`split(str)`\"\n        body: |\n\n          Splits an input string on the separator argument.\n\n        examples:\n          - program: 'split(\", \")'\n            input: '\"a, b,c,d, e, \"'\n            output: ['[\"a\",\"b,c,d\",\"e\",\"\"]']\n\n      - title: \"`join(str)`\"\n        body: |\n\n          Joins the array of elements given as input, using the\n          argument as separator. It is the inverse of `split`: that is,\n          running `split(\"foo\") | join(\"foo\")` over any input string\n          returns said input string.\n\n          Numbers and booleans in the input are converted to strings.\n          Null values are treated as empty strings. Arrays and objects\n          in the input are not supported.\n\n        examples:\n          - program: 'join(\", \")'\n            input: '[\"a\",\"b,c,d\",\"e\"]'\n            output: ['\"a, b,c,d, e\"']\n          - program: 'join(\" \")'\n            input: '[\"a\",1,2.3,true,null,false]'\n            output: ['\"a 1 2.3 true  false\"']\n\n      - title: \"`ascii_downcase`, `ascii_upcase`\"\n        body: |\n\n          Emit a copy of the input string with its alphabetic characters (a-z and A-Z)\n          converted to the specified case.\n\n        examples:\n          - program: 'ascii_upcase'\n            input: '\"useful but not for é\"'\n            output: ['\"USEFUL BUT NOT FOR é\"']\n\n      - title: \"`while(cond; update)`\"\n        body: |\n\n          The `while(cond; update)` function allows you to repeatedly\n          apply an update to `.` until `cond` is false.\n\n          Note that `while(cond; update)` is internally defined as a\n          recursive jq function.  Recursive calls within `while` will\n          not consume additional memory if `update` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[while(.<100; .*2)]'\n            input: '1'\n            output: ['[1,2,4,8,16,32,64]']\n\n      - title: \"`until(cond; next)`\"\n        body: |\n\n          The `until(cond; next)` function allows you to repeatedly\n          apply the expression `next`, initially to `.` then to its own\n          output, until `cond` is true.  For example, this can be used\n          to implement a factorial function (see below).\n\n          Note that `until(cond; next)` is internally defined as a\n          recursive jq function.  Recursive calls within `until()` will\n          not consume additional memory if `next` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]'\n            input: '4'\n            output: ['24']\n\n\n      - title: \"`recurse(f)`, `recurse`, `recurse(f; condition)`, `recurse_down`\"\n        body: |\n\n          The `recurse(f)` function allows you to search through a\n          recursive structure, and extract interesting data from all\n          levels. Suppose your input represents a filesystem:\n\n              {\"name\": \"/\", \"children\": [\n                {\"name\": \"/bin\", \"children\": [\n                  {\"name\": \"/bin/ls\", \"children\": []},\n                  {\"name\": \"/bin/sh\", \"children\": []}]},\n                {\"name\": \"/home\", \"children\": [\n                  {\"name\": \"/home/stephen\", \"children\": [\n                    {\"name\": \"/home/stephen/jq\", \"children\": []}]}]}]}\n\n          Now suppose you want to extract all of the filenames\n          present. You need to retrieve `.name`, `.children[].name`,\n          `.children[].children[].name`, and so on. You can do this\n          with:\n\n              recurse(.children[]) | .name\n\n          When called without an argument, `recurse` is equivalent to\n          `recurse(.[]?)`.\n\n          `recurse(f)` is identical to `recurse(f; true)` and can be\n          used without concerns about recursion depth.\n\n          `recurse(f; condition)` is a generator which begins by\n          emitting . and then emits in turn .|f, .|f|f, .|f|f|f, ...  so long\n          as the computed value satisfies the condition. For example,\n          to generate all the integers, at least in principle, one\n          could write `recurse(.+1; true)`.\n\n          For legacy reasons, `recurse_down` exists as an alias to\n          calling `recurse` without arguments. This alias is considered\n          *deprecated* and will be removed in the next major release.\n\n          The recursive calls in `recurse` will not consume additional\n          memory whenever `f` produces at most a single output for each\n          input.\n\n        examples:\n          - program: 'recurse(.foo[])'\n            input: '{\"foo\":[{\"foo\": []}, {\"foo\":[{\"foo\":[]}]}]}'\n            output:\n              - '{\"foo\":[{\"foo\":[]},{\"foo\":[{\"foo\":[]}]}]}'\n              - '{\"foo\":[]}'\n              - '{\"foo\":[{\"foo\":[]}]}'\n              - '{\"foo\":[]}'\n\n          - program: 'recurse'\n            input: '{\"a\":0,\"b\":[1]}'\n            output:\n              - '{\"a\":0,\"b\":[1]}'\n              - '0'\n              - '[1]'\n              - '1'\n\n          - program: 'recurse(. * .; . < 20)'\n            input: '2'\n            output: ['2', '4', '16']\n\n      - title: \"`walk(f)`\"\n        body: |\n\n          The `walk(f)` function applies f recursively to every\n          component of the input entity.  When an array is\n          encountered, f is first applied to its elements and then to\n          the array itself; when an object is encountered, f is first\n          applied to all the values and then to the object.  In\n          practice, f will usually test the type of its input, as\n          illustrated in the following examples.  The first example\n          highlights the usefulness of processing the elements of an\n          array of arrays before processing the array itself.  The second\n          example shows how all the keys of all the objects within the\n          input can be considered for alteration.\n\n        examples:\n          - program: 'walk(if type == \"array\" then sort else . end)'\n            input: '[[4, 1, 7], [8, 5, 2], [3, 6, 9]]'\n            output:\n              - '[[1,4,7],[2,5,8],[3,6,9]]'\n\n          - program: 'walk( if type == \"object\" then with_entries( .key |= sub( \"^_+\"; \"\") ) else . end )'\n            input: '[ { \"_a\": { \"__b\": 2 } } ]'\n            output:\n              - '[{\"a\":{\"b\":2}}]'\n\n      - title: \"`$ENV`, `env`\"\n        body: |\n\n          `$ENV` is an object representing the environment variables as\n          set when the jq program started.\n\n          `env` outputs an object representing jq's current environment.\n\n          At the moment there is no builtin for setting environment\n          variables.\n\n        examples:\n          - program: '$ENV.PAGER'\n            input: 'null'\n            output: ['\"less\"']\n\n          - program: 'env.PAGER'\n            input: 'null'\n            output: ['\"less\"']\n\n      - title: \"`transpose`\"\n        body: |\n\n          Transpose a possibly jagged matrix (an array of arrays).\n          Rows are padded with nulls so the result is always rectangular.\n\n        examples:\n          - program: 'transpose'\n            input: '[[1], [2,3]]'\n            output: ['[[1,2],[null,3]]']\n\n      - title: \"`bsearch(x)`\"\n        body: |\n\n          `bsearch(x)` conducts a binary search for x in the input\n          array.  If the input is sorted and contains x, then\n          `bsearch(x)` will return its index in the array; otherwise, if\n          the array is sorted, it will return (-1 - ix) where ix is an\n          insertion point such that the array would still be sorted\n          after the insertion of x at ix.  If the array is not sorted,\n          `bsearch(x)` will return an integer that is probably of no\n          interest.\n\n        examples:\n          - program: 'bsearch(0)'\n            input: '[0,1]'\n            output: ['0']\n          - program: 'bsearch(0)'\n            input: '[1,2,3]'\n            output: ['-1']\n          - program: 'bsearch(4) as $ix | if $ix < 0 then .[-(1+$ix)] = 4 else . end'\n            input: '[1,2,3]'\n            output: ['[1,2,3,4]']\n\n      - title: \"String interpolation: `\\\\(exp)`\"\n        body: |\n\n          Inside a string, you can put an expression inside parens\n          after a backslash. Whatever the expression returns will be\n          interpolated into the string.\n\n        examples:\n          - program: '\"The input was \\(.), which is one less than \\(.+1)\"'\n            input: '42'\n            output: ['\"The input was 42, which is one less than 43\"']\n\n      - title: \"Convert to/from JSON\"\n        body: |\n\n          The `tojson` and `fromjson` builtins dump values as JSON texts\n          or parse JSON texts into values, respectively.  The `tojson`\n          builtin differs from `tostring` in that `tostring` returns strings\n          unmodified, while `tojson` encodes strings as JSON strings.\n\n        examples:\n          - program: '[.[]|tostring]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"foo\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"\\\"foo\\\"\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson|fromjson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[1,\"foo\",[\"foo\"]]']\n\n      - title: \"Format strings and escaping\"\n        body: |\n\n          The `@foo` syntax is used to format and escape strings,\n          which is useful for building URLs, documents in a language\n          like HTML or XML, and so forth. `@foo` can be used as a\n          filter on its own, the possible escapings are:\n\n          * `@text`:\n\n            Calls `tostring`, see that function for details.\n\n          * `@json`:\n\n            Serializes the input as JSON.\n\n          * `@html`:\n\n            Applies HTML/XML escaping, by mapping the characters\n            `<>&'\"` to their entity equivalents `&lt;`, `&gt;`,\n            `&amp;`, `&apos;`, `&quot;`.\n\n          * `@uri`:\n\n            Applies percent-encoding, by mapping all reserved URI\n            characters to a `%XX` sequence.\n\n          * `@csv`:\n\n            The input must be an array, and it is rendered as CSV\n            with double quotes for strings, and quotes escaped by\n            repetition.\n\n          * `@tsv`:\n\n            The input must be an array, and it is rendered as TSV\n            (tab-separated values). Each input array will be printed as\n            a single line. Fields are separated by a single\n            tab (ascii `0x09`). Input characters line-feed (ascii `0x0a`),\n            carriage-return (ascii `0x0d`), tab (ascii `0x09`) and\n            backslash (ascii `0x5c`) will be output as escape sequences\n            `\\n`, `\\r`, `\\t`, `\\\\` respectively.\n\n          * `@sh`:\n\n            The input is escaped suitable for use in a command-line\n            for a POSIX shell. If the input is an array, the output\n            will be a series of space-separated strings.\n\n          * `@base64`:\n\n            The input is converted to base64 as specified by RFC 4648.\n\n          * `@base64d`:\n\n            The inverse of `@base64`, input is decoded as specified by RFC 4648.\n            Note\\: If the decoded string is not UTF-8, the results are undefined.\n\n          This syntax can be combined with string interpolation in a\n          useful way. You can follow a `@foo` token with a string\n          literal. The contents of the string literal will *not* be\n          escaped. However, all interpolations made inside that string\n          literal will be escaped. For instance,\n\n              @uri \"https://www.google.com/search?q=\\(.search)\"\n\n          will produce the following output for the input\n          `{\"search\":\"what is jq?\"}`:\n\n              \"https://www.google.com/search?q=what%20is%20jq%3F\"\n\n          Note that the slashes, question mark, etc. in the URL are\n          not escaped, as they were part of the string literal.\n\n        examples:\n          - program: '@html'\n            input: '\"This works if x < y\"'\n            output: ['\"This works if x &lt; y\"']\n\n          - program: '@sh \"echo \\(.)\"'\n            input: \"\\\"O'Hara's Ale\\\"\"\n            output: [\"\\\"echo 'O'\\\\\\\\''Hara'\\\\\\\\''s Ale'\\\"\"]\n\n          - program: '@base64'\n            input: '\"This is a message\"'\n            output: ['\"VGhpcyBpcyBhIG1lc3NhZ2U=\"']\n\n          - program: '@base64d'\n            input: '\"VGhpcyBpcyBhIG1lc3NhZ2U=\"'\n            output: ['\"This is a message\"']\n\n      - title: \"Dates\"\n        body: |\n\n          jq provides some basic date handling functionality, with some\n          high-level and low-level builtins.  In all cases these\n          builtins deal exclusively with time in UTC.\n\n          The `fromdateiso8601` builtin parses datetimes in the ISO 8601\n          format to a number of seconds since the Unix epoch\n          (1970-01-01T00:00:00Z).  The `todateiso8601` builtin does the\n          inverse.\n\n          The `fromdate` builtin parses datetime strings.  Currently\n          `fromdate` only supports ISO 8601 datetime strings, but in the\n          future it will attempt to parse datetime strings in more\n          formats.\n\n          The `todate` builtin is an alias for `todateiso8601`.\n\n          The `now` builtin outputs the current time, in seconds since\n          the Unix epoch.\n\n          Low-level jq interfaces to the C-library time functions are\n          also provided: `strptime`, `strftime`, `strflocaltime`,\n          `mktime`, `gmtime`, and `localtime`.  Refer to your host\n          operating system's documentation for the format strings used\n          by `strptime` and `strftime`.  Note: these are not necessarily\n          stable interfaces in jq, particularly as to their localization\n          functionality.\n\n          The `gmtime` builtin consumes a number of seconds since the\n          Unix epoch and outputs a \"broken down time\" representation of\n          Greenwich Mean Time as an array of numbers representing\n          (in this order): the year, the month (zero-based), the day of\n          the month (one-based), the hour of the day, the minute of the\n          hour, the second of the minute, the day of the week, and the\n          day of the year -- all one-based unless otherwise stated.  The\n          day of the week number may be wrong on some systems for dates\n          before March 1st 1900, or after December 31 2099.\n\n          The `localtime` builtin works like the `gmtime` builtin, but\n          using the local timezone setting.\n\n          The `mktime` builtin consumes \"broken down time\"\n          representations of time output by `gmtime` and `strptime`.\n\n          The `strptime(fmt)` builtin parses input strings matching the\n          `fmt` argument.  The output is in the \"broken down time\"\n          representation consumed by `mktime` and output by `gmtime`.\n\n          The `strftime(fmt)` builtin formats a time (GMT) with the\n          given format.  The `strflocaltime` does the same, but using\n          the local timezone setting.\n\n          The format strings for `strptime` and `strftime` are described\n          in typical C library documentation.  The format string for ISO\n          8601 datetime is `\"%Y-%m-%dT%H:%M:%SZ\"`.\n\n          jq may not support some or all of this date functionality on\n          some systems. In particular, the `%u` and `%j` specifiers for\n          `strptime(fmt)` are not supported on macOS.\n\n        examples:\n          - program: 'fromdate'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['1425599507']\n\n          - program: 'strptime(\"%Y-%m-%dT%H:%M:%SZ\")'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['[2015,2,5,23,51,47,4,63]']\n\n          - program: 'strptime(\"%Y-%m-%dT%H:%M:%SZ\")|mktime'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['1425599507']\n\n      - title: \"SQL-Style Operators\"\n        body: |\n\n          jq provides a few SQL-style operators.\n\n          * INDEX(stream; index_expression):\n\n            This builtin produces an object whose keys are computed by\n            the given index expression applied to each value from the\n            given stream.\n\n          * JOIN($idx; stream; idx_expr; join_expr):\n\n            This builtin joins the values from the given stream to the\n            given index.  The index's keys are computed by applying the\n            given index expression to each value from the given stream.\n            An array of the value in the stream and the corresponding\n            value from the index is fed to the given join expression to\n            produce each result.\n\n          * JOIN($idx; stream; idx_expr):\n\n            Same as `JOIN($idx; stream; idx_expr; .)`.\n\n          * JOIN($idx; idx_expr):\n\n            This builtin joins the input `.` to the given index, applying\n            the given index expression to `.` to compute the index key.\n            The join operation is as described above.\n\n          * IN(s):\n\n            This builtin outputs `true` if `.` appears in the given\n            stream, otherwise it outputs `false`.\n\n          * IN(source; s):\n\n            This builtin outputs `true` if any value in the source stream\n            appears in the second stream, otherwise it outputs `false`.\n\n      - title: \"`builtins`\"\n        body: |\n\n          Returns a list of all builtin functions in the format `name/arity`.\n          Since functions with the same name but different arities are considered\n          separate functions, `all/0`, `all/1`, and `all/2` would all be present\n          in the list.\n\n  - title: Conditionals and Comparisons\n    entries:\n      - title: \"`==`, `!=`\"\n        body: |\n\n          The expression 'a == b' will produce 'true' if the result of a and b\n          are equal (that is, if they represent equivalent JSON documents) and\n          'false' otherwise. In particular, strings are never considered equal\n          to numbers. If you're coming from JavaScript, jq's == is like\n          JavaScript's === - considering values equal only when they have the\n          same type as well as the same value.\n\n          != is \"not equal\", and 'a != b' returns the opposite value of 'a == b'\n\n        examples:\n          - program: '.[] == 1'\n            input: '[1, 1.0, \"1\", \"banana\"]'\n            output: ['true', 'true', 'false', 'false']\n\n      - title: if-then-else-end\n        body: |\n\n          `if A then B else C end` will act the same as `B` if `A`\n          produces a value other than false or null, but act the same\n          as `C` otherwise.\n\n          Checking for false or null is a simpler notion of\n          \"truthiness\" than is found in JavaScript or Python, but it\n          means that you'll sometimes have to be more explicit about\n          the condition you want.  You can't test whether, e.g. a\n          string is empty using `if .name then A else B end`, you'll\n          need something more like `if .name == \"\" then A else B end` instead.\n\n          If the condition `A` produces multiple results, then `B` is evaluated\n          once for each result that is not false or null, and `C` is evaluated\n          once for each false or null.\n\n          More cases can be added to an if using `elif A then B` syntax.\n\n        examples:\n          - program: |-\n              if . == 0 then\n                \"zero\"\n              elif . == 1 then\n                \"one\"\n              else\n                \"many\"\n              end\n            input: '2'\n            output: ['\"many\"']\n\n      - title: \"`>`, `>=`, `<=`, `<`\"\n        body: |\n\n          The comparison operators `>`, `>=`, `<=`, `<` return whether\n          their left argument is greater than, greater than or equal\n          to, less than or equal to or less than their right argument\n          (respectively).\n\n          The ordering is the same as that described for `sort`, above.\n\n        examples:\n          - program: '. < 5'\n            input: '2'\n            output: ['true']\n\n      - title: \"`and`, `or`, `not`\"\n        body: |\n\n          jq supports the normal Boolean operators `and`, `or`, `not`. They\n          have the same standard of truth as if expressions - `false` and\n          `null` are considered \"false values\", and anything else is a \"true\n          value\".\n\n          If an operand of one of these operators produces multiple\n          results, the operator itself will produce a result for each input.\n\n          `not` is in fact a builtin function rather than an operator,\n          so it is called as a filter to which things can be piped\n          rather than with special syntax, as in `.foo and .bar |\n          not`.\n\n          These three only produce the values `true` and `false`, and\n          so are only useful for genuine Boolean operations, rather\n          than the common Perl/Python/Ruby idiom of\n          \"value_that_may_be_null or default\". If you want to use this\n          form of \"or\", picking between two values rather than\n          evaluating a condition, see the `//` operator below.\n\n        examples:\n          - program: '42 and \"a string\"'\n            input: 'null'\n            output: ['true']\n          - program: '(true, false) or false'\n            input: 'null'\n            output: ['true', 'false']\n          - program: '(true, true) and (true, false)'\n            input: 'null'\n            output: ['true', 'false', 'true', 'false']\n          - program: '[true, false | not]'\n            input: 'null'\n            output: ['[false, true]']\n\n      - title: \"Alternative operator: `//`\"\n        body: |\n\n          A filter of the form `a // b` produces the same\n          results as `a`, if `a` produces results other than `false`\n          and `null`. Otherwise, `a // b` produces the same results as `b`.\n\n          This is useful for providing defaults: `.foo // 1` will\n          evaluate to `1` if there's no `.foo` element in the\n          input. It's similar to how `or` is sometimes used in Python\n          (jq's `or` operator is reserved for strictly Boolean\n          operations).\n\n        examples:\n          - program: '.foo // 42'\n            input: '{\"foo\": 19}'\n            output: ['19']\n          - program: '.foo // 42'\n            input: '{}'\n            output: ['42']\n\n      - title: try-catch\n        body: |\n\n          Errors can be caught by using `try EXP catch EXP`.  The first\n          expression is executed, and if it fails then the second is\n          executed with the error message.  The output of the handler,\n          if any, is output as if it had been the output of the\n          expression to try.\n\n          The `try EXP` form uses `empty` as the exception handler.\n\n        examples:\n          - program: 'try .a catch \". is not an object\"'\n            input: 'true'\n            output: ['\". is not an object\"']\n          - program: '[.[]|try .a]'\n            input: '[{}, true, {\"a\":1}]'\n            output: ['[null, 1]']\n          - program: 'try error(\"some exception\") catch .'\n            input: 'true'\n            output: ['\"some exception\"']\n\n      - title: Breaking out of control structures\n        body: |\n\n          A convenient use of try/catch is to break out of control\n          structures like `reduce`, `foreach`, `while`, and so on.\n\n          For example:\n\n              # Repeat an expression until it raises \"break\" as an\n              # error, then stop repeating without re-raising the error.\n              # But if the error caught is not \"break\" then re-raise it.\n              try repeat(exp) catch if .==\"break\" then empty else error\n\n          jq has a syntax for named lexical labels to \"break\" or \"go (back) to\":\n\n              label $out | ... break $out ...\n\n          The `break $label_name` expression will cause the program to\n          act as though the nearest (to the left) `label $label_name`\n          produced `empty`.\n\n          The relationship between the `break` and corresponding `label`\n          is lexical: the label has to be \"visible\" from the break.\n\n          To break out of a `reduce`, for example:\n\n              label $out | reduce .[] as $item (null; if .==false then break $out else ... end)\n\n          The following jq program produces a syntax error:\n\n              break $out\n\n          because no label `$out` is visible.\n\n      - title: \"Error Suppression / Optional Operator: `?`\"\n        body: |\n\n          The `?` operator, used as `EXP?`, is shorthand for `try EXP`.\n\n        examples:\n          - program: '[.[] | .a?]'\n            input: '[{}, true, {\"a\":1}]'\n            output: ['[null, 1]']\n          - program: '[.[] | tonumber?]'\n            input: '[\"1\", \"invalid\", \"3\", 4]'\n            output: ['[1, 3, 4]']\n\n  - title: Regular expressions\n    body: |\n\n      jq uses the Oniguruma regular expression library, as do PHP,\n      Ruby, TextMate, Sublime Text, etc, so the description here\n      will focus on jq specifics.\n\n      The jq regex filters are defined so that they can be used using\n      one of these patterns:\n\n          STRING | FILTER(REGEX)\n          STRING | FILTER(REGEX; FLAGS)\n          STRING | FILTER([REGEX])\n          STRING | FILTER([REGEX, FLAGS])\n\n      where:\n\n      * STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;\n      * REGEX, after string interpolation, should be a valid regular expression;\n      * FILTER is one of `test`, `match`, or `capture`, as described below.\n\n      FLAGS is a string consisting of one of more of the supported flags:\n\n      * `g` - Global search (find all matches, not just the first)\n      * `i` - Case insensitive search\n      * `m` - Multi line mode (`.` will match newlines)\n      * `n` - Ignore empty matches\n      * `p` - Both s and m modes are enabled\n      * `s` - Single line mode (`^` -> `\\A`, `$` -> `\\Z`)\n      * `l` - Find longest possible matches\n      * `x` - Extended regex format (ignore whitespace and comments)\n\n      To match a whitespace with the `x` flag, use `\\s`, e.g.\n\n          jq -n '\"a b\" | test(\"a\\\\sb\"; \"x\")'\n\n      Note that certain flags may also be specified within REGEX, e.g.\n\n          jq -n '(\"test\", \"TEst\", \"teST\", \"TEST\") | test(\"(?i)te(?-i)st\")'\n\n      evaluates to: `true`, `true`, `false`, `false`.\n\n    entries:\n      - title: \"`test(val)`, `test(regex; flags)`\"\n        body: |\n\n          Like `match`, but does not return match objects, only `true` or `false`\n          for whether or not the regex matches the input.\n\n        examples:\n          - program: 'test(\"foo\")'\n            input: '\"foo\"'\n            output: ['true']\n          - program: '.[] | test(\"a b c # spaces are ignored\"; \"ix\")'\n            input: '[\"xabcd\", \"ABC\"]'\n            output: ['true', 'true']\n\n      - title: \"`match(val)`, `match(regex; flags)`\"\n        body: |\n\n          **match** outputs an object for each match it finds.  Matches have\n          the following fields:\n\n          * `offset` - offset in UTF-8 codepoints from the beginning of the input\n          * `length` - length in UTF-8 codepoints of the match\n          * `string` - the string that it matched\n          * `captures` - an array of objects representing capturing groups.\n\n          Capturing group objects have the following fields:\n\n          * `offset` - offset in UTF-8 codepoints from the beginning of the input\n          * `length` - length in UTF-8 codepoints of this capturing group\n          * `string` - the string that was captured\n          * `name` - the name of the capturing group (or `null` if it was unnamed)\n\n          Capturing groups that did not match anything return an offset of -1\n\n        examples:\n          - program: 'match(\"(abc)+\"; \"g\")'\n            input: '\"abc abc\"'\n            output:\n             - '{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"name\": null}]}'\n             - '{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"name\": null}]}'\n          - program: 'match(\"foo\")'\n            input: '\"foo bar foo\"'\n            output: ['{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}']\n          - program: 'match([\"foo\", \"ig\"])'\n            input: '\"foo bar FOO\"'\n            output:\n             - '{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}'\n             - '{\"offset\": 8, \"length\": 3, \"string\": \"FOO\", \"captures\": []}'\n          - program: 'match(\"foo (?<bar123>bar)? foo\"; \"ig\")'\n            input: '\"foo bar foo foo  foo\"'\n            output:\n             - '{\"offset\": 0, \"length\": 11, \"string\": \"foo bar foo\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"bar\", \"name\": \"bar123\"}]}'\n             - '{\"offset\": 12, \"length\": 8, \"string\": \"foo  foo\", \"captures\": [{\"offset\": -1, \"length\": 0, \"string\": null, \"name\": \"bar123\"}]}'\n\n          - program: '[ match(\".\"; \"g\")] | length'\n            input: '\"abc\"'\n            output: ['3']\n\n\n      - title: \"`capture(val)`, `capture(regex; flags)`\"\n        body: |\n\n         Collects the named captures in a JSON object, with the name\n         of each capture as the key, and the matched string as the\n         corresponding value.\n\n        examples:\n          - program: 'capture(\"(?<a>[a-z]+)-(?<n>[0-9]+)\")'\n            input: '\"xyzzy-14\"'\n            output: ['{ \"a\": \"xyzzy\", \"n\": \"14\" }']\n\n      - title: \"`scan(regex)`, `scan(regex; flags)`\"\n        body: |\n\n          Emit a stream of the non-overlapping substrings of the input\n          that match the regex in accordance with the flags, if any\n          have been specified.  If there is no match, the stream is empty.\n          To capture all the matches for each input string, use the idiom\n          `[ expr ]`, e.g. `[ scan(regex) ]`.\n\n        examples:\n          - program: 'scan(\"c\")'\n            input: '\"abcdefabc\"'\n            output: ['\"c\"', '\"c\"']\n\n      - title: \"`split(regex; flags)`\"\n        body: |\n\n          For backwards compatibility, `split` splits on a string, not a regex.\n\n        examples:\n          - program: 'split(\", *\"; null)'\n            input: '\"ab,cd, ef\"'\n            output: ['[\"ab\",\"cd\",\"ef\"]']\n\n\n      - title: \"`splits(regex)`, `splits(regex; flags)`\"\n        body: |\n\n          These provide the same results as their `split` counterparts,\n          but as a stream instead of an array.\n\n        examples:\n          - program: 'splits(\", *\")'\n            input: '\"ab,cd,   ef, gh\"'\n            output: ['\"ab\"','\"cd\"','\"ef\"','\"gh\"']\n\n      - title: \"`sub(regex; tostring)`, `sub(regex; string; flags)`\"\n        body: |\n\n          Emit the string obtained by replacing the first match of regex in the\n          input string with `tostring`, after interpolation.  `tostring` should\n          be a jq string, and may contain references to named captures. The\n          named captures are, in effect, presented as a JSON object (as\n          constructed by `capture`) to `tostring`, so a reference to a captured\n          variable named \"x\" would take the form: `\"\\(.x)\"`.\n\n        examples:\n          - program: 'sub(\"[^a-z]*(?<x>[a-z]+)\"; \"Z\\(.x)\"; \"g\")'\n            input: '\"123abc456def\"'\n            output: ['\"ZabcZdef\"']\n\n\n      - title: \"`gsub(regex; string)`, `gsub(regex; string; flags)`\"\n        body: |\n\n          `gsub` is like `sub` but all the non-overlapping occurrences of the regex are\n          replaced by the string, after interpolation.\n\n        examples:\n          - program: 'gsub(\"(?<x>.)[^a]*\"; \"+\\(.x)-\")'\n            input: '\"Abcabc\"'\n            output: ['\"+A-+a-\"']\n\n\n  - title: Advanced features\n    body: |\n      Variables are an absolute necessity in most programming languages, but\n      they're relegated to an \"advanced feature\" in jq.\n\n      In most languages, variables are the only means of passing around\n      data. If you calculate a value, and you want to use it more than once,\n      you'll need to store it in a variable. To pass a value to another part\n      of the program, you'll need that part of the program to define a\n      variable (as a function parameter, object member, or whatever) in\n      which to place the data.\n\n      It is also possible to define functions in jq, although this is\n      is a feature whose biggest use is defining jq's standard library\n      (many jq functions such as `map` and `select` are in fact written\n      in jq).\n\n      jq has reduction operators, which are very powerful but a bit\n      tricky.  Again, these are mostly used internally, to define some\n      useful bits of jq's standard library.\n\n      It may not be obvious at first, but jq is all about generators\n      (yes, as often found in other languages).  Some utilities are\n      provided to help deal with generators.\n\n      Some minimal I/O support (besides reading JSON from standard\n      input, and writing JSON to standard output) is available.\n\n      Finally, there is a module/library system.\n\n    entries:\n      - title: \"Variable / Symbolic Binding Operator: `... as $identifier | ...`\"\n        body: |\n\n          In jq, all filters have an input and an output, so manual\n          plumbing is not necessary to pass a value from one part of a program\n          to the next. Many expressions, for instance `a + b`, pass their input\n          to two distinct subexpressions (here `a` and `b` are both passed the\n          same input), so variables aren't usually necessary in order to use a\n          value twice.\n\n          For instance, calculating the average value of an array of numbers\n          requires a few variables in most languages - at least one to hold the\n          array, perhaps one for each element or for a loop counter. In jq, it's\n          simply `add / length` - the `add` expression is given the array and\n          produces its sum, and the `length` expression is given the array and\n          produces its length.\n\n          So, there's generally a cleaner way to solve most problems in jq than\n          defining variables. Still, sometimes they do make things easier, so jq\n          lets you define variables using `expression as $variable`. All\n          variable names start with `$`. Here's a slightly uglier version of the\n          array-averaging example:\n\n              length as $array_length | add / $array_length\n\n          We'll need a more complicated problem to find a situation where using\n          variables actually makes our lives easier.\n\n\n          Suppose we have an array of blog posts, with \"author\" and \"title\"\n          fields, and another object which is used to map author usernames to\n          real names. Our input looks like:\n\n              {\"posts\": [{\"title\": \"First post\", \"author\": \"anon\"},\n                         {\"title\": \"A well-written article\", \"author\": \"person1\"}],\n               \"realnames\": {\"anon\": \"Anonymous Coward\",\n                             \"person1\": \"Person McPherson\"}}\n\n          We want to produce the posts with the author field containing a real\n          name, as in:\n\n              {\"title\": \"First post\", \"author\": \"Anonymous Coward\"}\n              {\"title\": \"A well-written article\", \"author\": \"Person McPherson\"}\n\n          We use a variable, $names, to store the realnames object, so that we\n          can refer to it later when looking up author usernames:\n\n              .realnames as $names | .posts[] | {title, author: $names[.author]}\n\n          The expression `exp as $x | ...` means: for each value of expression\n          `exp`, run the rest of the pipeline with the entire original input, and\n          with `$x` set to that value.  Thus `as` functions as something of a\n          foreach loop.\n\n          Just as `{foo}` is a handy way of writing `{foo: .foo}`, so\n          `{$foo}` is a handy way of writing `{foo: $foo}`.\n\n          Multiple variables may be declared using a single `as` expression by\n          providing a pattern that matches the structure of the input\n          (this is known as \"destructuring\"):\n\n              . as {realnames: $names, posts: [$first, $second]} | ...\n\n          The variable declarations in array patterns (e.g., `. as\n          [$first, $second]`) bind to the elements of the array in from\n          the element at index zero on up, in order.  When there is no\n          value at the index for an array pattern element, `null` is\n          bound to that variable.\n\n          Variables are scoped over the rest of the expression that defines\n          them, so\n\n              .realnames as $names | (.posts[] | {title, author: $names[.author]})\n\n          will work, but\n\n              (.realnames as $names | .posts[]) | {title, author: $names[.author]}\n\n          won't.\n\n          For programming language theorists, it's more accurate to\n          say that jq variables are lexically-scoped bindings.  In\n          particular there's no way to change the value of a binding;\n          one can only setup a new binding with the same name, but which\n          will not be visible where the old one was.\n\n        examples:\n          - program: '.bar as $x | .foo | . + $x'\n            input: '{\"foo\":10, \"bar\":200}'\n            output: ['210']\n          - program: '. as $i|[(.*2|. as $i| $i), $i]'\n            input: '5'\n            output: ['[10,5]']\n          - program: '. as [$a, $b, {c: $c}] | $a + $b + $c'\n            input: '[2, 3, {\"c\": 4, \"d\": 5}]'\n            output: ['9']\n          - program: '.[] as [$a, $b] | {a: $a, b: $b}'\n            input: '[[0], [0, 1], [2, 1, 0]]'\n            output: ['{\"a\":0,\"b\":null}', '{\"a\":0,\"b\":1}', '{\"a\":2,\"b\":1}']\n\n      - title: 'Destructuring Alternative Operator: `?//`'\n        body: |\n\n          The destructuring alternative operator provides a concise mechanism\n          for destructuring an input that can take one of several forms.\n\n          Suppose we have an API that returns a list of resources and events\n          associated with them, and we want to get the user_id and timestamp of\n          the first event for each resource. The API (having been clumsily\n          converted from XML) will only wrap the events in an array if the resource\n          has multiple events:\n\n              {\"resources\": [{\"id\": 1, \"kind\": \"widget\", \"events\": {\"action\": \"create\", \"user_id\": 1, \"ts\": 13}},\n                             {\"id\": 2, \"kind\": \"widget\", \"events\": [{\"action\": \"create\", \"user_id\": 1, \"ts\": 14}, {\"action\": \"destroy\", \"user_id\": 1, \"ts\": 15}]}]}\n\n          We can use the destructuring alternative operator to handle this structural change simply:\n\n              .resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}\n\n          Or, if we aren't sure if the input is an array of values or an object:\n\n              .[] as [$id, $kind, $user_id, $ts] ?// {$id, $kind, $user_id, $ts} | ...\n\n          Each alternative need not define all of the same variables, but all named\n          variables will be available to the subsequent expression. Variables not\n          matched in the alternative that succeeded will be `null`:\n\n              .resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$first_user_id, $first_ts}]} | {$user_id, $first_user_id, $kind, $id, $ts, $first_ts}\n\n          Additionally, if the subsequent expression returns an error, the\n          alternative operator will attempt to try the next binding. Errors\n          that occur during the final alternative are passed through.\n\n              [[3]] | .[] as [$a] ?// [$b] | if $a != null then error(\"err: \\($a)\") else {$a,$b} end\n\n        examples:\n          - program: '.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}'\n            input: '[{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]'\n            output: ['{\"a\":1,\"b\":2,\"d\":3,\"e\":4}', '{\"a\":1,\"b\":2,\"d\":3,\"e\":4}']\n          - program: '.[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}'\n            input: '[{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]'\n            output: ['{\"a\":1,\"b\":2,\"d\":3,\"e\":null}', '{\"a\":1,\"b\":2,\"d\":null,\"e\":4}']\n          - program: '.[] as [$a] ?// [$b] | if $a != null then error(\"err: \\($a)\") else {$a,$b} end'\n            input: '[[3]]'\n            output: ['{\"a\":null,\"b\":3}']\n\n      - title: 'Defining Functions'\n        body: |\n\n          You can give a filter a name using \"def\" syntax:\n\n              def increment: . + 1;\n\n          From then on, `increment` is usable as a filter just like a\n          builtin function (in fact, this is how many of the builtins\n          are defined). A function may take arguments:\n\n              def map(f): [.[] | f];\n\n          Arguments are passed as _filters_ (functions with no\n          arguments), _not_ as values. The same argument may be\n          referenced multiple times with different inputs (here `f` is\n          run for each element of the input array).  Arguments to a\n          function work more like callbacks than like value arguments.\n          This is important to understand.  Consider:\n\n              def foo(f): f|f;\n              5|foo(.*2)\n\n          The result will be 20 because `f` is `.*2`, and during the\n          first invocation of `f` `.` will be 5, and the second time it\n          will be 10 (5 * 2), so the result will be 20.  Function\n          arguments are filters, and filters expect an input when\n          invoked.\n\n          If you want the value-argument behaviour for defining simple\n          functions, you can just use a variable:\n\n              def addvalue(f): f as $f | map(. + $f);\n\n          Or use the short-hand:\n\n              def addvalue($f): ...;\n\n          With either definition, `addvalue(.foo)` will add the current\n          input's `.foo` field to each element of the array.  Do note\n          that calling `addvalue(.[])` will cause the `map(. + $f)` part\n          to be evaluated once per value in the value of `.` at the call\n          site.\n\n          Multiple definitions using the same function name are allowed.\n          Each re-definition replaces the previous one for the same\n          number of function arguments, but only for references from\n          functions (or main program) subsequent to the re-definition.\n          See also the section below on scoping.\n\n        examples:\n          - program: 'def addvalue(f): . + [f]; map(addvalue(.[0]))'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1], [10,20,10]]']\n          - program: 'def addvalue(f): f as $x | map(. + $x); addvalue(.[0])'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1,2], [10,20,1,2]]']\n\n      - title: 'Scoping'\n        body: |\n\n          There are two types of symbols in jq: value bindings (a.k.a.,\n          \"variables\"), and functions.  Both are scoped lexically,\n          with expressions being able to refer only to symbols that\n          have been defined \"to the left\" of them.  The only exception\n          to this rule is that functions can refer to themselves so as\n          to be able to create recursive functions.\n\n          For example, in the following expression there is a binding\n          which is visible \"to the right\" of it, `... | .*3 as\n          $times_three | [. + $times_three] | ...`, but not \"to the\n          left\".  Consider this expression now, `... | (.*3 as\n          $times_three | [. + $times_three]) | ...`: here the binding\n          `$times_three` is _not_ visible past the closing parenthesis.\n\n      - title: \"`isempty(exp)`\"\n        body: |\n\n          Returns true if `exp` produces no outputs, false otherwise.\n\n        examples:\n          - program: 'isempty(empty)'\n            input: 'null'\n            output: ['true']\n\n          - program: 'isempty(.[])'\n            input: '[]'\n            output: ['true']\n\n          - program: 'isempty(.[])'\n            input: '[1,2,3]'\n            output: ['false']\n\n      - title: \"`limit(n; exp)`\"\n        body: |\n\n          The `limit` function extracts up to `n` outputs from `exp`.\n\n        examples:\n          - program: '[limit(3;.[])]'\n            input: '[0,1,2,3,4,5,6,7,8,9]'\n            output: ['[0,1,2]']\n\n      - title: \"`first(expr)`, `last(expr)`, `nth(n; expr)`\"\n        body: |\n\n          The `first(expr)` and `last(expr)` functions extract the first\n          and last values from `expr`, respectively.\n\n          The `nth(n; expr)` function extracts the nth value output by\n          `expr`.  This can be defined as `def nth(n; expr):\n          last(limit(n + 1; expr));`.  Note that `nth(n; expr)` doesn't\n          support negative values of `n`.\n\n        examples:\n          - program: '[first(range(.)), last(range(.)), nth(./2; range(.))]'\n            input: '10'\n            output: ['[0,9,5]']\n\n      - title: \"`first`, `last`, `nth(n)`\"\n        body: |\n\n          The `first` and `last` functions extract the first\n          and last values from any array at `.`.\n\n          The `nth(n)` function extracts the nth value of any array at `.`.\n\n        examples:\n          - program: '[range(.)]|[first, last, nth(5)]'\n            input: '10'\n            output: ['[0,9,5]']\n\n      - title: \"`reduce`\"\n        body: |\n\n          The `reduce` syntax allows you to combine all of the results of\n          an expression by accumulating them into a single answer.\n          The form is `reduce EXP as $var (INIT; UPDATE)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              reduce .[] as $item (0; . + $item)\n\n          For each result that `.[]` produces, `. + $item` is run to\n          accumulate a running total, starting from 0 as the input value.\n          In this example, `.[]` produces the results `1`, `2`, and `3`,\n          so the effect is similar to running something like this:\n\n              0 | 1 as $item | . + $item |\n                  2 as $item | . + $item |\n                  3 as $item | . + $item\n\n        examples:\n          - program: 'reduce .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['15']\n\n          - program: 'reduce .[] as [$i,$j] (0; . + $i * $j)'\n            input: '[[1,2],[3,4],[5,6]]'\n            output: ['44']\n\n          - program: 'reduce .[] as {$x,$y} (null; .x += $x | .y += [$y])'\n            input: '[{\"x\":\"a\",\"y\":1},{\"x\":\"b\",\"y\":2},{\"x\":\"c\",\"y\":3}]'\n            output: ['{\"x\":\"abc\",\"y\":[1,2,3]}']\n\n      - title: \"`foreach`\"\n        body: |\n\n          The `foreach` syntax is similar to `reduce`, but intended to\n          allow the construction of `limit` and reducers that produce\n          intermediate results.\n\n          The form is `foreach EXP as $var (INIT; UPDATE; EXTRACT)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              foreach .[] as $item (0; . + $item; [$item, . * 2])\n\n          Like the `reduce` syntax, `. + $item` is run for each result\n          that `.[]` produces, but `[$item, . * 2]` is run for each\n          intermediate values. In this example, since the intermediate\n          values are `1`, `3`, and `6`, the `foreach` expression produces\n          `[1,2]`, `[2,6]`, and `[3,12]`. So the effect is similar\n          to running something like this:\n\n              0 | 1 as $item | . + $item | [$item, . * 2],\n                  2 as $item | . + $item | [$item, . * 2],\n                  3 as $item | . + $item | [$item, . * 2]\n\n          When `EXTRACT` is omitted, the identity filter is used.\n          That is, it outputs the intermediate values as they are.\n\n        examples:\n          - program: 'foreach .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['1','3','6','10','15']\n\n          - program: 'foreach .[] as $item (0; . + $item; [$item, . * 2])'\n            input: '[1,2,3,4,5]'\n            output: ['[1,2]','[2,6]','[3,12]','[4,20]','[5,30]']\n\n          - program: 'foreach .[] as $item (0; . + 1; {index: ., $item})'\n            input: '[\"foo\", \"bar\", \"baz\"]'\n            output:\n              - '{\"index\":1,\"item\":\"foo\"}'\n              - '{\"index\":2,\"item\":\"bar\"}'\n              - '{\"index\":3,\"item\":\"baz\"}'\n\n      - title: Recursion\n        body: |\n\n          As described above, `recurse` uses recursion, and any jq\n          function can be recursive.  The `while` builtin is also\n          implemented in terms of recursion.\n\n          Tail calls are optimized whenever the expression to the left of\n          the recursive call outputs its last value.  In practice this\n          means that the expression to the left of the recursive call\n          should not produce more than one output for each input.\n\n          For example:\n\n              def recurse(f): def r: ., (f | select(. != null) | r); r;\n\n              def while(cond; update):\n                def _while:\n                  if cond then ., (update | _while) else empty end;\n                _while;\n\n              def repeat(exp):\n                def _repeat:\n                  exp, _repeat;\n                _repeat;\n\n      - title: Generators and iterators\n        body: |\n\n            Some jq operators and functions are actually generators in\n            that they can produce zero, one, or more values for each\n            input, just as one might expect in other programming\n            languages that have generators.  For example, `.[]`\n            generates all the values in its input (which must be an\n            array or an object), `range(0; 10)` generates the integers\n            between 0 and 10, and so on.\n\n            Even the comma operator is a generator, generating first the\n            values generated by the expression to the left of the comma,\n            then for each of those, the values generate by the\n            expression on the right of the comma.\n\n            The `empty` builtin is the generator that produces zero\n            outputs.  The `empty` builtin backtracks to the preceding\n            generator expression.\n\n            All jq functions can be generators just by using builtin\n            generators.  It is also possible to define new generators\n            using only recursion and the comma operator.  If the\n            recursive call(s) is(are) \"in tail position\" then the\n            generator will be efficient.  In the example below the\n            recursive call by `_range` to itself is in tail position.\n            The example shows off three advanced topics: tail recursion,\n            generator construction, and sub-functions.\n\n        examples:\n          - program: 'def range(init; upto; by):\n                    def _range:\n                        if (by > 0 and . < upto) or (by < 0 and . > upto)\n                        then ., ((.+by)|_range)\n                        else . end;\n                    if by == 0 then init else init|_range end |\n                    select((by > 0 and . < upto) or (by < 0 and . > upto));\n                range(0; 10; 3)'\n            input: 'null'\n            output: ['0', '3', '6', '9']\n          - program: 'def while(cond; update):\n                    def _while:\n                        if cond then ., (update | _while) else empty end;\n                    _while;\n                [while(.<100; .*2)]'\n            input: '1'\n            output: ['[1,2,4,8,16,32,64]']\n\n  - title: 'Math'\n    body: |\n\n      jq currently only has IEEE754 double-precision (64-bit) floating\n      point number support.\n\n      Besides simple arithmetic operators such as `+`, jq also has most\n      standard math functions from the C math library.  C math functions\n      that take a single input argument (e.g., `sin()`) are available as\n      zero-argument jq functions.  C math functions that take two input\n      arguments (e.g., `pow()`) are available as two-argument jq\n      functions that ignore `.`.  C math functions that take three input\n      arguments are available as three-argument jq functions that ignore\n      `.`.\n\n      Availability of standard math functions depends on the\n      availability of the corresponding math functions in your operating\n      system and C math library.  Unavailable math functions will be\n      defined but will raise an error.\n\n      One-input C math functions: `acos` `acosh` `asin` `asinh` `atan`\n      `atanh` `cbrt` `ceil` `cos` `cosh` `erf` `erfc` `exp` `exp10`\n      `exp2` `expm1` `fabs` `floor` `gamma` `j0` `j1` `lgamma` `log`\n      `log10` `log1p` `log2` `logb` `nearbyint` `pow10` `rint` `round`\n      `significand` `sin` `sinh` `sqrt` `tan` `tanh` `tgamma` `trunc`\n      `y0` `y1`.\n\n      Two-input C math functions: `atan2` `copysign` `drem` `fdim`\n      `fmax` `fmin` `fmod` `frexp` `hypot` `jn` `ldexp` `modf`\n      `nextafter` `nexttoward` `pow` `remainder` `scalb` `scalbln` `yn`.\n\n      Three-input C math functions: `fma`.\n\n      See your system's manual for more information on each of these.\n\n  - title: 'I/O'\n    body: |\n\n      At this time jq has minimal support for I/O, mostly in the\n      form of control over when inputs are read.  Two builtins functions\n      are provided for this, `input` and `inputs`, that read from the\n      same sources (e.g., `stdin`, files named on the command-line) as\n      jq itself.  These two builtins, and jq's own reading actions, can\n      be interleaved with each other.\n\n      Two builtins provide minimal output capabilities, `debug`, and\n      `stderr`.  (Recall that a jq program's output values are always\n      output as JSON texts on `stdout`.)  The `debug` builtin can have\n      application-specific behavior, such as for executables that use\n      the libjq C API but aren't the jq executable itself.  The `stderr`\n      builtin outputs its input in raw mode to stderr with no additional\n      decoration, not even a newline.\n\n      Most jq builtins are referentially transparent, and yield constant\n      and repeatable value streams when applied to constant inputs.\n      This is not true of I/O builtins.\n\n    entries:\n      - title: \"`input`\"\n        body: |\n\n          Outputs one new input.\n\n              echo 1 2 3 4 | jq '[., input]' # [1,2] [3,4]\n\n      - title: \"`inputs`\"\n        body: |\n\n          Outputs all remaining inputs, one by one.\n\n          This is primarily useful for reductions over a program's\n          inputs.\n\n              echo 1 2 3 | jq -n 'reduce inputs as $i (0; . + $i)' # 6\n\n      - title: \"`debug`\"\n        body: |\n\n          Causes a debug message based on the input value to be\n          produced.  The jq executable wraps the input value with\n          `[\"DEBUG:\", <input-value>]` and prints that and a newline on\n          stderr, compactly.  This may change in the future.\n\n      - title: \"`stderr`\"\n        body: |\n\n          Prints its input in raw and compact mode to stderr with no\n          additional decoration, not even a newline.\n\n      - title: \"`input_filename`\"\n        body: |\n\n          Returns the name of the file whose input is currently being\n          filtered.  Note that this will not work well unless jq is\n          running in a UTF-8 locale.\n\n      - title: \"`input_line_number`\"\n        body: |\n\n          Returns the line number of the input currently being filtered.\n\n  - title: 'Streaming'\n    body: |\n\n      With the `--stream` option jq can parse input texts in a streaming\n      fashion, allowing jq programs to start processing large JSON texts\n      immediately rather than after the parse completes.  If you have a\n      single JSON text that is 1GB in size, streaming it will allow you\n      to process it much more quickly.\n\n      However, streaming isn't easy to deal with as the jq program will\n      have `[<path>, <leaf-value>]` (and a few other forms) as inputs.\n\n      Several builtins are provided to make handling streams easier.\n\n      The examples below use the streamed form of `[0,[1]]`, which is\n      `[[0],0],[[1,0],1],[[1,0]],[[1]]`.\n\n      Streaming forms include `[<path>, <leaf-value>]` (to indicate any\n      scalar value, empty array, or empty object), and `[<path>]` (to\n      indicate the end of an array or object).  Future versions of jq\n      run with `--stream` and `--seq` may output additional forms such\n      as `[\"error message\"]` when an input text fails to parse.\n\n    entries:\n      - title: \"`truncate_stream(stream_expression)`\"\n        body: |\n\n          Consumes a number as input and truncates the corresponding\n          number of path elements from the left of the outputs of the\n          given streaming expression.\n\n        examples:\n          - program: 'truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]])'\n            input: '1'\n            output: ['[[0],2]', '[[0]]']\n\n      - title: \"`fromstream(stream_expression)`\"\n        body: |\n\n          Outputs values corresponding to the stream expression's\n          outputs.\n\n        examples:\n          - program: 'fromstream(1|truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]]))'\n            input: 'null'\n            output: ['[2]']\n\n      - title: \"`tostream`\"\n        body: |\n\n          The `tostream` builtin outputs the streamed form of its input.\n\n        examples:\n          - program: '. as $dot|fromstream($dot|tostream)|.==$dot'\n            input: '[0,[1,{\"a\":1},{\"b\":2}]]'\n            output: ['true']\n\n  - title: Assignment\n    body: |\n      Assignment works a little differently in jq than in most\n      programming languages. jq doesn't distinguish between references\n      to and copies of something - two objects or arrays are either\n      equal or not equal, without any further notion of being \"the\n      same object\" or \"not the same object\".\n\n      If an object has two fields which are arrays, `.foo` and `.bar`,\n      and you append something to `.foo`, then `.bar` will not get\n      bigger, even if you've previously set `.bar = .foo`.  If you're\n      used to programming in languages like Python, Java, Ruby,\n      JavaScript, etc. then you can think of it as though jq does a full\n      deep copy of every object before it does the assignment (for\n      performance it doesn't actually do that, but that's the general\n      idea).\n\n      This means that it's impossible to build circular values in jq\n      (such as an array whose first element is itself). This is quite\n      intentional, and ensures that anything a jq program can produce\n      can be represented in JSON.\n\n      All the assignment operators in jq have path expressions on the\n      left-hand side (LHS).  The right-hand side (RHS) provides values\n      to set to the paths named by the LHS path expressions.\n\n      Values in jq are always immutable.  Internally, assignment works\n      by using a reduction to compute new, replacement values for `.` that\n      have had all the desired assignments applied to `.`, then\n      outputting the modified value.  This might be made clear by this\n      example: `{a:{b:{c:1}}} | (.a.b|=3), .`.  This will output\n      `{\"a\":{\"b\":3}}` and `{\"a\":{\"b\":{\"c\":1}}}` because the last\n      sub-expression, `.`, sees the original value, not the modified\n      value.\n\n      Most users will want to use modification assignment operators,\n      such as `|=` or `+=`, rather than `=`.\n\n      Note that the LHS of assignment operators refers to a value in\n      `.`.  Thus `$var.foo = 1` won't work as expected (`$var.foo` is\n      not a valid or useful path expression in `.`); use `$var | .foo =\n      1` instead.\n\n      Note too that `.a,.b=0` does not set `.a` and `.b`, but\n      `(.a,.b)=0` sets both.\n\n    entries:\n      - title: \"Update-assignment: `|=`\"\n        body: |\n          This is the \"update\" operator `|=`.  It takes a filter on the\n          right-hand side and works out the new value for the property\n          of `.` being assigned to by running the old value through this\n          expression. For instance, `(.foo, .bar) |= .+1` will build an\n          object with the \"foo\" field set to the input's \"foo\" plus 1,\n          and the \"bar\" field set to the input's \"bar\" plus 1.\n\n          The left-hand side can be any general path expression; see `path()`.\n\n          Note that the left-hand side of `|=` refers to a value in `.`.\n          Thus `$var.foo |= . + 1` won't work as expected (`$var.foo` is\n          not a valid or useful path expression in `.`); use `$var |\n          .foo |= . + 1` instead.\n\n          If the right-hand side outputs no values (i.e., `empty`), then\n          the left-hand side path will be deleted, as with `del(path)`.\n\n          If the right-hand side outputs multiple values, only the first\n          one will be used (COMPATIBILITY NOTE: in jq 1.5 and earlier\n          releases, it used to be that only the last one was used).\n\n        examples:\n          - program: '(..|select(type==\"boolean\")) |= if . then 1 else 0 end'\n            input: '[true,false,[5,true,[true,[false]],false]]'\n            output: ['[1,0,[5,1,[1,[0]],0]]']\n\n      - title: \"Arithmetic update-assignment: `+=`, `-=`, `*=`, `/=`, `%=`, `//=`\"\n        body: |\n\n          jq has a few operators of the form `a op= b`, which are all\n          equivalent to `a |= . op b`. So, `+= 1` can be used to\n          increment values, being the same as `|= . + 1`.\n\n        examples:\n          - program: .foo += 1\n            input: '{\"foo\": 42}'\n            output: ['{\"foo\": 43}']\n\n      - title: \"Plain assignment: `=`\"\n        body: |\n\n          This is the plain assignment operator.  Unlike the others, the\n          input to the right-hand-side (RHS) is the same as the input to\n          the left-hand-side (LHS) rather than the value at the LHS\n          path, and all values output by the RHS will be used (as shown\n          below).\n\n          If the RHS of '=' produces multiple values, then for each such\n          value jq will set the paths on the left-hand side to the value\n          and then it will output the modified `.`.  For example,\n          `(.a,.b)=range(2)` outputs `{\"a\":0,\"b\":0}`, then\n          `{\"a\":1,\"b\":1}`.  The \"update\" assignment forms (see above) do\n          not do this.\n\n          This example should show the difference between '=' and '|=':\n\n          Provide input `{\"a\": {\"b\": 10}, \"b\": 20}` to the programs:\n\n          `.a = .b`\n\n          `.a |= .b`\n\n          The former will set the \"a\" field of the input to the \"b\"\n          field of the input, and produce the output `{\"a\": 20, \"b\": 20}`.\n          The latter will set the \"a\" field of the input to the \"a\"\n          field's \"b\" field, producing `{\"a\": 10, \"b\": 20}`.\n\n          Another example of the difference between `=` and `|=`:\n\n          `null|(.a,.b)=range(3)`\n\n          outputs `{\"a\":0,\"b\":0}, {\"a\":1,\"b\":1}, {\"a\":2,\"b\":2}`,\n          while\n\n          `null|(.a,.b)|=range(3)`\n\n          outputs just `{\"a\":0,\"b\":0}`.\n\n      - title: Complex assignments\n        body: |\n          Lots more things are allowed on the left-hand side of a jq assignment\n          than in most languages. We've already seen simple field accesses on\n          the left hand side, and it's no surprise that array accesses work just\n          as well:\n\n              .posts[0].title = \"JQ Manual\"\n\n          What may come as a surprise is that the expression on the left may\n          produce multiple results, referring to different points in the input\n          document:\n\n              .posts[].comments |= . + [\"this is great\"]\n\n          That example appends the string \"this is great\" to the \"comments\"\n          array of each post in the input (where the input is an object with a\n          field \"posts\" which is an array of posts).\n\n          When jq encounters an assignment like 'a = b', it records the \"path\"\n          taken to select a part of the input document while executing a. This\n          path is then used to find which part of the input to change while\n          executing the assignment. Any filter may be used on the\n          left-hand side of an equals - whichever paths it selects from the\n          input will be where the assignment is performed.\n\n          This is a very powerful operation. Suppose we wanted to add a comment\n          to blog posts, using the same \"blog\" input above. This time, we only\n          want to comment on the posts written by \"stedolan\". We can find those\n          posts using the \"select\" function described earlier:\n\n              .posts[] | select(.author == \"stedolan\")\n\n          The paths provided by this operation point to each of the posts that\n          \"stedolan\" wrote, and we can comment on each of them in the same way\n          that we did before:\n\n              (.posts[] | select(.author == \"stedolan\") | .comments) |=\n                  . + [\"terrible.\"]\n\n  - title: Modules\n    body: |\n\n      jq has a library/module system.  Modules are files whose names end\n      in `.jq`.\n\n      Modules imported by a program are searched for in a default search\n      path (see below).  The `import` and `include` directives allow the\n      importer to alter this path.\n\n      Paths in the search path are subject to various substitutions.\n\n      For paths starting with \"~/\", the user's home directory is\n      substituted for \"~\".\n\n      For paths starting with \"$ORIGIN/\", the directory where the jq\n      executable is located is substituted for \"$ORIGIN\".\n\n      For paths starting with \"./\" or paths that are \".\", the path of\n      the including file is substituted for \".\".  For top-level programs\n      given on the command-line, the current directory is used.\n\n      Import directives can optionally specify a search path to which\n      the default is appended.\n\n      The default search path is the search path given to the `-L`\n      command-line option, else `[\"~/.jq\", \"$ORIGIN/../lib/jq\",\n      \"$ORIGIN/../lib\"]`.\n\n      Null and empty string path elements terminate search path\n      processing.\n\n      A dependency with relative path \"foo/bar\" would be searched for in\n      \"foo/bar.jq\" and \"foo/bar/bar.jq\" in the given search path. This\n      is intended to allow modules to be placed in a directory along\n      with, for example, version control files, README files, and so on,\n      but also to allow for single-file modules.\n\n      Consecutive components with the same name are not allowed to avoid\n      ambiguities (e.g., \"foo/foo\").\n\n      For example, with `-L$HOME/.jq` a module `foo` can be found in\n      `$HOME/.jq/foo.jq` and `$HOME/.jq/foo/foo.jq`.\n\n      If \"$HOME/.jq\" is a file, it is sourced into the main program.\n\n    entries:\n      - title: \"`import RelativePathString as NAME [<metadata>];`\"\n        body: |\n\n          Imports a module found at the given path relative to a\n          directory in a search path.  A \".jq\" suffix will be added to\n          the relative path string.  The module's symbols are prefixed\n          with \"NAME::\".\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like \"homepage\" and so on.  At\n          this time jq only uses the \"search\" key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n          The \"search\" key in the metadata, if present, should have a\n          string or array value (array of strings); this is the search\n          path to be prefixed to the top-level search path.\n\n      - title: \"`include RelativePathString [<metadata>];`\"\n        body: |\n\n          Imports a module found at the given path relative to a\n          directory in a search path as if it were included in place.  A\n          \".jq\" suffix will be added to the relative path string.  The\n          module's symbols are imported into the caller's namespace as\n          if the module's content had been included directly.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like \"homepage\" and so on.  At\n          this time jq only uses the \"search\" key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n      - title: \"`import RelativePathString as $NAME [<metadata>];`\"\n        body: |\n\n          Imports a JSON file found at the given path relative to a\n          directory in a search path.  A \".json\" suffix will be added to\n          the relative path string.  The file's data will be available\n          as `$NAME::NAME`.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like \"homepage\" and so on.  At\n          this time jq only uses the \"search\" key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n          The \"search\" key in the metadata, if present, should have a\n          string or array value (array of strings); this is the search\n          path to be prefixed to the top-level search path.\n\n      - title: \"`module <metadata>;`\"\n        body: |\n\n          This directive is entirely optional.  It's not required for\n          proper operation.  It serves only the purpose of providing\n          metadata that can be read with the `modulemeta` builtin.\n\n          The metadata must be a constant jq expression.  It should be\n          an object with keys like \"homepage\".  At this time jq doesn't\n          use this metadata, but it is made available to users via the\n          `modulemeta` builtin.\n\n      - title: \"`modulemeta`\"\n        body: |\n\n          Takes a module name as input and outputs the module's metadata\n          as an object, with the module's imports (including metadata)\n          as an array value for the \"deps\" key.\n\n          Programs can use this to query a module's metadata, which they\n          could then use to, for example, search for, download, and\n          install missing dependencies.\n\n  - title: Colors\n    body: |\n\n      To configure alternative colors just set the `JQ_COLORS`\n      environment variable to colon-delimited list of partial terminal\n      escape sequences like `\"1;31\"`, in this order:\n\n        - color for `null`\n        - color for `false`\n        - color for `true`\n        - color for numbers\n        - color for strings\n        - color for arrays\n        - color for objects\n\n      The default color scheme is the same as setting\n      `\"JQ_COLORS=1;30:0;39:0;39:0;39:0;32:1;39:1;39\"`.\n\n      This is not a manual for VT100/ANSI escapes.  However, each of\n      these color specifications should consist of two numbers separated\n      by a semi-colon, where the first number is one of these:\n\n        - 1 (bright)\n        - 2 (dim)\n        - 4 (underscore)\n        - 5 (blink)\n        - 7 (reverse)\n        - 8 (hidden)\n\n      and the second is one of these:\n\n        - 30 (black)\n        - 31 (red)\n        - 32 (green)\n        - 33 (yellow)\n        - 34 (blue)\n        - 35 (magenta)\n        - 36 (cyan)\n        - 37 (white)\n"
  },
  {
    "path": "docs/content/manual/v1.7/manual.yml",
    "content": "---\nheadline: jq 1.7 Manual\n\nbody: |\n\n  A jq program is a \"filter\": it takes an input, and produces an\n  output. There are a lot of builtin filters for extracting a\n  particular field of an object, or converting a number to a string,\n  or various other standard tasks.\n\n  Filters can be combined in various ways - you can pipe the output of\n  one filter into another filter, or collect the output of a filter\n  into an array.\n\n  Some filters produce multiple results, for instance there's one that\n  produces all the elements of its input array. Piping that filter\n  into a second runs the second filter for each element of the\n  array. Generally, things that would be done with loops and iteration\n  in other languages are just done by gluing filters together in jq.\n\n  It's important to remember that every filter has an input and an\n  output. Even literals like \"hello\" or 42 are filters - they take an\n  input but always produce the same literal as output. Operations that\n  combine two filters, like addition, generally feed the same input to\n  both and combine the results. So, you can implement an averaging\n  filter as `add / length` - feeding the input array both to the `add`\n  filter and the `length` filter and then performing the division.\n\n  But that's getting ahead of ourselves. :) Let's start with something\n  simpler:\n\nmanpage_intro: |\n  jq(1) -- Command-line JSON processor\n  ====================================\n\n  ## SYNOPSIS\n\n  `jq` [<options>...] <filter> [<files>...]\n\n  `jq` can transform JSON in various ways, by selecting, iterating,\n  reducing and otherwise mangling JSON documents. For instance,\n  running the command `jq 'map(.price) | add'` will take an array of\n  JSON objects as input and return the sum of their \"price\" fields.\n\n  `jq` can accept text input as well, but by default, `jq` reads a\n  stream of JSON entities (including numbers and other literals) from\n  `stdin`. Whitespace is only needed to separate entities such as 1\n  and 2, and true and false.  One or more <files> may be specified, in\n  which case `jq` will read input from those instead.\n\n  The <options> are described in the [INVOKING JQ] section; they\n  mostly concern input and output formatting. The <filter> is written\n  in the jq language and specifies how to transform the input\n  file or document.\n\n  ## FILTERS\n\nmanpage_epilogue: |\n  ## BUGS\n\n  Presumably. Report them or discuss them at:\n\n      https://github.com/jqlang/jq/issues\n\n  ## AUTHOR\n\n  Stephen Dolan `<mu@netsoc.tcd.ie>`\n\nsections:\n  - title: Invoking jq\n    body: |\n\n      jq filters run on a stream of JSON data. The input to jq is\n      parsed as a sequence of whitespace-separated JSON values which\n      are passed through the provided filter one at a time. The\n      output(s) of the filter are written to standard output, as a\n      sequence of newline-separated JSON data.\n\n      The simplest and most common filter (or jq program) is `.`,\n      which is the identity operator, copying the inputs of the jq\n      processor to the output stream.  Because the default behavior of\n      the jq processor is to read JSON texts from the input stream,\n      and to pretty-print outputs, the `.` program's main use is to\n      validate and pretty-print the inputs.  The jq programming\n      language is quite rich and allows for much more than just\n      validation and pretty-printing.\n\n      Note: it is important to mind the shell's quoting rules.  As a\n      general rule it's best to always quote (with single-quote\n      characters on Unix shells) the jq program, as too many characters with special\n      meaning to jq are also shell meta-characters.  For example, `jq\n      \"foo\"` will fail on most Unix shells because that will be the same\n      as `jq foo`, which will generally fail because `foo is not\n      defined`.  When using the Windows command shell (cmd.exe) it's\n      best to use double quotes around your jq program when given on the\n      command-line (instead of the `-f program-file` option), but then\n      double-quotes in the jq program need backslash escaping. When using\n      the Powershell (`powershell.exe`) or the Powershell Core\n      (`pwsh`/`pwsh.exe`), use single-quote characters around the jq\n      program and backslash-escaped double-quotes (`\\\"`) inside the jq\n      program.\n\n      * Unix shells: `jq '.[\"foo\"]'`\n      * Powershell: `jq '.[\\\"foo\\\"]'`\n      * Windows command shell: `jq \".[\\\"foo\\\"]\"`\n\n      Note: jq allows user-defined functions, but every jq program\n      must have a top-level expression.\n\n      You can affect how jq reads and writes its input and output\n      using some command-line options:\n\n      * `--null-input` / `-n`:\n\n        Don't read any input at all. Instead, the filter is run once\n        using `null` as the input. This is useful when using jq as a\n        simple calculator or to construct JSON data from scratch.\n\n      * `--raw-input` / `-R`:\n\n        Don't parse the input as JSON. Instead, each line of text is\n        passed to the filter as a string. If combined with `--slurp`,\n        then the entire input is passed to the filter as a single long\n        string.\n\n      * `--slurp` / `-s`:\n\n        Instead of running the filter for each JSON object in the\n        input, read the entire input stream into a large array and run\n        the filter just once.\n\n      * `--compact-output` / `-c`:\n\n        By default, jq pretty-prints JSON output. Using this option\n        will result in more compact output by instead putting each\n        JSON object on a single line.\n\n      * `--raw-output` / `-r`:\n\n        With this option, if the filter's result is a string then it\n        will be written directly to standard output rather than being\n        formatted as a JSON string with quotes. This can be useful for\n        making jq filters talk to non-JSON-based systems.\n\n      * `--raw-output0`:\n\n        Like `-r` but jq will print NUL instead of newline after each output.\n        This can be useful when the values being output can contain newlines.\n        When the output value contains NUL, jq exits with non-zero code.\n\n      * `--join-output` / `-j`:\n\n        Like `-r` but jq won't print a newline after each output.\n\n      * `--ascii-output` / `-a`:\n\n        jq usually outputs non-ASCII Unicode codepoints as UTF-8, even\n        if the input specified them as escape sequences (like\n        \"\\u03bc\"). Using this option, you can force jq to produce pure\n        ASCII output with every non-ASCII character replaced with the\n        equivalent escape sequence.\n\n      * `--sort-keys` / `-S`:\n\n        Output the fields of each object with the keys in sorted order.\n\n      * `--color-output` / `-C` and `--monochrome-output` / `-M`:\n\n        By default, jq outputs colored JSON if writing to a\n        terminal. You can force it to produce color even if writing to\n        a pipe or a file using `-C`, and disable color with `-M`.\n        When the `NO_COLOR` environment variable is not empty, jq disables\n        colored output by default, but you can enable it by `-C`.\n\n        Colors can be configured with the `JQ_COLORS` environment\n        variable (see below).\n\n      * `--tab`:\n\n        Use a tab for each indentation level instead of two spaces.\n\n      * `--indent n`:\n\n        Use the given number of spaces (no more than 7) for indentation.\n\n      * `--unbuffered`:\n\n        Flush the output after each JSON object is printed (useful if\n        you're piping a slow data source into jq and piping jq's\n        output elsewhere).\n\n      * `--stream`:\n\n        Parse the input in streaming fashion, outputting arrays of path\n        and leaf values (scalars and empty arrays or empty objects).\n        For example, `\"a\"` becomes `[[],\"a\"]`, and `[[],\"a\",[\"b\"]]`\n        becomes `[[0],[]]`, `[[1],\"a\"]`, and `[[2,0],\"b\"]`.\n\n        This is useful for processing very large inputs.  Use this in\n        conjunction with filtering and the `reduce` and `foreach` syntax\n        to reduce large inputs incrementally.\n\n      * `--stream-errors`:\n\n        Like `--stream`, but invalid JSON inputs yield array values\n        where the first element is the error and the second is a path.\n        For example, `[\"a\",n]` produces `[\"Invalid literal at line 1,\n        column 7\",[1]]`.\n\n        Implies `--stream`.  Invalid JSON inputs produce no error values\n        when `--stream` without `--stream-errors`.\n\n      * `--seq`:\n\n        Use the `application/json-seq` MIME type scheme for separating\n        JSON texts in jq's input and output.  This means that an ASCII\n        RS (record separator) character is printed before each value on\n        output and an ASCII LF (line feed) is printed after every\n        output.  Input JSON texts that fail to parse are ignored (but\n        warned about), discarding all subsequent input until the next\n        RS.  This mode also parses the output of jq without the `--seq`\n        option.\n\n      * `-f filename` / `--from-file filename`:\n\n        Read filter from the file rather than from a command line, like\n        awk's -f option. You can also use '#' to make comments.\n\n      * `-L directory`:\n\n        Prepend `directory` to the search list for modules.  If this\n        option is used then no builtin search list is used.  See the\n        section on modules below.\n\n      * `--arg name value`:\n\n        This option passes a value to the jq program as a predefined\n        variable. If you run jq with `--arg foo bar`, then `$foo` is\n        available in the program and has the value `\"bar\"`. Note that\n        `value` will be treated as a string, so `--arg foo 123` will\n        bind `$foo` to `\"123\"`.\n\n        Named arguments are also available to the jq program as\n        `$ARGS.named`.\n\n      * `--argjson name JSON-text`:\n\n        This option passes a JSON-encoded value to the jq program as a\n        predefined variable. If you run jq with `--argjson foo 123`, then\n        `$foo` is available in the program and has the value `123`.\n\n      * `--slurpfile variable-name filename`:\n\n        This option reads all the JSON texts in the named file and binds\n        an array of the parsed JSON values to the given global variable.\n        If you run jq with `--slurpfile foo bar`, then `$foo` is available\n        in the program and has an array whose elements correspond to the\n        texts in the file named `bar`.\n\n      * `--rawfile variable-name filename`:\n\n        This option reads in the named file and binds its content to the given\n        global variable.  If you run jq with `--rawfile foo bar`, then `$foo` is\n        available in the program and has a string whose content is set to the text\n        in the file named `bar`.\n\n      * `--args`:\n\n        Remaining arguments are positional string arguments.  These are\n        available to the jq program as `$ARGS.positional[]`.\n\n      * `--jsonargs`:\n\n        Remaining arguments are positional JSON text arguments.  These\n        are available to the jq program as `$ARGS.positional[]`.\n\n      * `--exit-status` / `-e`:\n\n        Sets the exit status of jq to 0 if the last output value was\n        neither `false` nor `null`, 1 if the last output value was\n        either `false` or `null`, or 4 if no valid result was ever\n        produced.  Normally jq exits with 2 if there was any usage\n        problem or system error, 3 if there was a jq program compile\n        error, or 0 if the jq program ran.\n\n        Another way to set the exit status is with the `halt_error`\n        builtin function.\n\n      * `--binary` / `-b`:\n\n        Windows users using WSL, MSYS2, or Cygwin, should use this option\n        when using a native jq.exe, otherwise jq will turn newlines (LFs)\n        into carriage-return-then-newline (CRLF).\n\n      * `--version` / `-V`:\n\n        Output the jq version and exit with zero.\n\n      * `--build-configuration`:\n\n        Output the build configuration of jq and exit with zero.\n        This output has no supported format or structure and may change\n        without notice in future releases.\n\n      * `--help` / `-h`:\n\n        Output the jq help and exit with zero.\n\n      * `--`:\n\n        Terminates argument processing.  Remaining arguments are\n        positional, either strings, JSON texts, or input filenames,\n        according to whether `--args` or `--jsonargs` were given.\n\n      * `--run-tests [filename]`:\n\n        Runs the tests in the given file or standard input.  This must\n        be the last option given and does not honor all preceding\n        options.  The input consists of comment lines, empty lines, and\n        program lines followed by one input line, as many lines of\n        output as are expected (one per output), and a terminating empty\n        line.  Compilation failure tests start with a line containing\n        only `%%FAIL`, then a line containing the program to compile,\n        then a line containing an error message to compare to the\n        actual.\n\n        Be warned that this option can change backwards-incompatibly.\n\n  - title: Basic filters\n    entries:\n      - title: \"Identity: `.`\"\n        body: |\n\n          The absolute simplest filter is `.` .  This filter takes its\n          input and produces the same value as output.  That is, this\n          is the identity operator.\n\n          Since jq by default pretty-prints all output, a trivial\n          program consisting of nothing but `.` can be used to format\n          JSON output from, say, `curl`.\n\n          Although the identity filter never modifies the value of its\n          input, jq processing can sometimes make it appear as though\n          it does.  For example, using the current implementation of\n          jq, we would see that the expression:\n\n              1E1234567890 | .\n\n          produces `1.7976931348623157e+308` on at least one platform.\n          This is because, in the process of parsing the number, this\n          particular version of jq has converted it to an IEEE754\n          double-precision representation, losing precision.\n\n          The way in which jq handles numbers has changed over time\n          and further changes are likely within the parameters set by\n          the relevant JSON standards.  The following remarks are\n          therefore offered with the understanding that they are\n          intended to be descriptive of the current version of jq and\n          should not be interpreted as being prescriptive:\n\n          (1) Any arithmetic operation on a number that has not\n          already been converted to an IEEE754 double precision\n          representation will trigger a conversion to the IEEE754\n          representation.\n\n          (2) jq will attempt to maintain the original decimal\n          precision of number literals, but in expressions such\n          `1E1234567890`, precision will be lost if the exponent is\n          too large.\n\n          (3) In jq programs, a leading minus sign will trigger the\n          conversion of the number to an IEEE754 representation.\n\n          (4) Comparisons are carried out using the untruncated\n          big decimal representation of numbers if available, as\n          illustrated in one of the following examples.\n\n        examples:\n          - program: '.'\n            input: '\"Hello, world!\"'\n            output: ['\"Hello, world!\"']\n\n          - program: '.'\n            input: '0.12345678901234567890123456789'\n            output: ['0.12345678901234567890123456789']\n\n          - program: '[., tojson]'\n            input: '12345678909876543212345'\n            output: ['[12345678909876543212345,\"12345678909876543212345\"]']\n\n          - program: '. < 0.12345678901234567890123456788'\n            input: '0.12345678901234567890123456789'\n            output: ['false']\n\n          - program: 'map([., . == 1]) | tojson'\n            input: '[1, 1.000, 1.0, 100e-2]'\n            output: ['\"[[1,true],[1.000,true],[1.0,true],[1.00,true]]\"']\n\n          - program: '. as $big | [$big, $big + 1] | map(. > 10000000000000000000000000000000)'\n            input: '10000000000000000000000000000001'\n            output: ['[true, false]']\n\n      - title: \"Object Identifier-Index: `.foo`, `.foo.bar`\"\n        body: |\n\n          The simplest *useful* filter has the form `.foo`. When given a\n          JSON object (aka dictionary or hash) as input, `.foo` produces\n          the value at the key \"foo\" if the key is present, or null otherwise.\n\n          A filter of the form `.foo.bar` is equivalent to `.foo | .bar`.\n\n          The `.foo` syntax only works for simple, identifier-like keys, that\n          is, keys that are all made of alphanumeric characters and\n          underscore, and which do not start with a digit.\n\n          If the key contains special characters or starts with a digit,\n          you need to surround it with double quotes like this:\n          `.\"foo$\"`, or else `.[\"foo$\"]`.\n\n          For example `.[\"foo::bar\"]` and `.[\"foo.bar\"]` work while\n          `.foo::bar` does not.\n\n        examples:\n          - program: '.foo'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n\n          - program: '.foo'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n\n          - program: '.[\"foo\"]'\n            input: '{\"foo\": 42}'\n            output: ['42']\n\n      - title: \"Optional Object Identifier-Index: `.foo?`\"\n        body: |\n\n          Just like `.foo`, but does not output an error when `.` is not an\n          object.\n\n        examples:\n          - program: '.foo?'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n          - program: '.foo?'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n          - program: '.[\"foo\"]?'\n            input: '{\"foo\": 42}'\n            output: ['42']\n          - program: '[.foo?]'\n            input: '[1,2]'\n            output: ['[]']\n\n      - title: \"Object Index: `.[<string>]`\"\n        body: |\n\n          You can also look up fields of an object using syntax like\n          `.[\"foo\"]` (`.foo` above is a shorthand version of this, but\n          only for identifier-like strings).\n\n      - title: \"Array Index: `.[<number>]`\"\n        body: |\n\n          When the index value is an integer, `.[<number>]` can index\n          arrays.  Arrays are zero-based, so `.[2]` returns the third\n          element.\n\n          Negative indices are allowed, with -1 referring to the last\n          element, -2 referring to the next to last element, and so on.\n\n        examples:\n          - program: '.[0]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['{\"name\":\"JSON\", \"good\":true}']\n\n          - program: '.[2]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['null']\n\n          - program: '.[-2]'\n            input: '[1,2,3]'\n            output: ['2']\n\n      - title: \"Array/String Slice: `.[<number>:<number>]`\"\n        body: |\n\n          The `.[<number>:<number>]` syntax can be used to return a\n          subarray of an array or substring of a string. The array\n          returned by `.[10:15]` will be of length 5, containing the\n          elements from index 10 (inclusive) to index 15 (exclusive).\n          Either index may be negative (in which case it counts\n          backwards from the end of the array), or omitted (in which\n          case it refers to the start or end of the array).\n          Indices are zero-based.\n\n        examples:\n          - program: '.[2:4]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"c\", \"d\"]']\n\n          - program: '.[2:4]'\n            input: '\"abcdefghi\"'\n            output: ['\"cd\"']\n\n          - program: '.[:3]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"a\", \"b\", \"c\"]']\n\n          - program: '.[-2:]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"d\", \"e\"]']\n\n      - title: \"Array/Object Value Iterator: `.[]`\"\n        body: |\n\n          If you use the `.[index]` syntax, but omit the index\n          entirely, it will return *all* of the elements of an\n          array. Running `.[]` with the input `[1,2,3]` will produce the\n          numbers as three separate results, rather than as a single\n          array. A filter of the form `.foo[]` is equivalent to\n          `.foo | .[]`.\n\n          You can also use this on an object, and it will return all\n          the values of the object.\n\n          Note that the iterator operator is a generator of values.\n\n        examples:\n          - program: '.[]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output:\n              - '{\"name\":\"JSON\", \"good\":true}'\n              - '{\"name\":\"XML\", \"good\":false}'\n\n          - program: '.[]'\n            input: '[]'\n            output: []\n\n          - program: '.foo[]'\n            input: '{\"foo\":[1,2,3]}'\n            output: ['1','2','3']\n\n          - program: '.[]'\n            input: '{\"a\": 1, \"b\": 1}'\n            output: ['1', '1']\n\n      - title: \"`.[]?`\"\n        body: |\n\n          Like `.[]`, but no errors will be output if . is not an array\n          or object. A filter of the form `.foo[]?` is equivalent to\n          `.foo | .[]?`.\n\n      - title: \"Comma: `,`\"\n        body: |\n\n          If two filters are separated by a comma, then the\n          same input will be fed into both and the two filters' output\n          value streams will be concatenated in order: first, all of the\n          outputs produced by the left expression, and then all of the\n          outputs produced by the right. For instance, filter `.foo,\n          .bar`, produces both the \"foo\" fields and \"bar\" fields as\n          separate outputs.\n\n          The `,` operator is one way to construct generators.\n\n        examples:\n          - program: '.foo, .bar'\n            input: '{\"foo\": 42, \"bar\": \"something else\", \"baz\": true}'\n            output: ['42', '\"something else\"']\n\n          - program: \".user, .projects[]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['\"stedolan\"', '\"jq\"', '\"wikiflow\"']\n\n          - program: '.[4,2]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['\"e\"', '\"c\"']\n\n      - title: \"Pipe: `|`\"\n        body: |\n\n          The | operator combines two filters by feeding the output(s) of\n          the one on the left into the input of the one on the right. It's\n          similar to the Unix shell's pipe, if you're used to that.\n\n          If the one on the left produces multiple results, the one on\n          the right will be run for each of those results. So, the\n          expression `.[] | .foo` retrieves the \"foo\" field of each\n          element of the input array.  This is a cartesian product,\n          which can be surprising.\n\n          Note that `.a.b.c` is the same as `.a | .b | .c`.\n\n          Note too that `.` is the input value at the particular stage\n          in a \"pipeline\", specifically: where the `.` expression appears.\n          Thus `.a | . | .b` is the same as `.a.b`, as the `.` in the\n          middle refers to whatever value `.a` produced.\n\n        examples:\n          - program: '.[] | .name'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['\"JSON\"', '\"XML\"']\n\n      - title: \"Parenthesis\"\n        body: |\n\n          Parenthesis work as a grouping operator just as in any typical\n          programming language.\n\n        examples:\n          - program: '(. + 2) * 5'\n            input: '1'\n            output: ['15']\n\n  - title: Types and Values\n    body: |\n\n      jq supports the same set of datatypes as JSON - numbers,\n      strings, booleans, arrays, objects (which in JSON-speak are\n      hashes with only string keys), and \"null\".\n\n      Booleans, null, strings and numbers are written the same way as\n      in JSON. Just like everything else in jq, these simple\n      values take an input and produce an output - `42` is a valid jq\n      expression that takes an input, ignores it, and returns 42\n      instead.\n\n      Numbers in jq are internally represented by their IEEE754 double\n      precision approximation. Any arithmetic operation with numbers,\n      whether they are literals or results of previous filters, will\n      produce a double precision floating point result.\n\n      However, when parsing a literal jq will store the original literal\n      string. If no mutation is applied to this value then it will make\n      to the output in its original form, even if conversion to double\n      would result in a loss.\n\n    entries:\n      - title: \"Array construction: `[]`\"\n        body: |\n\n          As in JSON, `[]` is used to construct arrays, as in\n          `[1,2,3]`. The elements of the arrays can be any jq\n          expression, including a pipeline. All of the results produced\n          by all of the expressions are collected into one big array.\n          You can use it to construct an array out of a known quantity\n          of values (as in `[.foo, .bar, .baz]`) or to \"collect\" all the\n          results of a filter into an array (as in `[.items[].name]`)\n\n          Once you understand the \",\" operator, you can look at jq's array\n          syntax in a different light: the expression `[1,2,3]` is not using a\n          built-in syntax for comma-separated arrays, but is instead applying\n          the `[]` operator (collect results) to the expression 1,2,3 (which\n          produces three different results).\n\n          If you have a filter `X` that produces four results,\n          then the expression `[X]` will produce a single result, an\n          array of four elements.\n\n        examples:\n          - program: \"[.user, .projects[]]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['[\"stedolan\", \"jq\", \"wikiflow\"]']\n          - program: \"[ .[] | . * 2]\"\n            input: '[1, 2, 3]'\n            output: ['[2, 4, 6]']\n\n      - title: \"Object Construction: `{}`\"\n        body: |\n\n          Like JSON, `{}` is for constructing objects (aka\n          dictionaries or hashes), as in: `{\"a\": 42, \"b\": 17}`.\n\n          If the keys are \"identifier-like\", then the quotes can be left\n          off, as in `{a:42, b:17}`.  Variable references as key\n          expressions use the value of the variable as the key.  Key\n          expressions other than constant literals, identifiers, or\n          variable references, need to be parenthesized, e.g.,\n          `{(\"a\"+\"b\"):59}`.\n\n          The value can be any expression (although you may need to wrap\n          it in parentheses if, for example, it contains colons), which\n          gets applied to the {} expression's input (remember, all\n          filters have an input and an output).\n\n              {foo: .bar}\n\n          will produce the JSON object `{\"foo\": 42}` if given the JSON\n          object `{\"bar\":42, \"baz\":43}` as its input. You can use this\n          to select particular fields of an object: if the input is an\n          object with \"user\", \"title\", \"id\", and \"content\" fields and\n          you just want \"user\" and \"title\", you can write\n\n              {user: .user, title: .title}\n\n          Because that is so common, there's a shortcut syntax for it:\n          `{user, title}`.\n\n          If one of the expressions produces multiple results,\n          multiple dictionaries will be produced. If the input's\n\n              {\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n\n          then the expression\n\n              {user, title: .titles[]}\n\n          will produce two outputs:\n\n              {\"user\":\"stedolan\", \"title\": \"JQ Primer\"}\n              {\"user\":\"stedolan\", \"title\": \"More JQ\"}\n\n          Putting parentheses around the key means it will be evaluated as an\n          expression. With the same input as above,\n\n              {(.user): .titles}\n\n          produces\n\n              {\"stedolan\": [\"JQ Primer\", \"More JQ\"]}\n\n          Variable references as keys use the value of the variable as\n          the key.  Without a value then the variable's name becomes the\n          key and its value becomes the value,\n\n              \"f o o\" as $foo | \"b a r\" as $bar | {$foo, $bar:$foo}\n\n          produces\n\n              {\"foo\":\"f o o\",\"b a r\":\"f o o\"}\n\n        examples:\n          - program: '{user, title: .titles[]}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output:\n              - '{\"user\":\"stedolan\", \"title\": \"JQ Primer\"}'\n              - '{\"user\":\"stedolan\", \"title\": \"More JQ\"}'\n          - program: '{(.user): .titles}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output: ['{\"stedolan\": [\"JQ Primer\", \"More JQ\"]}']\n\n      - title: \"Recursive Descent: `..`\"\n        body: |\n\n          Recursively descends `.`, producing every value.  This is the\n          same as the zero-argument `recurse` builtin (see below).  This\n          is intended to resemble the XPath `//` operator.  Note that\n          `..a` does not work; use `.. | .a` instead.  In the example\n          below we use `.. | .a?` to find all the values of object keys\n          \"a\" in any object found \"below\" `.`.\n\n          This is particularly useful in conjunction with `path(EXP)`\n          (also see below) and the `?` operator.\n\n        examples:\n          - program: '.. | .a?'\n            input: '[[{\"a\":1}]]'\n            output: ['1']\n\n  - title: Builtin operators and functions\n    body: |\n\n      Some jq operators (for instance, `+`) do different things\n      depending on the type of their arguments (arrays, numbers,\n      etc.). However, jq never does implicit type conversions. If you\n      try to add a string to an object you'll get an error message and\n      no result.\n\n      Please note that all numbers are converted to IEEE754 double precision\n      floating point representation. Arithmetic and logical operators are working\n      with these converted doubles. Results of all such operations are also limited\n      to the double precision.\n\n      The only exception to this behaviour of number is a snapshot of original number\n      literal. When a number which originally was provided as a literal is never\n      mutated until the end of the program then it is printed to the output in its\n      original literal form. This also includes cases when the original literal\n      would be truncated when converted to the IEEE754 double precision floating point\n      number.\n\n    entries:\n      - title: \"Addition: `+`\"\n        body: |\n\n          The operator `+` takes two filters, applies them both\n          to the same input, and adds the results together. What\n          \"adding\" means depends on the types involved:\n\n          - **Numbers** are added by normal arithmetic.\n\n          - **Arrays** are added by being concatenated into a larger array.\n\n          - **Strings** are added by being joined into a larger string.\n\n          - **Objects** are added by merging, that is, inserting all\n            the key-value pairs from both objects into a single\n            combined object. If both objects contain a value for the\n            same key, the object on the right of the `+` wins. (For\n            recursive merge use the `*` operator.)\n\n          `null` can be added to any value, and returns the other\n          value unchanged.\n\n        examples:\n          - program: '.a + 1'\n            input: '{\"a\": 7}'\n            output: ['8']\n          - program: '.a + .b'\n            input: '{\"a\": [1,2], \"b\": [3,4]}'\n            output: ['[1,2,3,4]']\n          - program: '.a + null'\n            input: '{\"a\": 1}'\n            output: ['1']\n          - program: '.a + 1'\n            input: '{}'\n            output: ['1']\n          - program: '{a: 1} + {b: 2} + {c: 3} + {a: 42}'\n            input: 'null'\n            output: ['{\"a\": 42, \"b\": 2, \"c\": 3}']\n\n      - title: \"Subtraction: `-`\"\n        body: |\n\n          As well as normal arithmetic subtraction on numbers, the `-`\n          operator can be used on arrays to remove all occurrences of\n          the second array's elements from the first array.\n\n        examples:\n          - program: '4 - .a'\n            input: '{\"a\":3}'\n            output: ['1']\n          - program: . - [\"xml\", \"yaml\"]\n            input: '[\"xml\", \"yaml\", \"json\"]'\n            output: ['[\"json\"]']\n\n      - title: \"Multiplication, division, modulo: `*`, `/`, `%`\"\n        body: |\n\n          These infix operators behave as expected when given two numbers.\n          Division by zero raises an error. `x % y` computes x modulo y.\n\n          Multiplying a string by a number produces the concatenation of\n          that string that many times. `\"x\" * 0` produces `\"\"`.\n\n          Dividing a string by another splits the first using the second\n          as separators.\n\n          Multiplying two objects will merge them recursively: this works\n          like addition but if both objects contain a value for the\n          same key, and the values are objects, the two are merged with\n          the same strategy.\n\n        examples:\n          - program: '10 / . * 3'\n            input: '5'\n            output: ['6']\n          - program: '. / \", \"'\n            input: '\"a, b,c,d, e\"'\n            output: ['[\"a\",\"b,c,d\",\"e\"]']\n          - program: '{\"k\": {\"a\": 1, \"b\": 2}} * {\"k\": {\"a\": 0,\"c\": 3}}'\n            input: 'null'\n            output: ['{\"k\": {\"a\": 0, \"b\": 2, \"c\": 3}}']\n          - program: '.[] | (1 / .)?'\n            input: '[1,0,-1]'\n            output: ['1', '-1']\n\n      - title: \"`abs`\"\n        body: |\n\n          The builtin function `abs` is defined naively as: `if . < 0 then - . else . end`.\n\n          For numeric input, this is the absolute value.  See the\n          section on the identity filter for the implications of this\n          definition for numeric input.\n\n          To compute the absolute value of a number as a floating point number, you may wish use `fabs`.\n\n        examples:\n          - program: 'map(abs)'\n            input: '[-10, -1.1, -1e-1]'\n            output: ['[10,1.1,1e-1]']\n\n      - title: \"`length`\"\n        body: |\n\n          The builtin function `length` gets the length of various\n          different types of value:\n\n          - The length of a **string** is the number of Unicode\n            codepoints it contains (which will be the same as its\n            JSON-encoded length in bytes if it's pure ASCII).\n\n          - The length of a **number** is its absolute value.\n\n          - The length of an **array** is the number of elements.\n\n          - The length of an **object** is the number of key-value pairs.\n\n          - The length of **null** is zero.\n\n          - It is an error to use `length` on a **boolean**.\n\n        examples:\n          - program: '.[] | length'\n            input: '[[1,2], \"string\", {\"a\":2}, null, -5]'\n            output: ['2', '6', '1', '0', '5']\n\n\n      - title: \"`utf8bytelength`\"\n        body: |\n\n          The builtin function `utf8bytelength` outputs the number of\n          bytes used to encode a string in UTF-8.\n\n        examples:\n          - program: 'utf8bytelength'\n            input: '\"\\u03bc\"'\n            output: ['2']\n\n      - title: \"`keys`, `keys_unsorted`\"\n        body: |\n\n          The builtin function `keys`, when given an object, returns\n          its keys in an array.\n\n          The keys are sorted \"alphabetically\", by unicode codepoint\n          order. This is not an order that makes particular sense in\n          any particular language, but you can count on it being the\n          same for any two objects with the same set of keys,\n          regardless of locale settings.\n\n          When `keys` is given an array, it returns the valid indices\n          for that array: the integers from 0 to length-1.\n\n          The `keys_unsorted` function is just like `keys`, but if\n          the input is an object then the keys will not be sorted,\n          instead the keys will roughly be in insertion order.\n\n        examples:\n          - program: 'keys'\n            input: '{\"abc\": 1, \"abcd\": 2, \"Foo\": 3}'\n            output: ['[\"Foo\", \"abc\", \"abcd\"]']\n          - program: 'keys'\n            input: '[42,3,35]'\n            output: ['[0,1,2]']\n\n      - title: \"`has(key)`\"\n        body: |\n\n          The builtin function `has` returns whether the input object\n          has the given key, or the input array has an element at the\n          given index.\n\n          `has($key)` has the same effect as checking whether `$key`\n          is a member of the array returned by `keys`, although `has`\n          will be faster.\n\n        examples:\n          - program: 'map(has(\"foo\"))'\n            input: '[{\"foo\": 42}, {}]'\n            output: ['[true, false]']\n          - program: 'map(has(2))'\n            input: '[[0,1], [\"a\",\"b\",\"c\"]]'\n            output: ['[false, true]']\n\n      - title: \"`in`\"\n        body: |\n\n          The builtin function `in` returns whether or not the input key is in the\n          given object, or the input index corresponds to an element\n          in the given array. It is, essentially, an inversed version\n          of `has`.\n\n        examples:\n          - program: '.[] | in({\"foo\": 42})'\n            input: '[\"foo\", \"bar\"]'\n            output: ['true', 'false']\n          - program: 'map(in([0,1]))'\n            input: '[2, 0]'\n            output: ['[false, true]']\n\n      - title: \"`map(f)`, `map_values(f)`\"\n        body: |\n\n          For any filter `f`, `map(f)` and `map_values(f)` apply `f`\n          to each of the values in the input array or object, that is,\n          to the values of `.[]`.\n\n          In the absence of errors, `map(f)` always outputs an array\n          whereas `map_values(f)` outputs an array if given an array,\n          or an object if given an object.\n\n          When the input to `map_values(f)` is an object, the output\n          object has the same keys as the input object except for\n          those keys whose values when piped to `f` produce no values\n          at all.\n\n          The key difference between `map(f)` and `map_values(f)` is\n          that the former simply forms an array from all the values of\n          `($x|f)` for each value, `$x`, in the input array or object,\n          but `map_values(f)` only uses `first($x|f)`.\n\n          Specifically, for object inputs, `map_values(f)` constructs\n          the output object by examining in turn the value of\n          `first(.[$k]|f)` for each key, `$k`, of the input.  If this\n          expression produces no values, then the corresponding key\n          will be dropped; otherwise, the output object will have that\n          value at the key, `$k`.\n\n          Here are some examples to clarify the behavior of `map` and\n          `map_values` when applied to arrays. These examples assume the\n          input is `[1]` in all cases:\n\n              map(.+1)          #=>  [2]\n              map(., .)         #=>  [1,1]\n              map(empty)        #=>  []\n\n              map_values(.+1)   #=>  [2]\n              map_values(., .)  #=>  [1]\n              map_values(empty) #=>  []\n\n          `map(f)` is equivalent to `[.[] | f]` and\n          `map_values(f)` is equivalent to `.[] |= f`.\n\n          In fact, these are their implementations.\n\n\n        examples:\n          - program: 'map(.+1)'\n            input: '[1,2,3]'\n            output: ['[2,3,4]']\n\n          - program: 'map_values(.+1)'\n            input: '{\"a\": 1, \"b\": 2, \"c\": 3}'\n            output: ['{\"a\": 2, \"b\": 3, \"c\": 4}']\n\n          - program: 'map(., .)'\n            input: '[1,2]'\n            output: ['[1,1,2,2]']\n\n          - program: 'map_values(. // empty)'\n            input: '{\"a\": null, \"b\": true, \"c\": false}'\n            output: ['{\"b\":true}']\n\n\n      - title: \"`pick(pathexps)`\"\n        body: |\n\n          Emit the projection of the input object or array defined by the\n          specified sequence of path expressions, such that if `p` is any\n          one of these specifications, then `(. | p)` will evaluate to the\n          same value as `(. | pick(pathexps) | p)`. For arrays, negative\n          indices and `.[m:n]` specifications should not be used.\n\n        examples:\n          - program: 'pick(.a, .b.c, .x)'\n            input: '{\"a\": 1, \"b\": {\"c\": 2, \"d\": 3}, \"e\": 4}'\n            output: ['{\"a\":1,\"b\":{\"c\":2},\"x\":null}']\n\n          - program: 'pick(.[2], .[0], .[0])'\n            input: '[1,2,3,4]'\n            output: ['[1,null,3]']\n\n\n      - title: \"`path(path_expression)`\"\n        body: |\n\n          Outputs array representations of the given path expression\n          in `.`.  The outputs are arrays of strings (object keys)\n          and/or numbers (array indices).\n\n          Path expressions are jq expressions like `.a`, but also `.[]`.\n          There are two types of path expressions: ones that can match\n          exactly, and ones that cannot.  For example, `.a.b.c` is an\n          exact match path expression, while `.a[].b` is not.\n\n          `path(exact_path_expression)` will produce the array\n          representation of the path expression even if it does not\n          exist in `.`, if `.` is `null` or an array or an object.\n\n          `path(pattern)` will produce array representations of the\n          paths matching `pattern` if the paths exist in `.`.\n\n          Note that the path expressions are not different from normal\n          expressions.  The expression\n          `path(..|select(type==\"boolean\"))` outputs all the paths to\n          boolean values in `.`, and only those paths.\n\n        examples:\n          - program: 'path(.a[0].b)'\n            input: 'null'\n            output: ['[\"a\",0,\"b\"]']\n          - program: '[path(..)]'\n            input: '{\"a\":[{\"b\":1}]}'\n            output: ['[[],[\"a\"],[\"a\",0],[\"a\",0,\"b\"]]']\n\n      - title: \"`del(path_expression)`\"\n        body: |\n\n          The builtin function `del` removes a key and its corresponding\n          value from an object.\n\n        examples:\n          - program: 'del(.foo)'\n            input: '{\"foo\": 42, \"bar\": 9001, \"baz\": 42}'\n            output: ['{\"bar\": 9001, \"baz\": 42}']\n          - program: 'del(.[1, 2])'\n            input: '[\"foo\", \"bar\", \"baz\"]'\n            output: ['[\"foo\"]']\n\n      - title: \"`getpath(PATHS)`\"\n        body: |\n\n          The builtin function `getpath` outputs the values in `.` found\n          at each path in `PATHS`.\n\n        examples:\n          - program: 'getpath([\"a\",\"b\"])'\n            input: 'null'\n            output: ['null']\n          - program: '[getpath([\"a\",\"b\"], [\"a\",\"c\"])]'\n            input: '{\"a\":{\"b\":0, \"c\":1}}'\n            output: ['[0, 1]']\n\n      - title: \"`setpath(PATHS; VALUE)`\"\n        body: |\n\n          The builtin function `setpath` sets the `PATHS` in `.` to `VALUE`.\n\n        examples:\n          - program: 'setpath([\"a\",\"b\"]; 1)'\n            input: 'null'\n            output: ['{\"a\": {\"b\": 1}}']\n          - program: 'setpath([\"a\",\"b\"]; 1)'\n            input: '{\"a\":{\"b\":0}}'\n            output: ['{\"a\": {\"b\": 1}}']\n          - program: 'setpath([0,\"a\"]; 1)'\n            input: 'null'\n            output: ['[{\"a\":1}]']\n\n      - title: \"`delpaths(PATHS)`\"\n        body: |\n\n          The builtin function `delpaths` deletes the `PATHS` in `.`.\n          `PATHS` must be an array of paths, where each path is an array\n          of strings and numbers.\n\n        examples:\n          - program: 'delpaths([[\"a\",\"b\"]])'\n            input: '{\"a\":{\"b\":1},\"x\":{\"y\":2}}'\n            output: ['{\"a\":{},\"x\":{\"y\":2}}']\n\n      - title: \"`to_entries`, `from_entries`, `with_entries(f)`\"\n        body: |\n\n          These functions convert between an object and an array of\n          key-value pairs. If `to_entries` is passed an object, then\n          for each `k: v` entry in the input, the output array\n          includes `{\"key\": k, \"value\": v}`.\n\n          `from_entries` does the opposite conversion, and `with_entries(f)`\n          is a shorthand for `to_entries | map(f) | from_entries`, useful for\n          doing some operation to all keys and values of an object.\n          `from_entries` accepts `\"key\"`, `\"Key\"`, `\"name\"`, `\"Name\"`,\n          `\"value\"`, and `\"Value\"` as keys.\n\n        examples:\n          - program: 'to_entries'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]']\n          - program: 'from_entries'\n            input: '[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]'\n            output: ['{\"a\": 1, \"b\": 2}']\n          - program: 'with_entries(.key |= \"KEY_\" + .)'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['{\"KEY_a\": 1, \"KEY_b\": 2}']\n\n\n      - title: \"`select(boolean_expression)`\"\n        body: |\n\n          The function `select(f)` produces its input unchanged if\n          `f` returns true for that input, and produces no output\n          otherwise.\n\n          It's useful for filtering lists: `[1,2,3] | map(select(. >= 2))`\n          will give you `[2,3]`.\n\n        examples:\n          - program: 'map(select(. >= 2))'\n            input: '[1,5,3,0,7]'\n            output: ['[5,3,7]']\n          - program: '.[] | select(.id == \"second\")'\n            input: '[{\"id\": \"first\", \"val\": 1}, {\"id\": \"second\", \"val\": 2}]'\n            output: ['{\"id\": \"second\", \"val\": 2}']\n\n\n      - title: \"`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `normals`, `finites`, `strings`, `nulls`, `values`, `scalars`\"\n        body: |\n\n          These built-ins select only inputs that are arrays, objects,\n          iterables (arrays or objects), booleans, numbers, normal\n          numbers, finite numbers, strings, null, non-null values, and\n          non-iterables, respectively.\n\n        examples:\n          - program: '.[]|numbers'\n            input: '[[],{},1,\"foo\",null,true,false]'\n            output: ['1']\n\n      - title: \"`empty`\"\n        body: |\n\n          `empty` returns no results. None at all. Not even `null`.\n\n          It's useful on occasion. You'll know if you need it :)\n\n        examples:\n          - program: '1, empty, 2'\n            input: 'null'\n            output: ['1', '2']\n          - program: '[1,2,empty,3]'\n            input: 'null'\n            output: ['[1,2,3]']\n\n      - title: \"`error`, `error(message)`\"\n        body: |\n\n          Produces an error with the input value, or with the message\n          given as the argument. Errors can be caught with try/catch;\n          see below.\n\n        examples:\n          - program: 'try error catch .'\n            input: '\"error message\"'\n            output: ['\"error message\"']\n\n          - program: 'try error(\"invalid value: \\(.)\") catch .'\n            input: '42'\n            output: ['\"invalid value: 42\"']\n\n      - title: \"`halt`\"\n        body: |\n\n          Stops the jq program with no further outputs.  jq will exit\n          with exit status `0`.\n\n      - title: \"`halt_error`, `halt_error(exit_code)`\"\n        body: |\n\n          Stops the jq program with no further outputs.  The input will\n          be printed on `stderr` as raw output (i.e., strings will not\n          have double quotes) with no decoration, not even a newline.\n\n          The given `exit_code` (defaulting to `5`) will be jq's exit\n          status.\n\n          For example, `\"Error: something went wrong\\n\"|halt_error(1)`.\n\n      - title: \"`$__loc__`\"\n        body: |\n\n          Produces an object with a \"file\" key and a \"line\" key, with\n          the filename and line number where `$__loc__` occurs, as\n          values.\n\n        examples:\n          - program: 'try error(\"\\($__loc__)\") catch .'\n            input: 'null'\n            output: ['\"{\\\"file\\\":\\\"<top-level>\\\",\\\"line\\\":1}\"']\n\n      - title: \"`paths`, `paths(node_filter)`\"\n        body: |\n\n          `paths` outputs the paths to all the elements in its input\n          (except it does not output the empty list, representing .\n          itself).\n\n          `paths(f)` outputs the paths to any values for which `f` is `true`.\n          That is, `paths(type == \"number\")` outputs the paths to all numeric\n          values.\n\n        examples:\n          - program: '[paths]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1],[1,0],[1,1],[1,1,\"a\"]]']\n          - program: '[paths(type == \"number\")]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1,1,\"a\"]]']\n\n      - title: \"`add`\"\n        body: |\n\n          The filter `add` takes as input an array, and produces as\n          output the elements of the array added together. This might\n          mean summed, concatenated or merged depending on the types\n          of the elements of the input array - the rules are the same\n          as those for the `+` operator (described above).\n\n          If the input is an empty array, `add` returns `null`.\n\n        examples:\n          - program: add\n            input: '[\"a\",\"b\",\"c\"]'\n            output: ['\"abc\"']\n          - program: add\n            input: '[1, 2, 3]'\n            output: ['6']\n          - program: add\n            input: '[]'\n            output: [\"null\"]\n\n      - title: \"`any`, `any(condition)`, `any(generator; condition)`\"\n        body: |\n\n          The filter `any` takes as input an array of boolean values,\n          and produces `true` as output if any of the elements of\n          the array are `true`.\n\n          If the input is an empty array, `any` returns `false`.\n\n          The `any(condition)` form applies the given condition to the\n          elements of the input array.\n\n          The `any(generator; condition)` form applies the given\n          condition to all the outputs of the given generator.\n\n        examples:\n          - program: any\n            input: '[true, false]'\n            output: [\"true\"]\n          - program: any\n            input: '[false, false]'\n            output: [\"false\"]\n          - program: any\n            input: '[]'\n            output: [\"false\"]\n\n      - title: \"`all`, `all(condition)`, `all(generator; condition)`\"\n        body: |\n\n          The filter `all` takes as input an array of boolean values,\n          and produces `true` as output if all of the elements of\n          the array are `true`.\n\n          The `all(condition)` form applies the given condition to the\n          elements of the input array.\n\n          The `all(generator; condition)` form applies the given\n          condition to all the outputs of the given generator.\n\n          If the input is an empty array, `all` returns `true`.\n\n        examples:\n          - program: all\n            input: '[true, false]'\n            output: [\"false\"]\n          - program: all\n            input: '[true, true]'\n            output: [\"true\"]\n          - program: all\n            input: '[]'\n            output: [\"true\"]\n\n      - title: \"`flatten`, `flatten(depth)`\"\n        body: |\n\n          The filter `flatten` takes as input an array of nested arrays,\n          and produces a flat array in which all arrays inside the original\n          array have been recursively replaced by their values. You can pass\n          an argument to it to specify how many levels of nesting to flatten.\n\n          `flatten(2)` is like `flatten`, but going only up to two\n          levels deep.\n\n        examples:\n          - program: flatten\n            input: '[1, [2], [[3]]]'\n            output: [\"[1, 2, 3]\"]\n          - program: flatten(1)\n            input: '[1, [2], [[3]]]'\n            output: [\"[1, 2, [3]]\"]\n          - program: flatten\n            input: '[[]]'\n            output: [\"[]\"]\n          - program: flatten\n            input: '[{\"foo\": \"bar\"}, [{\"foo\": \"baz\"}]]'\n            output: ['[{\"foo\": \"bar\"}, {\"foo\": \"baz\"}]']\n\n      - title: \"`range(upto)`, `range(from; upto)`, `range(from; upto; by)`\"\n        body: |\n\n          The `range` function produces a range of numbers. `range(4; 10)`\n          produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers\n          are produced as separate outputs. Use `[range(4; 10)]` to get a range as\n          an array.\n\n          The one argument form generates numbers from 0 to the given\n          number, with an increment of 1.\n\n          The two argument form generates numbers from `from` to `upto`\n          with an increment of 1.\n\n          The three argument form generates numbers `from` to `upto`\n          with an increment of `by`.\n\n        examples:\n          - program: 'range(2; 4)'\n            input: 'null'\n            output: ['2', '3']\n          - program: '[range(2; 4)]'\n            input: 'null'\n            output: ['[2,3]']\n          - program: '[range(4)]'\n            input: 'null'\n            output: ['[0,1,2,3]']\n          - program: '[range(0; 10; 3)]'\n            input: 'null'\n            output: ['[0,3,6,9]']\n          - program: '[range(0; 10; -1)]'\n            input: 'null'\n            output: ['[]']\n          - program: '[range(0; -5; -1)]'\n            input: 'null'\n            output: ['[0,-1,-2,-3,-4]']\n\n      - title: \"`floor`\"\n        body: |\n\n          The `floor` function returns the floor of its numeric input.\n\n        examples:\n          - program: 'floor'\n            input: '3.14159'\n            output: ['3']\n\n      - title: \"`sqrt`\"\n        body: |\n\n          The `sqrt` function returns the square root of its numeric input.\n\n        examples:\n          - program: 'sqrt'\n            input: '9'\n            output: ['3']\n\n      - title: \"`tonumber`\"\n        body: |\n\n          The `tonumber` function parses its input as a number. It\n          will convert correctly-formatted strings to their numeric\n          equivalent, leave numbers alone, and give an error on all other input.\n\n        examples:\n          - program: '.[] | tonumber'\n            input: '[1, \"1\"]'\n            output: ['1', '1']\n\n      - title: \"`tostring`\"\n        body: |\n\n          The `tostring` function prints its input as a\n          string. Strings are left unchanged, and all other values are\n          JSON-encoded.\n\n        examples:\n          - program: '.[] | tostring'\n            input: '[1, \"1\", [1]]'\n            output: ['\"1\"', '\"1\"', '\"[1]\"']\n\n      - title: \"`type`\"\n        body: |\n\n          The `type` function returns the type of its argument as a\n          string, which is one of null, boolean, number, string, array\n          or object.\n\n        examples:\n          - program: 'map(type)'\n            input: '[0, false, [], {}, null, \"hello\"]'\n            output: ['[\"number\", \"boolean\", \"array\", \"object\", \"null\", \"string\"]']\n\n      - title: \"`infinite`, `nan`, `isinfinite`, `isnan`, `isfinite`, `isnormal`\"\n        body: |\n\n          Some arithmetic operations can yield infinities and \"not a\n          number\" (NaN) values.  The `isinfinite` builtin returns `true`\n          if its input is infinite.  The `isnan` builtin returns `true`\n          if its input is a NaN.  The `infinite` builtin returns a\n          positive infinite value.  The `nan` builtin returns a NaN.\n          The `isnormal` builtin returns true if its input is a normal\n          number.\n\n          Note that division by zero raises an error.\n\n          Currently most arithmetic operations operating on infinities,\n          NaNs, and sub-normals do not raise errors.\n\n        examples:\n          - program: '.[] | (infinite * .) < 0'\n            input: '[-1, 1]'\n            output: ['true', 'false']\n          - program: 'infinite, nan | type'\n            input: 'null'\n            output: ['\"number\"', '\"number\"']\n\n      - title: \"`sort`, `sort_by(path_expression)`\"\n        body: |\n\n          The `sort` functions sorts its input, which must be an\n          array. Values are sorted in the following order:\n\n          * `null`\n          * `false`\n          * `true`\n          * numbers\n          * strings, in alphabetical order (by unicode codepoint value)\n          * arrays, in lexical order\n          * objects\n\n          The ordering for objects is a little complex: first they're\n          compared by comparing their sets of keys (as arrays in\n          sorted order), and if their keys are equal then the values\n          are compared key by key.\n\n          `sort_by` may be used to sort by a particular field of an\n          object, or by applying any jq filter. `sort_by(f)` compares\n          two elements by comparing the result of `f` on each element.\n          When `f` produces multiple values, it firstly compares the\n          first values, and the second values if the first values are\n          equal, and so on.\n\n        examples:\n          - program: 'sort'\n            input: '[8,3,null,6]'\n            output: ['[null,3,6,8]']\n\n          - program: 'sort_by(.foo)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":10}, {\"foo\":2, \"bar\":1}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":4, \"bar\":10}]']\n\n          - program: 'sort_by(.foo, .bar)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":4, \"bar\":10}]']\n\n      - title: \"`group_by(path_expression)`\"\n        body: |\n\n          `group_by(.foo)` takes as input an array, groups the\n          elements having the same `.foo` field into separate arrays,\n          and produces all of these arrays as elements of a larger\n          array, sorted by the value of the `.foo` field.\n\n          Any jq expression, not just a field access, may be used in\n          place of `.foo`. The sorting order is the same as described\n          in the `sort` function above.\n\n        examples:\n          - program: 'group_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":10}, {\"foo\":3, \"bar\":100}, {\"foo\":1, \"bar\":1}]'\n            output: ['[[{\"foo\":1, \"bar\":10}, {\"foo\":1, \"bar\":1}], [{\"foo\":3, \"bar\":100}]]']\n\n      - title: \"`min`, `max`, `min_by(path_exp)`, `max_by(path_exp)`\"\n        body: |\n\n          Find the minimum or maximum element of the input array.\n\n          The `min_by(path_exp)` and `max_by(path_exp)` functions allow\n          you to specify a particular field or property to examine, e.g.\n          `min_by(.foo)` finds the object with the smallest `foo` field.\n\n        examples:\n          - program: 'min'\n            input: '[5,4,2,7]'\n            output: ['2']\n          - program: 'max_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":14}, {\"foo\":2, \"bar\":3}]'\n            output: ['{\"foo\":2, \"bar\":3}']\n\n      - title: \"`unique`, `unique_by(path_exp)`\"\n        body: |\n\n          The `unique` function takes as input an array and produces\n          an array of the same elements, in sorted order, with\n          duplicates removed.\n\n          The `unique_by(path_exp)` function will keep only one element\n          for each value obtained by applying the argument. Think of it\n          as making an array by taking one element out of every group\n          produced by `group`.\n\n        examples:\n          - program: 'unique'\n            input: '[1,2,5,3,5,3,1,3]'\n            output: ['[1,2,3,5]']\n          - program: 'unique_by(.foo)'\n            input: '[{\"foo\": 1, \"bar\": 2}, {\"foo\": 1, \"bar\": 3}, {\"foo\": 4, \"bar\": 5}]'\n            output: ['[{\"foo\": 1, \"bar\": 2}, {\"foo\": 4, \"bar\": 5}]']\n          - program: 'unique_by(length)'\n            input: '[\"chunky\", \"bacon\", \"kitten\", \"cicada\", \"asparagus\"]'\n            output: ['[\"bacon\", \"chunky\", \"asparagus\"]']\n\n      - title: \"`reverse`\"\n        body: |\n\n          This function reverses an array.\n\n        examples:\n          - program: 'reverse'\n            input: '[1,2,3,4]'\n            output: ['[4,3,2,1]']\n\n      - title: \"`contains(element)`\"\n        body: |\n\n          The filter `contains(b)` will produce true if b is\n          completely contained within the input. A string B is\n          contained in a string A if B is a substring of A. An array B\n          is contained in an array A if all elements in B are\n          contained in any element in A. An object B is contained in\n          object A if all of the values in B are contained in the\n          value in A with the same key. All other types are assumed to\n          be contained in each other if they are equal.\n\n        examples:\n          - program: 'contains(\"bar\")'\n            input: '\"foobar\"'\n            output: ['true']\n          - program: 'contains([\"baz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['true']\n          - program: 'contains([\"bazzzzz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['false']\n          - program: 'contains({foo: 12, bar: [{barp: 12}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['true']\n          - program: 'contains({foo: 12, bar: [{barp: 15}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['false']\n\n      - title: \"`indices(s)`\"\n        body: |\n\n          Outputs an array containing the indices in `.` where `s`\n          occurs.  The input may be an array, in which case if `s` is an\n          array then the indices output will be those where all elements\n          in `.` match those of `s`.\n\n        examples:\n          - program: 'indices(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['[3,7,12]']\n          - program: 'indices(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['[1,3,5]']\n          - program: 'indices([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['[1,8]']\n\n      - title: \"`index(s)`, `rindex(s)`\"\n        body: |\n\n          Outputs the index of the first (`index`) or last (`rindex`)\n          occurrence of `s` in the input.\n\n        examples:\n          - program: 'index(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['3']\n          - program: 'index(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['1']\n          - program: 'index([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['1']\n          - program: 'rindex(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['12']\n          - program: 'rindex(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['5']\n          - program: 'rindex([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['8']\n\n      - title: \"`inside`\"\n        body: |\n\n          The filter `inside(b)` will produce true if the input is\n          completely contained within b. It is, essentially, an\n          inversed version of `contains`.\n\n        examples:\n          - program: 'inside(\"foobar\")'\n            input: '\"bar\"'\n            output: ['true']\n          - program: 'inside([\"foobar\", \"foobaz\", \"blarp\"])'\n            input: '[\"baz\", \"bar\"]'\n            output: ['true']\n          - program: 'inside([\"foobar\", \"foobaz\", \"blarp\"])'\n            input: '[\"bazzzzz\", \"bar\"]'\n            output: ['false']\n          - program: 'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})'\n            input: '{\"foo\": 12, \"bar\": [{\"barp\": 12}]}'\n            output: ['true']\n          - program: 'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})'\n            input: '{\"foo\": 12, \"bar\": [{\"barp\": 15}]}'\n            output: ['false']\n\n      - title: \"`startswith(str)`\"\n        body: |\n\n          Outputs `true` if . starts with the given string argument.\n\n        examples:\n          - program: '[.[]|startswith(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"barfoob\"]'\n            output: ['[false, true, false, true, false]']\n\n      - title: \"`endswith(str)`\"\n        body: |\n\n          Outputs `true` if . ends with the given string argument.\n\n        examples:\n          - program: '[.[]|endswith(\"foo\")]'\n            input: '[\"foobar\", \"barfoo\"]'\n            output: ['[false, true]']\n\n      - title: \"`combinations`, `combinations(n)`\"\n        body: |\n\n          Outputs all combinations of the elements of the arrays in the\n          input array. If given an argument `n`, it outputs all combinations\n          of `n` repetitions of the input array.\n\n        examples:\n          - program: 'combinations'\n            input: '[[1,2], [3, 4]]'\n            output: ['[1, 3]', '[1, 4]', '[2, 3]', '[2, 4]']\n          - program: 'combinations(2)'\n            input: '[0, 1]'\n            output: ['[0, 0]', '[0, 1]', '[1, 0]', '[1, 1]']\n\n      - title: \"`ltrimstr(str)`\"\n        body: |\n\n          Outputs its input with the given prefix string removed, if it\n          starts with it.\n\n        examples:\n          - program: '[.[]|ltrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"afoo\"]'\n            output: ['[\"fo\",\"\",\"barfoo\",\"bar\",\"afoo\"]']\n\n      - title: \"`rtrimstr(str)`\"\n        body: |\n\n          Outputs its input with the given suffix string removed, if it\n          ends with it.\n\n        examples:\n          - program: '[.[]|rtrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"foob\"]'\n            output: ['[\"fo\",\"\",\"bar\",\"foobar\",\"foob\"]']\n\n      - title: \"`explode`\"\n        body: |\n\n          Converts an input string into an array of the string's\n          codepoint numbers.\n\n        examples:\n          - program: 'explode'\n            input: '\"foobar\"'\n            output: ['[102,111,111,98,97,114]']\n\n      - title: \"`implode`\"\n        body: |\n\n          The inverse of explode.\n\n        examples:\n          - program: 'implode'\n            input: '[65, 66, 67]'\n            output: ['\"ABC\"']\n\n      - title: \"`split(str)`\"\n        body: |\n\n          Splits an input string on the separator argument.\n\n          `split` can also split on regex matches when called with\n          two arguments (see the regular expressions section below).\n\n        examples:\n          - program: 'split(\", \")'\n            input: '\"a, b,c,d, e, \"'\n            output: ['[\"a\",\"b,c,d\",\"e\",\"\"]']\n\n      - title: \"`join(str)`\"\n        body: |\n\n          Joins the array of elements given as input, using the\n          argument as separator. It is the inverse of `split`: that is,\n          running `split(\"foo\") | join(\"foo\")` over any input string\n          returns said input string.\n\n          Numbers and booleans in the input are converted to strings.\n          Null values are treated as empty strings. Arrays and objects\n          in the input are not supported.\n\n        examples:\n          - program: 'join(\", \")'\n            input: '[\"a\",\"b,c,d\",\"e\"]'\n            output: ['\"a, b,c,d, e\"']\n          - program: 'join(\" \")'\n            input: '[\"a\",1,2.3,true,null,false]'\n            output: ['\"a 1 2.3 true  false\"']\n\n      - title: \"`ascii_downcase`, `ascii_upcase`\"\n        body: |\n\n          Emit a copy of the input string with its alphabetic characters (a-z and A-Z)\n          converted to the specified case.\n\n        examples:\n          - program: 'ascii_upcase'\n            input: '\"useful but not for é\"'\n            output: ['\"USEFUL BUT NOT FOR é\"']\n\n      - title: \"`while(cond; update)`\"\n        body: |\n\n          The `while(cond; update)` function allows you to repeatedly\n          apply an update to `.` until `cond` is false.\n\n          Note that `while(cond; update)` is internally defined as a\n          recursive jq function.  Recursive calls within `while` will\n          not consume additional memory if `update` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[while(.<100; .*2)]'\n            input: '1'\n            output: ['[1,2,4,8,16,32,64]']\n\n      - title: \"`repeat(exp)`\"\n        body: |\n\n          The `repeat(exp)` function allows you to repeatedly\n          apply expression `exp` to `.` until an error is raised.\n\n          Note that `repeat(exp)` is internally defined as a\n          recursive jq function.  Recursive calls within `repeat` will\n          not consume additional memory if `exp` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[repeat(.*2, error)?]'\n            input: '1'\n            output: ['[2]']\n\n      - title: \"`until(cond; next)`\"\n        body: |\n\n          The `until(cond; next)` function allows you to repeatedly\n          apply the expression `next`, initially to `.` then to its own\n          output, until `cond` is true.  For example, this can be used\n          to implement a factorial function (see below).\n\n          Note that `until(cond; next)` is internally defined as a\n          recursive jq function.  Recursive calls within `until()` will\n          not consume additional memory if `next` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]'\n            input: '4'\n            output: ['24']\n\n\n      - title: \"`recurse(f)`, `recurse`, `recurse(f; condition)`\"\n        body: |\n\n          The `recurse(f)` function allows you to search through a\n          recursive structure, and extract interesting data from all\n          levels. Suppose your input represents a filesystem:\n\n              {\"name\": \"/\", \"children\": [\n                {\"name\": \"/bin\", \"children\": [\n                  {\"name\": \"/bin/ls\", \"children\": []},\n                  {\"name\": \"/bin/sh\", \"children\": []}]},\n                {\"name\": \"/home\", \"children\": [\n                  {\"name\": \"/home/stephen\", \"children\": [\n                    {\"name\": \"/home/stephen/jq\", \"children\": []}]}]}]}\n\n          Now suppose you want to extract all of the filenames\n          present. You need to retrieve `.name`, `.children[].name`,\n          `.children[].children[].name`, and so on. You can do this\n          with:\n\n              recurse(.children[]) | .name\n\n          When called without an argument, `recurse` is equivalent to\n          `recurse(.[]?)`.\n\n          `recurse(f)` is identical to `recurse(f; true)` and can be\n          used without concerns about recursion depth.\n\n          `recurse(f; condition)` is a generator which begins by\n          emitting . and then emits in turn .|f, .|f|f, .|f|f|f, ...  so long\n          as the computed value satisfies the condition. For example,\n          to generate all the integers, at least in principle, one\n          could write `recurse(.+1; true)`.\n\n          The recursive calls in `recurse` will not consume additional\n          memory whenever `f` produces at most a single output for each\n          input.\n\n        examples:\n          - program: 'recurse(.foo[])'\n            input: '{\"foo\":[{\"foo\": []}, {\"foo\":[{\"foo\":[]}]}]}'\n            output:\n              - '{\"foo\":[{\"foo\":[]},{\"foo\":[{\"foo\":[]}]}]}'\n              - '{\"foo\":[]}'\n              - '{\"foo\":[{\"foo\":[]}]}'\n              - '{\"foo\":[]}'\n\n          - program: 'recurse'\n            input: '{\"a\":0,\"b\":[1]}'\n            output:\n              - '{\"a\":0,\"b\":[1]}'\n              - '0'\n              - '[1]'\n              - '1'\n\n          - program: 'recurse(. * .; . < 20)'\n            input: '2'\n            output: ['2', '4', '16']\n\n      - title: \"`walk(f)`\"\n        body: |\n\n          The `walk(f)` function applies f recursively to every\n          component of the input entity.  When an array is\n          encountered, f is first applied to its elements and then to\n          the array itself; when an object is encountered, f is first\n          applied to all the values and then to the object.  In\n          practice, f will usually test the type of its input, as\n          illustrated in the following examples.  The first example\n          highlights the usefulness of processing the elements of an\n          array of arrays before processing the array itself.  The second\n          example shows how all the keys of all the objects within the\n          input can be considered for alteration.\n\n        examples:\n          - program: 'walk(if type == \"array\" then sort else . end)'\n            input: '[[4, 1, 7], [8, 5, 2], [3, 6, 9]]'\n            output:\n              - '[[1,4,7],[2,5,8],[3,6,9]]'\n\n          - program: 'walk( if type == \"object\" then with_entries( .key |= sub( \"^_+\"; \"\") ) else . end )'\n            input: '[ { \"_a\": { \"__b\": 2 } } ]'\n            output:\n              - '[{\"a\":{\"b\":2}}]'\n\n      - title: \"`$JQ_BUILD_CONFIGURATION`\"\n        body: |\n\n          This builtin binding shows the jq executable's build\n          configuration.  Its value has no particular format, but\n          it can be expected to be at least the `./configure`\n          command-line arguments, and may be enriched in the\n          future to include the version strings for the build\n          tooling used.\n\n          Note that this can be overridden in the command-line\n          with `--arg` and related options.\n\n      - title: \"`$ENV`, `env`\"\n        body: |\n\n          `$ENV` is an object representing the environment variables as\n          set when the jq program started.\n\n          `env` outputs an object representing jq's current environment.\n\n          At the moment there is no builtin for setting environment\n          variables.\n\n        examples:\n          - program: '$ENV.PAGER'\n            input: 'null'\n            output: ['\"less\"']\n\n          - program: 'env.PAGER'\n            input: 'null'\n            output: ['\"less\"']\n\n      - title: \"`transpose`\"\n        body: |\n\n          Transpose a possibly jagged matrix (an array of arrays).\n          Rows are padded with nulls so the result is always rectangular.\n\n        examples:\n          - program: 'transpose'\n            input: '[[1], [2,3]]'\n            output: ['[[1,2],[null,3]]']\n\n      - title: \"`bsearch(x)`\"\n        body: |\n\n          `bsearch(x)` conducts a binary search for x in the input\n          array.  If the input is sorted and contains x, then\n          `bsearch(x)` will return its index in the array; otherwise, if\n          the array is sorted, it will return (-1 - ix) where ix is an\n          insertion point such that the array would still be sorted\n          after the insertion of x at ix.  If the array is not sorted,\n          `bsearch(x)` will return an integer that is probably of no\n          interest.\n\n        examples:\n          - program: 'bsearch(0)'\n            input: '[0,1]'\n            output: ['0']\n          - program: 'bsearch(0)'\n            input: '[1,2,3]'\n            output: ['-1']\n          - program: 'bsearch(4) as $ix | if $ix < 0 then .[-(1+$ix)] = 4 else . end'\n            input: '[1,2,3]'\n            output: ['[1,2,3,4]']\n\n      - title: \"String interpolation: `\\\\(exp)`\"\n        body: |\n\n          Inside a string, you can put an expression inside parens\n          after a backslash. Whatever the expression returns will be\n          interpolated into the string.\n\n        examples:\n          - program: '\"The input was \\(.), which is one less than \\(.+1)\"'\n            input: '42'\n            output: ['\"The input was 42, which is one less than 43\"']\n\n      - title: \"Convert to/from JSON\"\n        body: |\n\n          The `tojson` and `fromjson` builtins dump values as JSON texts\n          or parse JSON texts into values, respectively.  The `tojson`\n          builtin differs from `tostring` in that `tostring` returns strings\n          unmodified, while `tojson` encodes strings as JSON strings.\n\n        examples:\n          - program: '[.[]|tostring]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"foo\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"\\\"foo\\\"\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson|fromjson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[1,\"foo\",[\"foo\"]]']\n\n      - title: \"Format strings and escaping\"\n        body: |\n\n          The `@foo` syntax is used to format and escape strings,\n          which is useful for building URLs, documents in a language\n          like HTML or XML, and so forth. `@foo` can be used as a\n          filter on its own, the possible escapings are:\n\n          * `@text`:\n\n            Calls `tostring`, see that function for details.\n\n          * `@json`:\n\n            Serializes the input as JSON.\n\n          * `@html`:\n\n            Applies HTML/XML escaping, by mapping the characters\n            `<>&'\"` to their entity equivalents `&lt;`, `&gt;`,\n            `&amp;`, `&apos;`, `&quot;`.\n\n          * `@uri`:\n\n            Applies percent-encoding, by mapping all reserved URI\n            characters to a `%XX` sequence.\n\n          * `@csv`:\n\n            The input must be an array, and it is rendered as CSV\n            with double quotes for strings, and quotes escaped by\n            repetition.\n\n          * `@tsv`:\n\n            The input must be an array, and it is rendered as TSV\n            (tab-separated values). Each input array will be printed as\n            a single line. Fields are separated by a single\n            tab (ascii `0x09`). Input characters line-feed (ascii `0x0a`),\n            carriage-return (ascii `0x0d`), tab (ascii `0x09`) and\n            backslash (ascii `0x5c`) will be output as escape sequences\n            `\\n`, `\\r`, `\\t`, `\\\\` respectively.\n\n          * `@sh`:\n\n            The input is escaped suitable for use in a command-line\n            for a POSIX shell. If the input is an array, the output\n            will be a series of space-separated strings.\n\n          * `@base64`:\n\n            The input is converted to base64 as specified by RFC 4648.\n\n          * `@base64d`:\n\n            The inverse of `@base64`, input is decoded as specified by RFC 4648.\n            Note\\: If the decoded string is not UTF-8, the results are undefined.\n\n          This syntax can be combined with string interpolation in a\n          useful way. You can follow a `@foo` token with a string\n          literal. The contents of the string literal will *not* be\n          escaped. However, all interpolations made inside that string\n          literal will be escaped. For instance,\n\n              @uri \"https://www.google.com/search?q=\\(.search)\"\n\n          will produce the following output for the input\n          `{\"search\":\"what is jq?\"}`:\n\n              \"https://www.google.com/search?q=what%20is%20jq%3F\"\n\n          Note that the slashes, question mark, etc. in the URL are\n          not escaped, as they were part of the string literal.\n\n        examples:\n          - program: '@html'\n            input: '\"This works if x < y\"'\n            output: ['\"This works if x &lt; y\"']\n\n          - program: '@sh \"echo \\(.)\"'\n            input: \"\\\"O'Hara's Ale\\\"\"\n            output: [\"\\\"echo 'O'\\\\\\\\''Hara'\\\\\\\\''s Ale'\\\"\"]\n\n          - program: '@base64'\n            input: '\"This is a message\"'\n            output: ['\"VGhpcyBpcyBhIG1lc3NhZ2U=\"']\n\n          - program: '@base64d'\n            input: '\"VGhpcyBpcyBhIG1lc3NhZ2U=\"'\n            output: ['\"This is a message\"']\n\n      - title: \"Dates\"\n        body: |\n\n          jq provides some basic date handling functionality, with some\n          high-level and low-level builtins.  In all cases these\n          builtins deal exclusively with time in UTC.\n\n          The `fromdateiso8601` builtin parses datetimes in the ISO 8601\n          format to a number of seconds since the Unix epoch\n          (1970-01-01T00:00:00Z).  The `todateiso8601` builtin does the\n          inverse.\n\n          The `fromdate` builtin parses datetime strings.  Currently\n          `fromdate` only supports ISO 8601 datetime strings, but in the\n          future it will attempt to parse datetime strings in more\n          formats.\n\n          The `todate` builtin is an alias for `todateiso8601`.\n\n          The `now` builtin outputs the current time, in seconds since\n          the Unix epoch.\n\n          Low-level jq interfaces to the C-library time functions are\n          also provided: `strptime`, `strftime`, `strflocaltime`,\n          `mktime`, `gmtime`, and `localtime`.  Refer to your host\n          operating system's documentation for the format strings used\n          by `strptime` and `strftime`.  Note: these are not necessarily\n          stable interfaces in jq, particularly as to their localization\n          functionality.\n\n          The `gmtime` builtin consumes a number of seconds since the\n          Unix epoch and outputs a \"broken down time\" representation of\n          Greenwich Mean Time as an array of numbers representing\n          (in this order): the year, the month (zero-based), the day of\n          the month (one-based), the hour of the day, the minute of the\n          hour, the second of the minute, the day of the week, and the\n          day of the year -- all one-based unless otherwise stated.  The\n          day of the week number may be wrong on some systems for dates\n          before March 1st 1900, or after December 31 2099.\n\n          The `localtime` builtin works like the `gmtime` builtin, but\n          using the local timezone setting.\n\n          The `mktime` builtin consumes \"broken down time\"\n          representations of time output by `gmtime` and `strptime`.\n\n          The `strptime(fmt)` builtin parses input strings matching the\n          `fmt` argument.  The output is in the \"broken down time\"\n          representation consumed by `mktime` and output by `gmtime`.\n\n          The `strftime(fmt)` builtin formats a time (GMT) with the\n          given format.  The `strflocaltime` does the same, but using\n          the local timezone setting.\n\n          The format strings for `strptime` and `strftime` are described\n          in typical C library documentation.  The format string for ISO\n          8601 datetime is `\"%Y-%m-%dT%H:%M:%SZ\"`.\n\n          jq may not support some or all of this date functionality on\n          some systems. In particular, the `%u` and `%j` specifiers for\n          `strptime(fmt)` are not supported on macOS.\n\n        examples:\n          - program: 'fromdate'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['1425599507']\n\n          - program: 'strptime(\"%Y-%m-%dT%H:%M:%SZ\")'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['[2015,2,5,23,51,47,4,63]']\n\n          - program: 'strptime(\"%Y-%m-%dT%H:%M:%SZ\")|mktime'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['1425599507']\n\n      - title: \"SQL-Style Operators\"\n        body: |\n\n          jq provides a few SQL-style operators.\n\n          * `INDEX(stream; index_expression)`:\n\n            This builtin produces an object whose keys are computed by\n            the given index expression applied to each value from the\n            given stream.\n\n          * `JOIN($idx; stream; idx_expr; join_expr)`:\n\n            This builtin joins the values from the given stream to the\n            given index.  The index's keys are computed by applying the\n            given index expression to each value from the given stream.\n            An array of the value in the stream and the corresponding\n            value from the index is fed to the given join expression to\n            produce each result.\n\n          * `JOIN($idx; stream; idx_expr)`:\n\n            Same as `JOIN($idx; stream; idx_expr; .)`.\n\n          * `JOIN($idx; idx_expr)`:\n\n            This builtin joins the input `.` to the given index, applying\n            the given index expression to `.` to compute the index key.\n            The join operation is as described above.\n\n          * `IN(s)`:\n\n            This builtin outputs `true` if `.` appears in the given\n            stream, otherwise it outputs `false`.\n\n          * `IN(source; s)`:\n\n            This builtin outputs `true` if any value in the source stream\n            appears in the second stream, otherwise it outputs `false`.\n\n      - title: \"`builtins`\"\n        body: |\n\n          Returns a list of all builtin functions in the format `name/arity`.\n          Since functions with the same name but different arities are considered\n          separate functions, `all/0`, `all/1`, and `all/2` would all be present\n          in the list.\n\n  - title: Conditionals and Comparisons\n    entries:\n      - title: \"`==`, `!=`\"\n        body: |\n\n          The expression 'a == b' will produce 'true' if the results of evaluating\n          a and b are equal (that is, if they represent equivalent JSON values) and\n          'false' otherwise. In particular, strings are never considered equal\n          to numbers.  In checking for the equality of JSON objects, the ordering of keys\n          is irrelevant.  If you're coming from JavaScript, please note that jq's `==` is like\n          JavaScript's `===`, the \"strict equality\" operator.\n\n          != is \"not equal\", and 'a != b' returns the opposite value of 'a == b'\n\n        examples:\n          - program: '. == false'\n            input: 'null'\n            output: ['false']\n\n          - program: '. == {\"b\": {\"d\": (4 + 1e-20), \"c\": 3}, \"a\":1}'\n            input: '{\"a\":1, \"b\": {\"c\": 3, \"d\": 4}}'\n            output: ['true']\n\n          - program: '.[] == 1'\n            input: '[1, 1.0, \"1\", \"banana\"]'\n            output: ['true', 'true', 'false', 'false']\n\n      - title: if-then-else-end\n        body: |\n\n          `if A then B else C end` will act the same as `B` if `A`\n          produces a value other than false or null, but act the same\n          as `C` otherwise.\n\n          `if A then B end` is the same as `if A then B else .  end`.\n          That is, the `else` branch is optional, and if absent is the\n          same as `.`. This also applies to `elif` with absent ending `else` branch.\n\n          Checking for false or null is a simpler notion of\n          \"truthiness\" than is found in JavaScript or Python, but it\n          means that you'll sometimes have to be more explicit about\n          the condition you want.  You can't test whether, e.g. a\n          string is empty using `if .name then A else B end`; you'll\n          need something like `if .name == \"\" then A else B end` instead.\n\n          If the condition `A` produces multiple results, then `B` is evaluated\n          once for each result that is not false or null, and `C` is evaluated\n          once for each false or null.\n\n          More cases can be added to an if using `elif A then B` syntax.\n\n        examples:\n          - program: |-\n              if . == 0 then\n                \"zero\"\n              elif . == 1 then\n                \"one\"\n              else\n                \"many\"\n              end\n            input: '2'\n            output: ['\"many\"']\n\n      - title: \"`>`, `>=`, `<=`, `<`\"\n        body: |\n\n          The comparison operators `>`, `>=`, `<=`, `<` return whether\n          their left argument is greater than, greater than or equal\n          to, less than or equal to or less than their right argument\n          (respectively).\n\n          The ordering is the same as that described for `sort`, above.\n\n        examples:\n          - program: '. < 5'\n            input: '2'\n            output: ['true']\n\n      - title: \"`and`, `or`, `not`\"\n        body: |\n\n          jq supports the normal Boolean operators `and`, `or`, `not`.\n          They have the same standard of truth as if expressions -\n          `false` and `null` are considered \"false values\", and\n          anything else is a \"true value\".\n\n          If an operand of one of these operators produces multiple\n          results, the operator itself will produce a result for each input.\n\n          `not` is in fact a builtin function rather than an operator,\n          so it is called as a filter to which things can be piped\n          rather than with special syntax, as in `.foo and .bar |\n          not`.\n\n          These three only produce the values `true` and `false`, and\n          so are only useful for genuine Boolean operations, rather\n          than the common Perl/Python/Ruby idiom of\n          \"value_that_may_be_null or default\". If you want to use this\n          form of \"or\", picking between two values rather than\n          evaluating a condition, see the `//` operator below.\n\n        examples:\n          - program: '42 and \"a string\"'\n            input: 'null'\n            output: ['true']\n          - program: '(true, false) or false'\n            input: 'null'\n            output: ['true', 'false']\n          - program: '(true, true) and (true, false)'\n            input: 'null'\n            output: ['true', 'false', 'true', 'false']\n          - program: '[true, false | not]'\n            input: 'null'\n            output: ['[false, true]']\n\n      - title: \"Alternative operator: `//`\"\n        body: |\n\n          The `//` operator produces all the values of its left-hand\n          side that are neither `false` nor `null`, or, if the\n          left-hand side produces no values other than `false` or\n          `null`, then `//` produces all the values of its right-hand\n          side.\n\n          A filter of the form `a // b` produces all the results of\n          `a` that are not `false` or `null`.  If `a` produces no\n          results, or no results other than `false` or `null`, then `a\n          // b` produces the results of `b`.\n\n          This is useful for providing defaults: `.foo // 1` will\n          evaluate to `1` if there's no `.foo` element in the\n          input. It's similar to how `or` is sometimes used in Python\n          (jq's `or` operator is reserved for strictly Boolean\n          operations).\n\n          Note: `some_generator // defaults_here` is not the same\n          as `some_generator | . // defaults_here`.  The latter will\n          produce default values for all non-`false`, non-`null`\n          values of the left-hand side, while the former will not.\n          Precedence rules can make this confusing.  For example, in\n          `false, 1 // 2` the left-hand side of `//` is `1`, not\n          `false, 1` -- `false, 1 // 2` parses the same way as `false,\n          (1 // 2)`.  In `(false, null, 1) | . // 42` the left-hand\n          side of `//` is `.`, which always produces just one value,\n          while in `(false, null, 1) // 42` the left-hand side is a\n          generator of three values, and since it produces a\n          value other `false` and `null`, the default `42` is not\n          produced.\n\n        examples:\n          - program: 'empty // 42'\n            input: 'null'\n            output: ['42']\n          - program: '.foo // 42'\n            input: '{\"foo\": 19}'\n            output: ['19']\n          - program: '.foo // 42'\n            input: '{}'\n            output: ['42']\n          - program: '(false, null, 1) // 42'\n            input: 'null'\n            output: ['1']\n          - program: '(false, null, 1) | . // 42'\n            input: 'null'\n            output: ['42', '42', '1']\n\n      - title: try-catch\n        body: |\n\n          Errors can be caught by using `try EXP catch EXP`.  The first\n          expression is executed, and if it fails then the second is\n          executed with the error message.  The output of the handler,\n          if any, is output as if it had been the output of the\n          expression to try.\n\n          The `try EXP` form uses `empty` as the exception handler.\n\n        examples:\n          - program: 'try .a catch \". is not an object\"'\n            input: 'true'\n            output: ['\". is not an object\"']\n          - program: '[.[]|try .a]'\n            input: '[{}, true, {\"a\":1}]'\n            output: ['[null, 1]']\n          - program: 'try error(\"some exception\") catch .'\n            input: 'true'\n            output: ['\"some exception\"']\n\n      - title: Breaking out of control structures\n        body: |\n\n          A convenient use of try/catch is to break out of control\n          structures like `reduce`, `foreach`, `while`, and so on.\n\n          For example:\n\n              # Repeat an expression until it raises \"break\" as an\n              # error, then stop repeating without re-raising the error.\n              # But if the error caught is not \"break\" then re-raise it.\n              try repeat(exp) catch if .==\"break\" then empty else error\n\n          jq has a syntax for named lexical labels to \"break\" or \"go (back) to\":\n\n              label $out | ... break $out ...\n\n          The `break $label_name` expression will cause the program to\n          act as though the nearest (to the left) `label $label_name`\n          produced `empty`.\n\n          The relationship between the `break` and corresponding `label`\n          is lexical: the label has to be \"visible\" from the break.\n\n          To break out of a `reduce`, for example:\n\n              label $out | reduce .[] as $item (null; if .==false then break $out else ... end)\n\n          The following jq program produces a syntax error:\n\n              break $out\n\n          because no label `$out` is visible.\n\n      - title: \"Error Suppression / Optional Operator: `?`\"\n        body: |\n\n          The `?` operator, used as `EXP?`, is shorthand for `try EXP`.\n\n        examples:\n          - program: '[.[] | .a?]'\n            input: '[{}, true, {\"a\":1}]'\n            output: ['[null, 1]']\n          - program: '[.[] | tonumber?]'\n            input: '[\"1\", \"invalid\", \"3\", 4]'\n            output: ['[1, 3, 4]']\n\n  - title: Regular expressions\n    body: |\n\n      jq uses the\n      [Oniguruma regular expression library](https://github.com/kkos/oniguruma/blob/master/doc/RE),\n      as do PHP, TextMate, Sublime Text, etc, so the\n      description here will focus on jq specifics.\n\n      Oniguruma supports several flavors of regular expression, so it is important to know\n      that jq uses the [\"Perl NG\" (Perl with named groups)](https://github.com/kkos/oniguruma/blob/master/doc/SYNTAX.md) flavor.\n\n      The jq regex filters are defined so that they can be used using\n      one of these patterns:\n\n          STRING | FILTER(REGEX)\n          STRING | FILTER(REGEX; FLAGS)\n          STRING | FILTER([REGEX])\n          STRING | FILTER([REGEX, FLAGS])\n\n      where:\n\n      * STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;\n      * REGEX, after string interpolation, should be a valid regular expression;\n      * FILTER is one of `test`, `match`, or `capture`, as described below.\n\n      Since REGEX must evaluate to a JSON string, some characters that are needed\n      to form a regular expression must be escaped. For example, the regular expression\n      `\\s` signifying a whitespace character would be written as `\"\\\\s\"`.\n\n      FLAGS is a string consisting of one of more of the supported flags:\n\n      * `g` - Global search (find all matches, not just the first)\n      * `i` - Case insensitive search\n      * `m` - Multi line mode (`.` will match newlines)\n      * `n` - Ignore empty matches\n      * `p` - Both s and m modes are enabled\n      * `s` - Single line mode (`^` -> `\\A`, `$` -> `\\Z`)\n      * `l` - Find longest possible matches\n      * `x` - Extended regex format (ignore whitespace and comments)\n\n      To match a whitespace with the `x` flag, use `\\s`, e.g.\n\n          jq -n '\"a b\" | test(\"a\\\\sb\"; \"x\")'\n\n      Note that certain flags may also be specified within REGEX, e.g.\n\n          jq -n '(\"test\", \"TEst\", \"teST\", \"TEST\") | test(\"(?i)te(?-i)st\")'\n\n      evaluates to: `true`, `true`, `false`, `false`.\n\n    entries:\n      - title: \"`test(val)`, `test(regex; flags)`\"\n        body: |\n\n          Like `match`, but does not return match objects, only `true` or `false`\n          for whether or not the regex matches the input.\n\n        examples:\n          - program: 'test(\"foo\")'\n            input: '\"foo\"'\n            output: ['true']\n          - program: '.[] | test(\"a b c # spaces are ignored\"; \"ix\")'\n            input: '[\"xabcd\", \"ABC\"]'\n            output: ['true', 'true']\n\n      - title: \"`match(val)`, `match(regex; flags)`\"\n        body: |\n\n          **match** outputs an object for each match it finds.  Matches have\n          the following fields:\n\n          * `offset` - offset in UTF-8 codepoints from the beginning of the input\n          * `length` - length in UTF-8 codepoints of the match\n          * `string` - the string that it matched\n          * `captures` - an array of objects representing capturing groups.\n\n          Capturing group objects have the following fields:\n\n          * `offset` - offset in UTF-8 codepoints from the beginning of the input\n          * `length` - length in UTF-8 codepoints of this capturing group\n          * `string` - the string that was captured\n          * `name` - the name of the capturing group (or `null` if it was unnamed)\n\n          Capturing groups that did not match anything return an offset of -1\n\n        examples:\n          - program: 'match(\"(abc)+\"; \"g\")'\n            input: '\"abc abc\"'\n            output:\n             - '{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"name\": null}]}'\n             - '{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"name\": null}]}'\n          - program: 'match(\"foo\")'\n            input: '\"foo bar foo\"'\n            output: ['{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}']\n          - program: 'match([\"foo\", \"ig\"])'\n            input: '\"foo bar FOO\"'\n            output:\n             - '{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}'\n             - '{\"offset\": 8, \"length\": 3, \"string\": \"FOO\", \"captures\": []}'\n          - program: 'match(\"foo (?<bar123>bar)? foo\"; \"ig\")'\n            input: '\"foo bar foo foo  foo\"'\n            output:\n             - '{\"offset\": 0, \"length\": 11, \"string\": \"foo bar foo\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"bar\", \"name\": \"bar123\"}]}'\n             - '{\"offset\": 12, \"length\": 8, \"string\": \"foo  foo\", \"captures\": [{\"offset\": -1, \"length\": 0, \"string\": null, \"name\": \"bar123\"}]}'\n\n          - program: '[ match(\".\"; \"g\")] | length'\n            input: '\"abc\"'\n            output: ['3']\n\n\n      - title: \"`capture(val)`, `capture(regex; flags)`\"\n        body: |\n\n         Collects the named captures in a JSON object, with the name\n         of each capture as the key, and the matched string as the\n         corresponding value.\n\n        examples:\n          - program: 'capture(\"(?<a>[a-z]+)-(?<n>[0-9]+)\")'\n            input: '\"xyzzy-14\"'\n            output: ['{ \"a\": \"xyzzy\", \"n\": \"14\" }']\n\n      - title: \"`scan(regex)`, `scan(regex; flags)`\"\n        body: |\n\n          Emit a stream of the non-overlapping substrings of the input\n          that match the regex in accordance with the flags, if any\n          have been specified.  If there is no match, the stream is empty.\n          To capture all the matches for each input string, use the idiom\n          `[ expr ]`, e.g. `[ scan(regex) ]`.  If the regex contains capturing\n          groups, the filter emits a stream of arrays, each of which contains\n          the captured strings.\n\n        examples:\n          - program: 'scan(\"c\")'\n            input: '\"abcdefabc\"'\n            output: ['\"c\"', '\"c\"']\n          - program: 'scan(\"(a+)(b+)\")'\n            input: '\"abaabbaaabbb\"'\n            output: ['[\"a\",\"b\"]', '[\"aa\",\"bb\"]', '[\"aaa\",\"bbb\"]']\n\n      - title: \"`split(regex; flags)`\"\n        body: |\n\n          Splits an input string on each regex match.\n\n          For backwards compatibility, when called with a single argument,\n          `split` splits on a string, not a regex.\n\n        examples:\n          - program: 'split(\", *\"; null)'\n            input: '\"ab,cd, ef\"'\n            output: ['[\"ab\",\"cd\",\"ef\"]']\n\n\n      - title: \"`splits(regex)`, `splits(regex; flags)`\"\n        body: |\n\n          These provide the same results as their `split` counterparts,\n          but as a stream instead of an array.\n\n        examples:\n          - program: 'splits(\", *\")'\n            input: '\"ab,cd,   ef, gh\"'\n            output: ['\"ab\"','\"cd\"','\"ef\"','\"gh\"']\n\n      - title: \"`sub(regex; tostring)`, `sub(regex; tostring; flags)`\"\n        body: |\n\n          Emit the string obtained by replacing the first match of\n          regex in the input string with `tostring`, after\n          interpolation.  `tostring` should be a jq string or a stream\n          of such strings, each of which may contain references to\n          named captures. The named captures are, in effect, presented\n          as a JSON object (as constructed by `capture`) to\n          `tostring`, so a reference to a captured variable named \"x\"\n          would take the form: `\"\\(.x)\"`.\n\n        examples:\n          - program: 'sub(\"[^a-z]*(?<x>[a-z]+)\"; \"Z\\(.x)\"; \"g\")'\n            input: '\"123abc456def\"'\n            output: ['\"ZabcZdef\"']\n\n          - program: '[sub(\"(?<a>.)\"; \"\\(.a|ascii_upcase)\", \"\\(.a|ascii_downcase)\")]'\n            input: '\"aB\"'\n            output: ['[\"AB\",\"aB\"]']\n\n      - title: \"`gsub(regex; tostring)`, `gsub(regex; tostring; flags)`\"\n        body: |\n\n          `gsub` is like `sub` but all the non-overlapping occurrences of the regex are\n          replaced by `tostring`, after interpolation. If the second argument is a stream\n          of jq strings, then `gsub` will produce a corresponding stream of JSON strings.\n\n        examples:\n          - program: 'gsub(\"(?<x>.)[^a]*\"; \"+\\(.x)-\")'\n            input: '\"Abcabc\"'\n            output: ['\"+A-+a-\"']\n\n          - program: '[gsub(\"p\"; \"a\", \"b\")]'\n            input: '\"p\"'\n            output: ['[\"a\",\"b\"]']\n\n\n  - title: Advanced features\n    body: |\n      Variables are an absolute necessity in most programming languages, but\n      they're relegated to an \"advanced feature\" in jq.\n\n      In most languages, variables are the only means of passing around\n      data. If you calculate a value, and you want to use it more than once,\n      you'll need to store it in a variable. To pass a value to another part\n      of the program, you'll need that part of the program to define a\n      variable (as a function parameter, object member, or whatever) in\n      which to place the data.\n\n      It is also possible to define functions in jq, although this is\n      is a feature whose biggest use is defining jq's standard library\n      (many jq functions such as `map` and `select` are in fact written\n      in jq).\n\n      jq has reduction operators, which are very powerful but a bit\n      tricky.  Again, these are mostly used internally, to define some\n      useful bits of jq's standard library.\n\n      It may not be obvious at first, but jq is all about generators\n      (yes, as often found in other languages).  Some utilities are\n      provided to help deal with generators.\n\n      Some minimal I/O support (besides reading JSON from standard\n      input, and writing JSON to standard output) is available.\n\n      Finally, there is a module/library system.\n\n    entries:\n      - title: \"Variable / Symbolic Binding Operator: `... as $identifier | ...`\"\n        body: |\n\n          In jq, all filters have an input and an output, so manual\n          plumbing is not necessary to pass a value from one part of a program\n          to the next. Many expressions, for instance `a + b`, pass their input\n          to two distinct subexpressions (here `a` and `b` are both passed the\n          same input), so variables aren't usually necessary in order to use a\n          value twice.\n\n          For instance, calculating the average value of an array of numbers\n          requires a few variables in most languages - at least one to hold the\n          array, perhaps one for each element or for a loop counter. In jq, it's\n          simply `add / length` - the `add` expression is given the array and\n          produces its sum, and the `length` expression is given the array and\n          produces its length.\n\n          So, there's generally a cleaner way to solve most problems in jq than\n          defining variables. Still, sometimes they do make things easier, so jq\n          lets you define variables using `expression as $variable`. All\n          variable names start with `$`. Here's a slightly uglier version of the\n          array-averaging example:\n\n              length as $array_length | add / $array_length\n\n          We'll need a more complicated problem to find a situation where using\n          variables actually makes our lives easier.\n\n\n          Suppose we have an array of blog posts, with \"author\" and \"title\"\n          fields, and another object which is used to map author usernames to\n          real names. Our input looks like:\n\n              {\"posts\": [{\"title\": \"First post\", \"author\": \"anon\"},\n                         {\"title\": \"A well-written article\", \"author\": \"person1\"}],\n               \"realnames\": {\"anon\": \"Anonymous Coward\",\n                             \"person1\": \"Person McPherson\"}}\n\n          We want to produce the posts with the author field containing a real\n          name, as in:\n\n              {\"title\": \"First post\", \"author\": \"Anonymous Coward\"}\n              {\"title\": \"A well-written article\", \"author\": \"Person McPherson\"}\n\n          We use a variable, `$names`, to store the realnames object, so that we\n          can refer to it later when looking up author usernames:\n\n              .realnames as $names | .posts[] | {title, author: $names[.author]}\n\n          The expression `exp as $x | ...` means: for each value of expression\n          `exp`, run the rest of the pipeline with the entire original input, and\n          with `$x` set to that value.  Thus `as` functions as something of a\n          foreach loop.\n\n          Just as `{foo}` is a handy way of writing `{foo: .foo}`, so\n          `{$foo}` is a handy way of writing `{foo: $foo}`.\n\n          Multiple variables may be declared using a single `as` expression by\n          providing a pattern that matches the structure of the input\n          (this is known as \"destructuring\"):\n\n              . as {realnames: $names, posts: [$first, $second]} | ...\n\n          The variable declarations in array patterns (e.g., `. as\n          [$first, $second]`) bind to the elements of the array in from\n          the element at index zero on up, in order.  When there is no\n          value at the index for an array pattern element, `null` is\n          bound to that variable.\n\n          Variables are scoped over the rest of the expression that defines\n          them, so\n\n              .realnames as $names | (.posts[] | {title, author: $names[.author]})\n\n          will work, but\n\n              (.realnames as $names | .posts[]) | {title, author: $names[.author]}\n\n          won't.\n\n          For programming language theorists, it's more accurate to\n          say that jq variables are lexically-scoped bindings.  In\n          particular there's no way to change the value of a binding;\n          one can only setup a new binding with the same name, but which\n          will not be visible where the old one was.\n\n        examples:\n          - program: '.bar as $x | .foo | . + $x'\n            input: '{\"foo\":10, \"bar\":200}'\n            output: ['210']\n          - program: '. as $i|[(.*2|. as $i| $i), $i]'\n            input: '5'\n            output: ['[10,5]']\n          - program: '. as [$a, $b, {c: $c}] | $a + $b + $c'\n            input: '[2, 3, {\"c\": 4, \"d\": 5}]'\n            output: ['9']\n          - program: '.[] as [$a, $b] | {a: $a, b: $b}'\n            input: '[[0], [0, 1], [2, 1, 0]]'\n            output: ['{\"a\":0,\"b\":null}', '{\"a\":0,\"b\":1}', '{\"a\":2,\"b\":1}']\n\n      - title: 'Destructuring Alternative Operator: `?//`'\n        body: |\n\n          The destructuring alternative operator provides a concise mechanism\n          for destructuring an input that can take one of several forms.\n\n          Suppose we have an API that returns a list of resources and events\n          associated with them, and we want to get the user_id and timestamp of\n          the first event for each resource. The API (having been clumsily\n          converted from XML) will only wrap the events in an array if the resource\n          has multiple events:\n\n              {\"resources\": [{\"id\": 1, \"kind\": \"widget\", \"events\": {\"action\": \"create\", \"user_id\": 1, \"ts\": 13}},\n                             {\"id\": 2, \"kind\": \"widget\", \"events\": [{\"action\": \"create\", \"user_id\": 1, \"ts\": 14}, {\"action\": \"destroy\", \"user_id\": 1, \"ts\": 15}]}]}\n\n          We can use the destructuring alternative operator to handle this structural change simply:\n\n              .resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}\n\n          Or, if we aren't sure if the input is an array of values or an object:\n\n              .[] as [$id, $kind, $user_id, $ts] ?// {$id, $kind, $user_id, $ts} | ...\n\n          Each alternative need not define all of the same variables, but all named\n          variables will be available to the subsequent expression. Variables not\n          matched in the alternative that succeeded will be `null`:\n\n              .resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$first_user_id, $first_ts}]} | {$user_id, $first_user_id, $kind, $id, $ts, $first_ts}\n\n          Additionally, if the subsequent expression returns an error, the\n          alternative operator will attempt to try the next binding. Errors\n          that occur during the final alternative are passed through.\n\n              [[3]] | .[] as [$a] ?// [$b] | if $a != null then error(\"err: \\($a)\") else {$a,$b} end\n\n        examples:\n          - program: '.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}'\n            input: '[{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]'\n            output: ['{\"a\":1,\"b\":2,\"d\":3,\"e\":4}', '{\"a\":1,\"b\":2,\"d\":3,\"e\":4}']\n          - program: '.[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}'\n            input: '[{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]'\n            output: ['{\"a\":1,\"b\":2,\"d\":3,\"e\":null}', '{\"a\":1,\"b\":2,\"d\":null,\"e\":4}']\n          - program: '.[] as [$a] ?// [$b] | if $a != null then error(\"err: \\($a)\") else {$a,$b} end'\n            input: '[[3]]'\n            output: ['{\"a\":null,\"b\":3}']\n\n      - title: 'Defining Functions'\n        body: |\n\n          You can give a filter a name using \"def\" syntax:\n\n              def increment: . + 1;\n\n          From then on, `increment` is usable as a filter just like a\n          builtin function (in fact, this is how many of the builtins\n          are defined). A function may take arguments:\n\n              def map(f): [.[] | f];\n\n          Arguments are passed as _filters_ (functions with no\n          arguments), _not_ as values. The same argument may be\n          referenced multiple times with different inputs (here `f` is\n          run for each element of the input array).  Arguments to a\n          function work more like callbacks than like value arguments.\n          This is important to understand.  Consider:\n\n              def foo(f): f|f;\n              5|foo(.*2)\n\n          The result will be 20 because `f` is `.*2`, and during the\n          first invocation of `f` `.` will be 5, and the second time it\n          will be 10 (5 * 2), so the result will be 20.  Function\n          arguments are filters, and filters expect an input when\n          invoked.\n\n          If you want the value-argument behaviour for defining simple\n          functions, you can just use a variable:\n\n              def addvalue(f): f as $f | map(. + $f);\n\n          Or use the short-hand:\n\n              def addvalue($f): ...;\n\n          With either definition, `addvalue(.foo)` will add the current\n          input's `.foo` field to each element of the array.  Do note\n          that calling `addvalue(.[])` will cause the `map(. + $f)` part\n          to be evaluated once per value in the value of `.` at the call\n          site.\n\n          Multiple definitions using the same function name are allowed.\n          Each re-definition replaces the previous one for the same\n          number of function arguments, but only for references from\n          functions (or main program) subsequent to the re-definition.\n          See also the section below on scoping.\n\n        examples:\n          - program: 'def addvalue(f): . + [f]; map(addvalue(.[0]))'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1], [10,20,10]]']\n          - program: 'def addvalue(f): f as $x | map(. + $x); addvalue(.[0])'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1,2], [10,20,1,2]]']\n\n      - title: 'Scoping'\n        body: |\n\n          There are two types of symbols in jq: value bindings (a.k.a.,\n          \"variables\"), and functions.  Both are scoped lexically,\n          with expressions being able to refer only to symbols that\n          have been defined \"to the left\" of them.  The only exception\n          to this rule is that functions can refer to themselves so as\n          to be able to create recursive functions.\n\n          For example, in the following expression there is a binding\n          which is visible \"to the right\" of it, `... | .*3 as\n          $times_three | [. + $times_three] | ...`, but not \"to the\n          left\".  Consider this expression now, `... | (.*3 as\n          $times_three | [. + $times_three]) | ...`: here the binding\n          `$times_three` is _not_ visible past the closing parenthesis.\n\n      - title: \"`isempty(exp)`\"\n        body: |\n\n          Returns true if `exp` produces no outputs, false otherwise.\n\n        examples:\n          - program: 'isempty(empty)'\n            input: 'null'\n            output: ['true']\n\n          - program: 'isempty(.[])'\n            input: '[]'\n            output: ['true']\n\n          - program: 'isempty(.[])'\n            input: '[1,2,3]'\n            output: ['false']\n\n      - title: \"`limit(n; exp)`\"\n        body: |\n\n          The `limit` function extracts up to `n` outputs from `exp`.\n\n        examples:\n          - program: '[limit(3;.[])]'\n            input: '[0,1,2,3,4,5,6,7,8,9]'\n            output: ['[0,1,2]']\n\n      - title: \"`first(expr)`, `last(expr)`, `nth(n; expr)`\"\n        body: |\n\n          The `first(expr)` and `last(expr)` functions extract the first\n          and last values from `expr`, respectively.\n\n          The `nth(n; expr)` function extracts the nth value output by `expr`.\n          Note that `nth(n; expr)` doesn't support negative values of `n`.\n\n        examples:\n          - program: '[first(range(.)), last(range(.)), nth(./2; range(.))]'\n            input: '10'\n            output: ['[0,9,5]']\n\n      - title: \"`first`, `last`, `nth(n)`\"\n        body: |\n\n          The `first` and `last` functions extract the first\n          and last values from any array at `.`.\n\n          The `nth(n)` function extracts the nth value of any array at `.`.\n\n        examples:\n          - program: '[range(.)]|[first, last, nth(5)]'\n            input: '10'\n            output: ['[0,9,5]']\n\n      - title: \"`reduce`\"\n        body: |\n\n          The `reduce` syntax allows you to combine all of the results of\n          an expression by accumulating them into a single answer.\n          The form is `reduce EXP as $var (INIT; UPDATE)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              reduce .[] as $item (0; . + $item)\n\n          For each result that `.[]` produces, `. + $item` is run to\n          accumulate a running total, starting from 0 as the input value.\n          In this example, `.[]` produces the results `1`, `2`, and `3`,\n          so the effect is similar to running something like this:\n\n              0 | 1 as $item | . + $item |\n                  2 as $item | . + $item |\n                  3 as $item | . + $item\n\n        examples:\n          - program: 'reduce .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['15']\n\n          - program: 'reduce .[] as [$i,$j] (0; . + $i * $j)'\n            input: '[[1,2],[3,4],[5,6]]'\n            output: ['44']\n\n          - program: 'reduce .[] as {$x,$y} (null; .x += $x | .y += [$y])'\n            input: '[{\"x\":\"a\",\"y\":1},{\"x\":\"b\",\"y\":2},{\"x\":\"c\",\"y\":3}]'\n            output: ['{\"x\":\"abc\",\"y\":[1,2,3]}']\n\n      - title: \"`foreach`\"\n        body: |\n\n          The `foreach` syntax is similar to `reduce`, but intended to\n          allow the construction of `limit` and reducers that produce\n          intermediate results.\n\n          The form is `foreach EXP as $var (INIT; UPDATE; EXTRACT)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              foreach .[] as $item (0; . + $item; [$item, . * 2])\n\n          Like the `reduce` syntax, `. + $item` is run for each result\n          that `.[]` produces, but `[$item, . * 2]` is run for each\n          intermediate values. In this example, since the intermediate\n          values are `1`, `3`, and `6`, the `foreach` expression produces\n          `[1,2]`, `[2,6]`, and `[3,12]`. So the effect is similar\n          to running something like this:\n\n              0 | 1 as $item | . + $item | [$item, . * 2],\n                  2 as $item | . + $item | [$item, . * 2],\n                  3 as $item | . + $item | [$item, . * 2]\n\n          When `EXTRACT` is omitted, the identity filter is used.\n          That is, it outputs the intermediate values as they are.\n\n        examples:\n          - program: 'foreach .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['1','3','6','10','15']\n\n          - program: 'foreach .[] as $item (0; . + $item; [$item, . * 2])'\n            input: '[1,2,3,4,5]'\n            output: ['[1,2]','[2,6]','[3,12]','[4,20]','[5,30]']\n\n          - program: 'foreach .[] as $item (0; . + 1; {index: ., $item})'\n            input: '[\"foo\", \"bar\", \"baz\"]'\n            output:\n              - '{\"index\":1,\"item\":\"foo\"}'\n              - '{\"index\":2,\"item\":\"bar\"}'\n              - '{\"index\":3,\"item\":\"baz\"}'\n\n      - title: Recursion\n        body: |\n\n          As described above, `recurse` uses recursion, and any jq\n          function can be recursive.  The `while` builtin is also\n          implemented in terms of recursion.\n\n          Tail calls are optimized whenever the expression to the left of\n          the recursive call outputs its last value.  In practice this\n          means that the expression to the left of the recursive call\n          should not produce more than one output for each input.\n\n          For example:\n\n              def recurse(f): def r: ., (f | select(. != null) | r); r;\n\n              def while(cond; update):\n                def _while:\n                  if cond then ., (update | _while) else empty end;\n                _while;\n\n              def repeat(exp):\n                def _repeat:\n                  exp, _repeat;\n                _repeat;\n\n      - title: Generators and iterators\n        body: |\n\n            Some jq operators and functions are actually generators in\n            that they can produce zero, one, or more values for each\n            input, just as one might expect in other programming\n            languages that have generators.  For example, `.[]`\n            generates all the values in its input (which must be an\n            array or an object), `range(0; 10)` generates the integers\n            between 0 and 10, and so on.\n\n            Even the comma operator is a generator, generating first\n            the values generated by the expression to the left of the\n            comma, then the values generated by the expression on the\n            right of the comma.\n\n            The `empty` builtin is the generator that produces zero\n            outputs.  The `empty` builtin backtracks to the preceding\n            generator expression.\n\n            All jq functions can be generators just by using builtin\n            generators.  It is also possible to construct new generators\n            using only recursion and the comma operator.  If\n            recursive calls are \"in tail position\" then the\n            generator will be efficient.  In the example below the\n            recursive call by `_range` to itself is in tail position.\n            The example shows off three advanced topics: tail recursion,\n            generator construction, and sub-functions.\n\n        examples:\n          - program: 'def range(init; upto; by):\n                    def _range:\n                        if (by > 0 and . < upto) or (by < 0 and . > upto)\n                        then ., ((.+by)|_range)\n                        else empty end;\n                    if init == upto then empty elif by == 0 then init else init|_range end;\n                range(0; 10; 3)'\n            input: 'null'\n            output: ['0', '3', '6', '9']\n          - program: 'def while(cond; update):\n                    def _while:\n                        if cond then ., (update | _while) else empty end;\n                    _while;\n                [while(.<100; .*2)]'\n            input: '1'\n            output: ['[1,2,4,8,16,32,64]']\n\n  - title: 'Math'\n    body: |\n\n      jq currently only has IEEE754 double-precision (64-bit) floating\n      point number support.\n\n      Besides simple arithmetic operators such as `+`, jq also has most\n      standard math functions from the C math library.  C math functions\n      that take a single input argument (e.g., `sin()`) are available as\n      zero-argument jq functions.  C math functions that take two input\n      arguments (e.g., `pow()`) are available as two-argument jq\n      functions that ignore `.`.  C math functions that take three input\n      arguments are available as three-argument jq functions that ignore\n      `.`.\n\n      Availability of standard math functions depends on the\n      availability of the corresponding math functions in your operating\n      system and C math library.  Unavailable math functions will be\n      defined but will raise an error.\n\n      One-input C math functions: `acos` `acosh` `asin` `asinh` `atan`\n      `atanh` `cbrt` `ceil` `cos` `cosh` `erf` `erfc` `exp` `exp10`\n      `exp2` `expm1` `fabs` `floor` `gamma` `j0` `j1` `lgamma` `log`\n      `log10` `log1p` `log2` `logb` `nearbyint` `pow10` `rint` `round`\n      `significand` `sin` `sinh` `sqrt` `tan` `tanh` `tgamma` `trunc`\n      `y0` `y1`.\n\n      Two-input C math functions: `atan2` `copysign` `drem` `fdim`\n      `fmax` `fmin` `fmod` `frexp` `hypot` `jn` `ldexp` `modf`\n      `nextafter` `nexttoward` `pow` `remainder` `scalb` `scalbln` `yn`.\n\n      Three-input C math functions: `fma`.\n\n      See your system's manual for more information on each of these.\n\n  - title: 'I/O'\n    body: |\n\n      At this time jq has minimal support for I/O, mostly in the\n      form of control over when inputs are read.  Two builtins functions\n      are provided for this, `input` and `inputs`, that read from the\n      same sources (e.g., `stdin`, files named on the command-line) as\n      jq itself.  These two builtins, and jq's own reading actions, can\n      be interleaved with each other.  They are commonly used in combination\n      with the null input option `-n` to prevent one input from being read\n      implicitly.\n\n      Two builtins provide minimal output capabilities, `debug`, and\n      `stderr`.  (Recall that a jq program's output values are always\n      output as JSON texts on `stdout`.) The `debug` builtin can have\n      application-specific behavior, such as for executables that use\n      the libjq C API but aren't the jq executable itself.  The `stderr`\n      builtin outputs its input in raw mode to stderr with no additional\n      decoration, not even a newline.\n\n      Most jq builtins are referentially transparent, and yield constant\n      and repeatable value streams when applied to constant inputs.\n      This is not true of I/O builtins.\n\n    entries:\n      - title: \"`input`\"\n        body: |\n\n          Outputs one new input.\n\n          Note that when using `input` it is generally necessary to\n          invoke jq with the `-n` command-line option, otherwise\n          the first entity will be lost.\n\n              echo 1 2 3 4 | jq '[., input]' # [1,2] [3,4]\n\n      - title: \"`inputs`\"\n        body: |\n\n          Outputs all remaining inputs, one by one.\n\n          This is primarily useful for reductions over a program's\n          inputs.  Note that when using `inputs` it is generally necessary\n          to invoke jq with the `-n` command-line option, otherwise\n          the first entity will be lost.\n\n              echo 1 2 3 | jq -n 'reduce inputs as $i (0; . + $i)' # 6\n\n      - title: \"`debug`, `debug(msgs)`\"\n        body: |\n\n          These two filters are like `.` but have as a side-effect the\n          production of one or more messages on stderr.\n\n          The message produced by the `debug` filter has the form\n\n              [\"DEBUG:\",<input-value>]\n\n          where `<input-value>` is a compact rendition of the input\n          value.  This format may change in the future.\n\n          The `debug(msgs)` filter is defined as `(msgs | debug | empty), .`\n          thus allowing great flexibility in the content of the message,\n          while also allowing multi-line debugging statements to be created.\n\n          For example, the expression:\n\n              1 as $x | 2 | debug(\"Entering function foo with $x == \\($x)\", .) | (.+1)\n\n          would produce the value 3 but with the following two lines\n          being written to stderr:\n\n              [\"DEBUG:\",\"Entering function foo with $x == 1\"]\n              [\"DEBUG:\",2]\n\n      - title: \"`stderr`\"\n        body: |\n\n          Prints its input in raw and compact mode to stderr with no\n          additional decoration, not even a newline.\n\n      - title: \"`input_filename`\"\n        body: |\n\n          Returns the name of the file whose input is currently being\n          filtered.  Note that this will not work well unless jq is\n          running in a UTF-8 locale.\n\n      - title: \"`input_line_number`\"\n        body: |\n\n          Returns the line number of the input currently being filtered.\n\n  - title: 'Streaming'\n    body: |\n\n      With the `--stream` option jq can parse input texts in a streaming\n      fashion, allowing jq programs to start processing large JSON texts\n      immediately rather than after the parse completes.  If you have a\n      single JSON text that is 1GB in size, streaming it will allow you\n      to process it much more quickly.\n\n      However, streaming isn't easy to deal with as the jq program will\n      have `[<path>, <leaf-value>]` (and a few other forms) as inputs.\n\n      Several builtins are provided to make handling streams easier.\n\n      The examples below use the streamed form of `[\"a\",[\"b\"]]`, which is\n      `[[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]]`.\n\n      Streaming forms include `[<path>, <leaf-value>]` (to indicate any\n      scalar value, empty array, or empty object), and `[<path>]` (to\n      indicate the end of an array or object).  Future versions of jq\n      run with `--stream` and `--seq` may output additional forms such\n      as `[\"error message\"]` when an input text fails to parse.\n\n    entries:\n      - title: \"`truncate_stream(stream_expression)`\"\n        body: |\n\n          Consumes a number as input and truncates the corresponding\n          number of path elements from the left of the outputs of the\n          given streaming expression.\n\n        examples:\n          - program: 'truncate_stream([[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]])'\n            input: '1'\n            output: ['[[0],\"b\"]', '[[0]]']\n\n      - title: \"`fromstream(stream_expression)`\"\n        body: |\n\n          Outputs values corresponding to the stream expression's\n          outputs.\n\n        examples:\n          - program: 'fromstream(1|truncate_stream([[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]]))'\n            input: 'null'\n            output: ['[\"b\"]']\n\n      - title: \"`tostream`\"\n        body: |\n\n          The `tostream` builtin outputs the streamed form of its input.\n\n        examples:\n          - program: '. as $dot|fromstream($dot|tostream)|.==$dot'\n            input: '[0,[1,{\"a\":1},{\"b\":2}]]'\n            output: ['true']\n\n  - title: Assignment\n    body: |\n      Assignment works a little differently in jq than in most\n      programming languages. jq doesn't distinguish between references\n      to and copies of something - two objects or arrays are either\n      equal or not equal, without any further notion of being \"the\n      same object\" or \"not the same object\".\n\n      If an object has two fields which are arrays, `.foo` and `.bar`,\n      and you append something to `.foo`, then `.bar` will not get\n      bigger, even if you've previously set `.bar = .foo`.  If you're\n      used to programming in languages like Python, Java, Ruby,\n      JavaScript, etc. then you can think of it as though jq does a full\n      deep copy of every object before it does the assignment (for\n      performance it doesn't actually do that, but that's the general\n      idea).\n\n      This means that it's impossible to build circular values in jq\n      (such as an array whose first element is itself). This is quite\n      intentional, and ensures that anything a jq program can produce\n      can be represented in JSON.\n\n      All the assignment operators in jq have path expressions on the\n      left-hand side (LHS).  The right-hand side (RHS) provides values\n      to set to the paths named by the LHS path expressions.\n\n      Values in jq are always immutable.  Internally, assignment works\n      by using a reduction to compute new, replacement values for `.` that\n      have had all the desired assignments applied to `.`, then\n      outputting the modified value.  This might be made clear by this\n      example: `{a:{b:{c:1}}} | (.a.b|=3), .`.  This will output\n      `{\"a\":{\"b\":3}}` and `{\"a\":{\"b\":{\"c\":1}}}` because the last\n      sub-expression, `.`, sees the original value, not the modified\n      value.\n\n      Most users will want to use modification assignment operators,\n      such as `|=` or `+=`, rather than `=`.\n\n      Note that the LHS of assignment operators refers to a value in\n      `.`.  Thus `$var.foo = 1` won't work as expected (`$var.foo` is\n      not a valid or useful path expression in `.`); use `$var | .foo =\n      1` instead.\n\n      Note too that `.a,.b=0` does not set `.a` and `.b`, but\n      `(.a,.b)=0` sets both.\n\n    entries:\n      - title: \"Update-assignment: `|=`\"\n        body: |\n          This is the \"update\" operator `|=`.  It takes a filter on the\n          right-hand side and works out the new value for the property\n          of `.` being assigned to by running the old value through this\n          expression. For instance, `(.foo, .bar) |= .+1` will build an\n          object with the `foo` field set to the input's `foo` plus 1,\n          and the `bar` field set to the input's `bar` plus 1.\n\n          The left-hand side can be any general path expression; see `path()`.\n\n          Note that the left-hand side of `|=` refers to a value in `.`.\n          Thus `$var.foo |= . + 1` won't work as expected (`$var.foo` is\n          not a valid or useful path expression in `.`); use `$var |\n          .foo |= . + 1` instead.\n\n          If the right-hand side outputs no values (i.e., `empty`), then\n          the left-hand side path will be deleted, as with `del(path)`.\n\n          If the right-hand side outputs multiple values, only the first\n          one will be used (COMPATIBILITY NOTE: in jq 1.5 and earlier\n          releases, it used to be that only the last one was used).\n\n        examples:\n          - program: '(..|select(type==\"boolean\")) |= if . then 1 else 0 end'\n            input: '[true,false,[5,true,[true,[false]],false]]'\n            output: ['[1,0,[5,1,[1,[0]],0]]']\n\n      - title: \"Arithmetic update-assignment: `+=`, `-=`, `*=`, `/=`, `%=`, `//=`\"\n        body: |\n\n          jq has a few operators of the form `a op= b`, which are all\n          equivalent to `a |= . op b`. So, `+= 1` can be used to\n          increment values, being the same as `|= . + 1`.\n\n        examples:\n          - program: .foo += 1\n            input: '{\"foo\": 42}'\n            output: ['{\"foo\": 43}']\n\n      - title: \"Plain assignment: `=`\"\n        body: |\n\n          This is the plain assignment operator.  Unlike the others, the\n          input to the right-hand side (RHS) is the same as the input to\n          the left-hand side (LHS) rather than the value at the LHS\n          path, and all values output by the RHS will be used (as shown\n          below).\n\n          If the RHS of `=` produces multiple values, then for each such\n          value jq will set the paths on the left-hand side to the value\n          and then it will output the modified `.`.  For example,\n          `(.a,.b) = range(2)` outputs `{\"a\":0,\"b\":0}`, then\n          `{\"a\":1,\"b\":1}`.  The \"update\" assignment forms (see above) do\n          not do this.\n\n          This example should show the difference between `=` and `|=`:\n\n          Provide input `{\"a\": {\"b\": 10}, \"b\": 20}` to the programs\n\n              .a = .b\n\n          and\n\n              .a |= .b\n\n          The former will set the `a` field of the input to the `b`\n          field of the input, and produce the output `{\"a\": 20, \"b\": 20}`.\n          The latter will set the `a` field of the input to the `a`\n          field's `b` field, producing `{\"a\": 10, \"b\": 20}`.\n\n        examples:\n          - program: .a = .b\n            input: '{\"a\": {\"b\": 10}, \"b\": 20}'\n            output: ['{\"a\":20,\"b\":20}']\n\n          - program: .a |= .b\n            input: '{\"a\": {\"b\": 10}, \"b\": 20}'\n            output: ['{\"a\":10,\"b\":20}']\n\n          - program: (.a, .b) = range(3)\n            input: 'null'\n            output:\n              - '{\"a\":0,\"b\":0}'\n              - '{\"a\":1,\"b\":1}'\n              - '{\"a\":2,\"b\":2}'\n\n          - program: (.a, .b) |= range(3)\n            input: 'null'\n            output: ['{\"a\":0,\"b\":0}']\n\n      - title: Complex assignments\n        body: |\n          Lots more things are allowed on the left-hand side of a jq assignment\n          than in most languages. We've already seen simple field accesses on\n          the left hand side, and it's no surprise that array accesses work just\n          as well:\n\n              .posts[0].title = \"JQ Manual\"\n\n          What may come as a surprise is that the expression on the left may\n          produce multiple results, referring to different points in the input\n          document:\n\n              .posts[].comments |= . + [\"this is great\"]\n\n          That example appends the string \"this is great\" to the \"comments\"\n          array of each post in the input (where the input is an object with a\n          field \"posts\" which is an array of posts).\n\n          When jq encounters an assignment like 'a = b', it records the \"path\"\n          taken to select a part of the input document while executing a. This\n          path is then used to find which part of the input to change while\n          executing the assignment. Any filter may be used on the\n          left-hand side of an equals - whichever paths it selects from the\n          input will be where the assignment is performed.\n\n          This is a very powerful operation. Suppose we wanted to add a comment\n          to blog posts, using the same \"blog\" input above. This time, we only\n          want to comment on the posts written by \"stedolan\". We can find those\n          posts using the \"select\" function described earlier:\n\n              .posts[] | select(.author == \"stedolan\")\n\n          The paths provided by this operation point to each of the posts that\n          \"stedolan\" wrote, and we can comment on each of them in the same way\n          that we did before:\n\n              (.posts[] | select(.author == \"stedolan\") | .comments) |=\n                  . + [\"terrible.\"]\n\n  - title: Modules\n    body: |\n\n      jq has a library/module system.  Modules are files whose names end\n      in `.jq`.\n\n      Modules imported by a program are searched for in a default search\n      path (see below).  The `import` and `include` directives allow the\n      importer to alter this path.\n\n      Paths in the search path are subject to various substitutions.\n\n      For paths starting with `~/`, the user's home directory is\n      substituted for `~`.\n\n      For paths starting with `$ORIGIN/`, the directory where the jq\n      executable is located is substituted for `$ORIGIN`.\n\n      For paths starting with `./` or paths that are `.`, the path of\n      the including file is substituted for `.`.  For top-level programs\n      given on the command-line, the current directory is used.\n\n      Import directives can optionally specify a search path to which\n      the default is appended.\n\n      The default search path is the search path given to the `-L`\n      command-line option, else `[\"~/.jq\", \"$ORIGIN/../lib/jq\",\n      \"$ORIGIN/../lib\"]`.\n\n      Null and empty string path elements terminate search path\n      processing.\n\n      A dependency with relative path `foo/bar` would be searched for in\n      `foo/bar.jq` and `foo/bar/bar.jq` in the given search path. This\n      is intended to allow modules to be placed in a directory along\n      with, for example, version control files, README files, and so on,\n      but also to allow for single-file modules.\n\n      Consecutive components with the same name are not allowed to avoid\n      ambiguities (e.g., `foo/foo`).\n\n      For example, with `-L$HOME/.jq` a module `foo` can be found in\n      `$HOME/.jq/foo.jq` and `$HOME/.jq/foo/foo.jq`.\n\n      If `$HOME/.jq` is a file, it is sourced into the main program.\n\n    entries:\n      - title: \"`import RelativePathString as NAME [<metadata>];`\"\n        body: |\n\n          Imports a module found at the given path relative to a\n          directory in a search path.  A `.jq` suffix will be added to\n          the relative path string.  The module's symbols are prefixed\n          with `NAME::`.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like `homepage` and so on.  At\n          this time jq only uses the `search` key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n          The `search` key in the metadata, if present, should have a\n          string or array value (array of strings); this is the search\n          path to be prefixed to the top-level search path.\n\n      - title: \"`include RelativePathString [<metadata>];`\"\n        body: |\n\n          Imports a module found at the given path relative to a\n          directory in a search path as if it were included in place.  A\n          `.jq` suffix will be added to the relative path string.  The\n          module's symbols are imported into the caller's namespace as\n          if the module's content had been included directly.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like `homepage` and so on.  At\n          this time jq only uses the `search` key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n      - title: \"`import RelativePathString as $NAME [<metadata>];`\"\n        body: |\n\n          Imports a JSON file found at the given path relative to a\n          directory in a search path.  A `.json` suffix will be added to\n          the relative path string.  The file's data will be available\n          as `$NAME::NAME`.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like `homepage` and so on.  At\n          this time jq only uses the `search` key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n          The `search` key in the metadata, if present, should have a\n          string or array value (array of strings); this is the search\n          path to be prefixed to the top-level search path.\n\n      - title: \"`module <metadata>;`\"\n        body: |\n\n          This directive is entirely optional.  It's not required for\n          proper operation.  It serves only the purpose of providing\n          metadata that can be read with the `modulemeta` builtin.\n\n          The metadata must be a constant jq expression.  It should be\n          an object with keys like `homepage`.  At this time jq doesn't\n          use this metadata, but it is made available to users via the\n          `modulemeta` builtin.\n\n      - title: \"`modulemeta`\"\n        body: |\n\n          Takes a module name as input and outputs the module's metadata\n          as an object, with the module's imports (including metadata)\n          as an array value for the `deps` key and the module's defined\n          functions as an array value for the `defs` key.\n\n          Programs can use this to query a module's metadata, which they\n          could then use to, for example, search for, download, and\n          install missing dependencies.\n\n  - title: Colors\n    body: |\n\n      To configure alternative colors just set the `JQ_COLORS`\n      environment variable to colon-delimited list of partial terminal\n      escape sequences like `\"1;31\"`, in this order:\n\n        - color for `null`\n        - color for `false`\n        - color for `true`\n        - color for numbers\n        - color for strings\n        - color for arrays\n        - color for objects\n        - color for object keys\n\n      The default color scheme is the same as setting\n      `JQ_COLORS=\"0;90:0;37:0;37:0;37:0;32:1;37:1;37:1;34\"`.\n\n      This is not a manual for VT100/ANSI escapes.  However, each of\n      these color specifications should consist of two numbers separated\n      by a semi-colon, where the first number is one of these:\n\n        - 1 (bright)\n        - 2 (dim)\n        - 4 (underscore)\n        - 5 (blink)\n        - 7 (reverse)\n        - 8 (hidden)\n\n      and the second is one of these:\n\n        - 30 (black)\n        - 31 (red)\n        - 32 (green)\n        - 33 (yellow)\n        - 34 (blue)\n        - 35 (magenta)\n        - 36 (cyan)\n        - 37 (white)\n"
  },
  {
    "path": "docs/content/manual/v1.8/manual.yml",
    "content": "---\nheadline: jq 1.8 Manual\n\nbody: |\n\n  A jq program is a \"filter\": it takes an input, and produces an\n  output. There are a lot of builtin filters for extracting a\n  particular field of an object, or converting a number to a string,\n  or various other standard tasks.\n\n  Filters can be combined in various ways - you can pipe the output of\n  one filter into another filter, or collect the output of a filter\n  into an array.\n\n  Some filters produce multiple results, for instance there's one that\n  produces all the elements of its input array. Piping that filter\n  into a second runs the second filter for each element of the\n  array. Generally, things that would be done with loops and iteration\n  in other languages are just done by gluing filters together in jq.\n\n  It's important to remember that every filter has an input and an\n  output. Even literals like \"hello\" or 42 are filters - they take an\n  input but always produce the same literal as output. Operations that\n  combine two filters, like addition, generally feed the same input to\n  both and combine the results. So, you can implement an averaging\n  filter as `add / length` - feeding the input array both to the `add`\n  filter and the `length` filter and then performing the division.\n\n  But that's getting ahead of ourselves. :) Let's start with something\n  simpler:\n\nmanpage_intro: |\n  jq(1) -- Command-line JSON processor\n  ====================================\n\n  ## SYNOPSIS\n\n  `jq` [<options>...] <filter> [<files>...]\n\n  `jq` can transform JSON in various ways, by selecting, iterating,\n  reducing and otherwise mangling JSON documents. For instance,\n  running the command `jq 'map(.price) | add'` will take an array of\n  JSON objects as input and return the sum of their \"price\" fields.\n\n  `jq` can accept text input as well, but by default, `jq` reads a\n  stream of JSON entities (including numbers and other literals) from\n  `stdin`. Whitespace is only needed to separate entities such as 1\n  and 2, and true and false.  One or more <files> may be specified, in\n  which case `jq` will read input from those instead.\n\n  The <options> are described in the [INVOKING JQ] section; they\n  mostly concern input and output formatting. The <filter> is written\n  in the jq language and specifies how to transform the input\n  file or document.\n\n  ## FILTERS\n\nmanpage_epilogue: |\n  ## BUGS\n\n  Presumably. Report them or discuss them at:\n\n      https://github.com/jqlang/jq/issues\n\n  ## AUTHOR\n\n  Stephen Dolan `<mu@netsoc.tcd.ie>`\n\nsections:\n  - title: Invoking jq\n    body: |\n\n      jq filters run on a stream of JSON data. The input to jq is\n      parsed as a sequence of whitespace-separated JSON values which\n      are passed through the provided filter one at a time. The\n      output(s) of the filter are written to standard output, as a\n      sequence of newline-separated JSON data.\n\n      The simplest and most common filter (or jq program) is `.`,\n      which is the identity operator, copying the inputs of the jq\n      processor to the output stream.  Because the default behavior of\n      the jq processor is to read JSON texts from the input stream,\n      and to pretty-print outputs, the `.` program's main use is to\n      validate and pretty-print the inputs.  The jq programming\n      language is quite rich and allows for much more than just\n      validation and pretty-printing.\n\n      Note: it is important to mind the shell's quoting rules.  As a\n      general rule it's best to always quote (with single-quote\n      characters on Unix shells) the jq program, as too many characters with special\n      meaning to jq are also shell meta-characters.  For example, `jq\n      \"foo\"` will fail on most Unix shells because that will be the same\n      as `jq foo`, which will generally fail because `foo is not\n      defined`.  When using the Windows command shell (cmd.exe) it's\n      best to use double quotes around your jq program when given on the\n      command-line (instead of the `-f program-file` option), but then\n      double-quotes in the jq program need backslash escaping. When using\n      the Powershell (`powershell.exe`) or the Powershell Core\n      (`pwsh`/`pwsh.exe`), use single-quote characters around the jq\n      program and backslash-escaped double-quotes (`\\\"`) inside the jq\n      program.\n\n      * Unix shells: `jq '.[\"foo\"]'`\n      * Powershell: `jq '.[\\\"foo\\\"]'`\n      * Windows command shell: `jq \".[\\\"foo\\\"]\"`\n\n      Note: jq allows user-defined functions, but every jq program\n      must have a top-level expression.\n\n      You can affect how jq reads and writes its input and output\n      using some command-line options:\n\n      * `--null-input` / `-n`:\n\n        Don't read any input at all. Instead, the filter is run once\n        using `null` as the input. This is useful when using jq as a\n        simple calculator or to construct JSON data from scratch.\n\n      * `--raw-input` / `-R`:\n\n        Don't parse the input as JSON. Instead, each line of text is\n        passed to the filter as a string. If combined with `--slurp`,\n        then the entire input is passed to the filter as a single long\n        string.\n\n      * `--slurp` / `-s`:\n\n        Instead of running the filter for each JSON object in the\n        input, read the entire input stream into a large array and run\n        the filter just once.\n\n      * `--compact-output` / `-c`:\n\n        By default, jq pretty-prints JSON output. Using this option\n        will result in more compact output by instead putting each\n        JSON object on a single line.\n\n      * `--raw-output` / `-r`:\n\n        With this option, if the filter's result is a string then it\n        will be written directly to standard output rather than being\n        formatted as a JSON string with quotes. This can be useful for\n        making jq filters talk to non-JSON-based systems.\n\n      * `--raw-output0`:\n\n        Like `-r` but jq will print NUL instead of newline after each output.\n        This can be useful when the values being output can contain newlines.\n        When the output value contains NUL, jq exits with non-zero code.\n\n      * `--join-output` / `-j`:\n\n        Like `-r` but jq won't print a newline after each output.\n\n      * `--ascii-output` / `-a`:\n\n        jq usually outputs non-ASCII Unicode codepoints as UTF-8, even\n        if the input specified them as escape sequences (like\n        \"\\u03bc\"). Using this option, you can force jq to produce pure\n        ASCII output with every non-ASCII character replaced with the\n        equivalent escape sequence.\n\n      * `--sort-keys` / `-S`:\n\n        Output the fields of each object with the keys in sorted order.\n\n      * `--color-output` / `-C` and `--monochrome-output` / `-M`:\n\n        By default, jq outputs colored JSON if writing to a\n        terminal. You can force it to produce color even if writing to\n        a pipe or a file using `-C`, and disable color with `-M`.\n        When the `NO_COLOR` environment variable is not empty, jq disables\n        colored output by default, but you can enable it by `-C`.\n\n        Colors can be configured with the `JQ_COLORS` environment\n        variable (see below).\n\n      * `--tab`:\n\n        Use a tab for each indentation level instead of two spaces.\n\n      * `--indent n`:\n\n        Use the given number of spaces (no more than 7) for indentation.\n\n      * `--unbuffered`:\n\n        Flush the output after each JSON object is printed (useful if\n        you're piping a slow data source into jq and piping jq's\n        output elsewhere).\n\n      * `--stream`:\n\n        Parse the input in streaming fashion, outputting arrays of path\n        and leaf values (scalars and empty arrays or empty objects).\n        For example, `\"a\"` becomes `[[],\"a\"]`, and `[[],\"a\",[\"b\"]]`\n        becomes `[[0],[]]`, `[[1],\"a\"]`, and `[[2,0],\"b\"]`.\n\n        This is useful for processing very large inputs.  Use this in\n        conjunction with filtering and the `reduce` and `foreach` syntax\n        to reduce large inputs incrementally.\n\n      * `--stream-errors`:\n\n        Like `--stream`, but invalid JSON inputs yield array values\n        where the first element is the error and the second is a path.\n        For example, `[\"a\",n]` produces `[\"Invalid literal at line 1,\n        column 7\",[1]]`.\n\n        Implies `--stream`.  Invalid JSON inputs produce no error values\n        when `--stream` without `--stream-errors`.\n\n      * `--seq`:\n\n        Use the `application/json-seq` MIME type scheme for separating\n        JSON texts in jq's input and output.  This means that an ASCII\n        RS (record separator) character is printed before each value on\n        output and an ASCII LF (line feed) is printed after every\n        output.  Input JSON texts that fail to parse are ignored (but\n        warned about), discarding all subsequent input until the next\n        RS.  This mode also parses the output of jq without the `--seq`\n        option.\n\n      * `-f` / `--from-file`:\n\n        Read the filter from a file rather than from a command line,\n        like awk's -f option. This changes the filter argument to be\n        interpreted as a filename, instead of the source of a program.\n\n      * `-L directory` / `--library-path directory`:\n\n        Prepend `directory` to the search list for modules.  If this\n        option is used then no builtin search list is used.  See the\n        section on modules below.\n\n      * `--arg name value`:\n\n        This option passes a value to the jq program as a predefined\n        variable. If you run jq with `--arg foo bar`, then `$foo` is\n        available in the program and has the value `\"bar\"`. Note that\n        `value` will be treated as a string, so `--arg foo 123` will\n        bind `$foo` to `\"123\"`.\n\n        Named arguments are also available to the jq program as\n        `$ARGS.named`. When the name is not a valid identifier, this is\n        the only way to access it.\n\n      * `--argjson name JSON-text`:\n\n        This option passes a JSON-encoded value to the jq program as a\n        predefined variable. If you run jq with `--argjson foo 123`, then\n        `$foo` is available in the program and has the value `123`.\n\n      * `--slurpfile variable-name filename`:\n\n        This option reads all the JSON texts in the named file and binds\n        an array of the parsed JSON values to the given global variable.\n        If you run jq with `--slurpfile foo bar`, then `$foo` is available\n        in the program and has an array whose elements correspond to the\n        texts in the file named `bar`.\n\n      * `--rawfile variable-name filename`:\n\n        This option reads in the named file and binds its content to the given\n        global variable.  If you run jq with `--rawfile foo bar`, then `$foo` is\n        available in the program and has a string whose content is set to the\n        text in the file named `bar`.\n\n      * `--args`:\n\n        Remaining arguments are positional string arguments.  These are\n        available to the jq program as `$ARGS.positional[]`.\n\n      * `--jsonargs`:\n\n        Remaining arguments are positional JSON text arguments.  These\n        are available to the jq program as `$ARGS.positional[]`.\n\n      * `--exit-status` / `-e`:\n\n        Sets the exit status of jq to 0 if the last output value was\n        neither `false` nor `null`, 1 if the last output value was\n        either `false` or `null`, or 4 if no valid result was ever\n        produced.  Normally jq exits with 2 if there was any usage\n        problem or system error, 3 if there was a jq program compile\n        error, or 0 if the jq program ran.\n\n        Another way to set the exit status is with the `halt_error`\n        builtin function.\n\n      * `--binary` / `-b`:\n\n        Windows users using WSL, MSYS2, or Cygwin, should use this option\n        when using a native jq.exe, otherwise jq will turn newlines (LFs)\n        into carriage-return-then-newline (CRLF).\n\n      * `--version` / `-V`:\n\n        Output the jq version and exit with zero.\n\n      * `--build-configuration`:\n\n        Output the build configuration of jq and exit with zero.\n        This output has no supported format or structure and may change\n        without notice in future releases.\n\n      * `--help` / `-h`:\n\n        Output the jq help and exit with zero.\n\n      * `--`:\n\n        Terminates argument processing.  Remaining arguments are not\n        interpreted as options.\n\n      * `--run-tests [filename]`:\n\n        Runs the tests in the given file or standard input.  This must\n        be the last option given and does not honor all preceding\n        options.  The input consists of comment lines, empty lines, and\n        program lines followed by one input line, as many lines of\n        output as are expected (one per output), and a terminating empty\n        line.  Compilation failure tests start with a line containing\n        only `%%FAIL`, then a line containing the program to compile,\n        then a line containing an error message to compare to the\n        actual.\n\n        Be warned that this option can change backwards-incompatibly.\n\n  - title: Basic filters\n    entries:\n      - title: \"Identity: `.`\"\n        body: |\n\n          The absolute simplest filter is `.` .  This filter takes its\n          input and produces the same value as output.  That is, this\n          is the identity operator.\n\n          Since jq by default pretty-prints all output, a trivial\n          program consisting of nothing but `.` can be used to format\n          JSON output from, say, `curl`.\n\n          Although the identity filter never modifies the value of its\n          input, jq processing can sometimes make it appear as though\n          it does.  For example, using the current implementation of\n          jq, we would see that the expression:\n\n              1E1234567890 | .\n\n          produces `1.7976931348623157e+308` on at least one platform.\n          This is because, in the process of parsing the number, this\n          particular version of jq has converted it to an IEEE754\n          double-precision representation, losing precision.\n\n          The way in which jq handles numbers has changed over time\n          and further changes are likely within the parameters set by\n          the relevant JSON standards.  Moreover, build configuration\n          options can alter how jq processes numbers.\n\n          The following remarks are therefore offered with the\n          understanding that they are intended to be descriptive of the\n          current version of jq and should not be interpreted as being\n          prescriptive:\n\n          (1) Any arithmetic operation on a number that has not\n          already been converted to an IEEE754 double precision\n          representation will trigger a conversion to the IEEE754\n          representation.\n\n          (2) jq will attempt to maintain the original decimal\n          precision of number literals (if the `--disable-decnum`\n          build configuration option was not used), but in expressions\n          such `1E1234567890`, precision will be lost if the exponent\n          is too large.\n\n          (3) Comparisons are carried out using the untruncated\n          big decimal representation of numbers if available, as\n          illustrated in one of the following examples.\n\n          The examples below use the builtin function `have_decnum` in\n          order to demonstrate the expected effects of using / not\n          using the `--disable-decnum` build configuration option, and\n          also to allow automated tests derived from these examples to\n          pass regardless of whether that option is used.\n\n        examples:\n          - program: '.'\n            input: '\"Hello, world!\"'\n            output: ['\"Hello, world!\"']\n\n          - program: '.'\n            input: '0.12345678901234567890123456789'\n            output: ['0.12345678901234567890123456789']\n\n          - program: '[., tojson] == if have_decnum then [12345678909876543212345,\"12345678909876543212345\"] else [12345678909876543000000,\"12345678909876543000000\"] end'\n            input: '12345678909876543212345'\n            output: ['true']\n\n          - program: '[1234567890987654321,-1234567890987654321 | tojson] == if have_decnum then [\"1234567890987654321\",\"-1234567890987654321\"] else [\"1234567890987654400\",\"-1234567890987654400\"] end'\n            input: 'null'\n            output: ['true']\n\n          - program: '. < 0.12345678901234567890123456788'\n            input: '0.12345678901234567890123456789'\n            output: ['false']\n\n          - program: 'map([., . == 1]) | tojson == if have_decnum then \"[[1,true],[1.000,true],[1.0,true],[1.00,true]]\" else \"[[1,true],[1,true],[1,true],[1,true]]\" end'\n            input: '[1, 1.000, 1.0, 100e-2]'\n            output: ['true']\n\n          - program: '. as $big | [$big, $big + 1] | map(. > 10000000000000000000000000000000) | . == if have_decnum then [true, false] else [false, false] end'\n            input: '10000000000000000000000000000001'\n            output: ['true']\n\n      - title: \"Object Identifier-Index: `.foo`, `.foo.bar`\"\n        body: |\n\n          The simplest *useful* filter has the form `.foo`. When given a\n          JSON object (aka dictionary or hash) as input, `.foo` produces\n          the value at the key \"foo\" if the key is present, or null otherwise.\n\n          A filter of the form `.foo.bar` is equivalent to `.foo | .bar`.\n\n          The `.foo` syntax only works for simple, identifier-like keys, that\n          is, keys that are all made of alphanumeric characters and\n          underscore, and which do not start with a digit.\n\n          If the key contains special characters or starts with a digit,\n          you need to surround it with double quotes like this:\n          `.\"foo$\"`, or else `.[\"foo$\"]`.\n\n          For example `.[\"foo::bar\"]` and `.[\"foo.bar\"]` work while\n          `.foo::bar` does not.\n\n        examples:\n          - program: '.foo'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n\n          - program: '.foo'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n\n          - program: '.[\"foo\"]'\n            input: '{\"foo\": 42}'\n            output: ['42']\n\n      - title: \"Optional Object Identifier-Index: `.foo?`\"\n        body: |\n\n          Just like `.foo`, but does not output an error when `.` is not an\n          object.\n\n        examples:\n          - program: '.foo?'\n            input: '{\"foo\": 42, \"bar\": \"less interesting data\"}'\n            output: ['42']\n          - program: '.foo?'\n            input: '{\"notfoo\": true, \"alsonotfoo\": false}'\n            output: ['null']\n          - program: '.[\"foo\"]?'\n            input: '{\"foo\": 42}'\n            output: ['42']\n          - program: '[.foo?]'\n            input: '[1,2]'\n            output: ['[]']\n\n      - title: \"Object Index: `.[<string>]`\"\n        body: |\n\n          You can also look up fields of an object using syntax like\n          `.[\"foo\"]` (`.foo` above is a shorthand version of this, but\n          only for identifier-like strings).\n\n      - title: \"Array Index: `.[<number>]`\"\n        body: |\n\n          When the index value is an integer, `.[<number>]` can index\n          arrays.  Arrays are zero-based, so `.[2]` returns the third\n          element.\n\n          Negative indices are allowed, with -1 referring to the last\n          element, -2 referring to the next to last element, and so on.\n\n        examples:\n          - program: '.[0]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['{\"name\":\"JSON\", \"good\":true}']\n\n          - program: '.[2]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['null']\n\n          - program: '.[-2]'\n            input: '[1,2,3]'\n            output: ['2']\n\n      - title: \"Array/String Slice: `.[<number>:<number>]`\"\n        body: |\n\n          The `.[<number>:<number>]` syntax can be used to return a\n          subarray of an array or substring of a string. The array\n          returned by `.[10:15]` will be of length 5, containing the\n          elements from index 10 (inclusive) to index 15 (exclusive).\n          Either index may be negative (in which case it counts\n          backwards from the end of the array), or omitted (in which\n          case it refers to the start or end of the array).\n          Indices are zero-based.\n\n        examples:\n          - program: '.[2:4]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"c\", \"d\"]']\n\n          - program: '.[2:4]'\n            input: '\"abcdefghi\"'\n            output: ['\"cd\"']\n\n          - program: '.[:3]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"a\", \"b\", \"c\"]']\n\n          - program: '.[-2:]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['[\"d\", \"e\"]']\n\n      - title: \"Array/Object Value Iterator: `.[]`\"\n        body: |\n\n          If you use the `.[index]` syntax, but omit the index\n          entirely, it will return *all* of the elements of an\n          array. Running `.[]` with the input `[1,2,3]` will produce the\n          numbers as three separate results, rather than as a single\n          array. A filter of the form `.foo[]` is equivalent to\n          `.foo | .[]`.\n\n          You can also use this on an object, and it will return all\n          the values of the object.\n\n          Note that the iterator operator is a generator of values.\n\n        examples:\n          - program: '.[]'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output:\n              - '{\"name\":\"JSON\", \"good\":true}'\n              - '{\"name\":\"XML\", \"good\":false}'\n\n          - program: '.[]'\n            input: '[]'\n            output: []\n\n          - program: '.foo[]'\n            input: '{\"foo\":[1,2,3]}'\n            output: ['1','2','3']\n\n          - program: '.[]'\n            input: '{\"a\": 1, \"b\": 1}'\n            output: ['1', '1']\n\n      - title: \"`.[]?`\"\n        body: |\n\n          Like `.[]`, but no errors will be output if . is not an array\n          or object. A filter of the form `.foo[]?` is equivalent to\n          `.foo | .[]?`.\n\n      - title: \"Comma: `,`\"\n        body: |\n\n          If two filters are separated by a comma, then the\n          same input will be fed into both and the two filters' output\n          value streams will be concatenated in order: first, all of the\n          outputs produced by the left expression, and then all of the\n          outputs produced by the right. For instance, filter `.foo,\n          .bar`, produces both the \"foo\" fields and \"bar\" fields as\n          separate outputs.\n\n          The `,` operator is one way to construct generators.\n\n        examples:\n          - program: '.foo, .bar'\n            input: '{\"foo\": 42, \"bar\": \"something else\", \"baz\": true}'\n            output: ['42', '\"something else\"']\n\n          - program: \".user, .projects[]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['\"stedolan\"', '\"jq\"', '\"wikiflow\"']\n\n          - program: '.[4,2]'\n            input: '[\"a\",\"b\",\"c\",\"d\",\"e\"]'\n            output: ['\"e\"', '\"c\"']\n\n      - title: \"Pipe: `|`\"\n        body: |\n\n          The | operator combines two filters by feeding the output(s) of\n          the one on the left into the input of the one on the right. It's\n          similar to the Unix shell's pipe, if you're used to that.\n\n          If the one on the left produces multiple results, the one on\n          the right will be run for each of those results. So, the\n          expression `.[] | .foo` retrieves the \"foo\" field of each\n          element of the input array.  This is a cartesian product,\n          which can be surprising.\n\n          Note that `.a.b.c` is the same as `.a | .b | .c`.\n\n          Note too that `.` is the input value at the particular stage\n          in a \"pipeline\", specifically: where the `.` expression appears.\n          Thus `.a | . | .b` is the same as `.a.b`, as the `.` in the\n          middle refers to whatever value `.a` produced.\n\n        examples:\n          - program: '.[] | .name'\n            input: '[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]'\n            output: ['\"JSON\"', '\"XML\"']\n\n      - title: \"Parenthesis\"\n        body: |\n\n          Parenthesis work as a grouping operator just as in any typical\n          programming language.\n\n        examples:\n          - program: '(. + 2) * 5'\n            input: '1'\n            output: ['15']\n\n  - title: Types and Values\n    body: |\n\n      jq supports the same set of datatypes as JSON - numbers,\n      strings, booleans, arrays, objects (which in JSON-speak are\n      hashes with only string keys), and \"null\".\n\n      Booleans, null, strings and numbers are written the same way as\n      in JSON. Just like everything else in jq, these simple\n      values take an input and produce an output - `42` is a valid jq\n      expression that takes an input, ignores it, and returns 42\n      instead.\n\n      Numbers in jq are internally represented by their IEEE754 double\n      precision approximation. Any arithmetic operation with numbers,\n      whether they are literals or results of previous filters, will\n      produce a double precision floating point result.\n\n      However, when parsing a literal jq will store the original literal\n      string. If no mutation is applied to this value then it will make\n      to the output in its original form, even if conversion to double\n      would result in a loss.\n\n    entries:\n      - title: \"Array construction: `[]`\"\n        body: |\n\n          As in JSON, `[]` is used to construct arrays, as in\n          `[1,2,3]`. The elements of the arrays can be any jq\n          expression, including a pipeline. All of the results produced\n          by all of the expressions are collected into one big array.\n          You can use it to construct an array out of a known quantity\n          of values (as in `[.foo, .bar, .baz]`) or to \"collect\" all the\n          results of a filter into an array (as in `[.items[].name]`)\n\n          Once you understand the \",\" operator, you can look at jq's array\n          syntax in a different light: the expression `[1,2,3]` is not using a\n          built-in syntax for comma-separated arrays, but is instead applying\n          the `[]` operator (collect results) to the expression 1,2,3 (which\n          produces three different results).\n\n          If you have a filter `X` that produces four results,\n          then the expression `[X]` will produce a single result, an\n          array of four elements.\n\n        examples:\n          - program: \"[.user, .projects[]]\"\n            input: '{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}'\n            output: ['[\"stedolan\", \"jq\", \"wikiflow\"]']\n          - program: \"[ .[] | . * 2]\"\n            input: '[1, 2, 3]'\n            output: ['[2, 4, 6]']\n\n      - title: \"Object Construction: `{}`\"\n        body: |\n\n          Like JSON, `{}` is for constructing objects (aka\n          dictionaries or hashes), as in: `{\"a\": 42, \"b\": 17}`.\n\n          If the keys are \"identifier-like\", then the quotes can be left\n          off, as in `{a:42, b:17}`.  Variable references as key\n          expressions use the value of the variable as the key.  Key\n          expressions other than constant literals, identifiers, or\n          variable references, need to be parenthesized, e.g.,\n          `{(\"a\"+\"b\"):59}`.\n\n          The value can be any expression (although you may need to wrap\n          it in parentheses if, for example, it contains colons), which\n          gets applied to the {} expression's input (remember, all\n          filters have an input and an output).\n\n              {foo: .bar}\n\n          will produce the JSON object `{\"foo\": 42}` if given the JSON\n          object `{\"bar\":42, \"baz\":43}` as its input. You can use this\n          to select particular fields of an object: if the input is an\n          object with \"user\", \"title\", \"id\", and \"content\" fields and\n          you just want \"user\" and \"title\", you can write\n\n              {user: .user, title: .title}\n\n          Because that is so common, there's a shortcut syntax for it:\n          `{user, title}`.\n\n          If one of the expressions produces multiple results,\n          multiple dictionaries will be produced. If the input's\n\n              {\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n\n          then the expression\n\n              {user, title: .titles[]}\n\n          will produce two outputs:\n\n              {\"user\":\"stedolan\", \"title\": \"JQ Primer\"}\n              {\"user\":\"stedolan\", \"title\": \"More JQ\"}\n\n          Putting parentheses around the key means it will be evaluated as an\n          expression. With the same input as above,\n\n              {(.user): .titles}\n\n          produces\n\n              {\"stedolan\": [\"JQ Primer\", \"More JQ\"]}\n\n          Variable references as keys use the value of the variable as\n          the key.  Without a value then the variable's name becomes the\n          key and its value becomes the value,\n\n              \"f o o\" as $foo | \"b a r\" as $bar | {$foo, $bar:$foo}\n\n          produces\n\n              {\"foo\":\"f o o\",\"b a r\":\"f o o\"}\n\n        examples:\n          - program: '{user, title: .titles[]}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output:\n              - '{\"user\":\"stedolan\", \"title\": \"JQ Primer\"}'\n              - '{\"user\":\"stedolan\", \"title\": \"More JQ\"}'\n          - program: '{(.user): .titles}'\n            input: '{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}'\n            output: ['{\"stedolan\": [\"JQ Primer\", \"More JQ\"]}']\n\n      - title: \"Recursive Descent: `..`\"\n        body: |\n\n          Recursively descends `.`, producing every value.  This is the\n          same as the zero-argument `recurse` builtin (see below).  This\n          is intended to resemble the XPath `//` operator.  Note that\n          `..a` does not work; use `.. | .a` instead.  In the example\n          below we use `.. | .a?` to find all the values of object keys\n          \"a\" in any object found \"below\" `.`.\n\n          This is particularly useful in conjunction with `path(EXP)`\n          (also see below) and the `?` operator.\n\n        examples:\n          - program: '.. | .a?'\n            input: '[[{\"a\":1}]]'\n            output: ['1']\n\n  - title: Builtin operators and functions\n    body: |\n\n      Some jq operators (for instance, `+`) do different things\n      depending on the type of their arguments (arrays, numbers,\n      etc.). However, jq never does implicit type conversions. If you\n      try to add a string to an object you'll get an error message and\n      no result.\n\n      Please note that all numbers are converted to IEEE754 double precision\n      floating point representation. Arithmetic and logical operators are working\n      with these converted doubles. Results of all such operations are also limited\n      to the double precision.\n\n      The only exception to this behaviour of number is a snapshot of original number\n      literal. When a number which originally was provided as a literal is never\n      mutated until the end of the program then it is printed to the output in its\n      original literal form. This also includes cases when the original literal\n      would be truncated when converted to the IEEE754 double precision floating point\n      number.\n\n    entries:\n      - title: \"Addition: `+`\"\n        body: |\n\n          The operator `+` takes two filters, applies them both\n          to the same input, and adds the results together. What\n          \"adding\" means depends on the types involved:\n\n          - **Numbers** are added by normal arithmetic.\n\n          - **Arrays** are added by being concatenated into a larger array.\n\n          - **Strings** are added by being joined into a larger string.\n\n          - **Objects** are added by merging, that is, inserting all\n            the key-value pairs from both objects into a single\n            combined object. If both objects contain a value for the\n            same key, the object on the right of the `+` wins. (For\n            recursive merge use the `*` operator.)\n\n          `null` can be added to any value, and returns the other\n          value unchanged.\n\n        examples:\n          - program: '.a + 1'\n            input: '{\"a\": 7}'\n            output: ['8']\n          - program: '.a + .b'\n            input: '{\"a\": [1,2], \"b\": [3,4]}'\n            output: ['[1,2,3,4]']\n          - program: '.a + null'\n            input: '{\"a\": 1}'\n            output: ['1']\n          - program: '.a + 1'\n            input: '{}'\n            output: ['1']\n          - program: '{a: 1} + {b: 2} + {c: 3} + {a: 42}'\n            input: 'null'\n            output: ['{\"a\": 42, \"b\": 2, \"c\": 3}']\n\n      - title: \"Subtraction: `-`\"\n        body: |\n\n          As well as normal arithmetic subtraction on numbers, the `-`\n          operator can be used on arrays to remove all occurrences of\n          the second array's elements from the first array.\n\n        examples:\n          - program: '4 - .a'\n            input: '{\"a\":3}'\n            output: ['1']\n          - program: . - [\"xml\", \"yaml\"]\n            input: '[\"xml\", \"yaml\", \"json\"]'\n            output: ['[\"json\"]']\n\n      - title: \"Multiplication, division, modulo: `*`, `/`, `%`\"\n        body: |\n\n          These infix operators behave as expected when given two numbers.\n          Division by zero raises an error. `x % y` computes x modulo y.\n\n          Multiplying a string by a number produces the concatenation of\n          that string that many times. `\"x\" * 0` produces `\"\"`.\n\n          Dividing a string by another splits the first using the second\n          as separators.\n\n          Multiplying two objects will merge them recursively: this works\n          like addition but if both objects contain a value for the\n          same key, and the values are objects, the two are merged with\n          the same strategy.\n\n        examples:\n          - program: '10 / . * 3'\n            input: '5'\n            output: ['6']\n          - program: '. / \", \"'\n            input: '\"a, b,c,d, e\"'\n            output: ['[\"a\",\"b,c,d\",\"e\"]']\n          - program: '{\"k\": {\"a\": 1, \"b\": 2}} * {\"k\": {\"a\": 0,\"c\": 3}}'\n            input: 'null'\n            output: ['{\"k\": {\"a\": 0, \"b\": 2, \"c\": 3}}']\n          - program: '.[] | (1 / .)?'\n            input: '[1,0,-1]'\n            output: ['1', '-1']\n\n      - title: \"`abs`\"\n        body: |\n\n          The builtin function `abs` is defined naively as: `if . < 0 then - . else . end`.\n\n          For numeric input, this is the absolute value.  See the\n          section on the identity filter for the implications of this\n          definition for numeric input.\n\n          To compute the absolute value of a number as a floating point number, you may wish use `fabs`.\n\n        examples:\n          - program: 'map(abs)'\n            input: '[-10, -1.1, -1e-1]'\n            output: ['[10,1.1,1e-1]']\n\n      - title: \"`length`\"\n        body: |\n\n          The builtin function `length` gets the length of various\n          different types of value:\n\n          - The length of a **string** is the number of Unicode\n            codepoints it contains (which will be the same as its\n            JSON-encoded length in bytes if it's pure ASCII).\n\n          - The length of a **number** is its absolute value.\n\n          - The length of an **array** is the number of elements.\n\n          - The length of an **object** is the number of key-value pairs.\n\n          - The length of **null** is zero.\n\n          - It is an error to use `length` on a **boolean**.\n\n        examples:\n          - program: '.[] | length'\n            input: '[[1,2], \"string\", {\"a\":2}, null, -5]'\n            output: ['2', '6', '1', '0', '5']\n\n\n      - title: \"`utf8bytelength`\"\n        body: |\n\n          The builtin function `utf8bytelength` outputs the number of\n          bytes used to encode a string in UTF-8.\n\n        examples:\n          - program: 'utf8bytelength'\n            input: '\"\\u03bc\"'\n            output: ['2']\n\n      - title: \"`keys`, `keys_unsorted`\"\n        body: |\n\n          The builtin function `keys`, when given an object, returns\n          its keys in an array.\n\n          The keys are sorted \"alphabetically\", by unicode codepoint\n          order. This is not an order that makes particular sense in\n          any particular language, but you can count on it being the\n          same for any two objects with the same set of keys,\n          regardless of locale settings.\n\n          When `keys` is given an array, it returns the valid indices\n          for that array: the integers from 0 to length-1.\n\n          The `keys_unsorted` function is just like `keys`, but if\n          the input is an object then the keys will not be sorted,\n          instead the keys will roughly be in insertion order.\n\n        examples:\n          - program: 'keys'\n            input: '{\"abc\": 1, \"abcd\": 2, \"Foo\": 3}'\n            output: ['[\"Foo\", \"abc\", \"abcd\"]']\n          - program: 'keys'\n            input: '[42,3,35]'\n            output: ['[0,1,2]']\n\n      - title: \"`has(key)`\"\n        body: |\n\n          The builtin function `has` returns whether the input object\n          has the given key, or the input array has an element at the\n          given index.\n\n          `has($key)` has the same effect as checking whether `$key`\n          is a member of the array returned by `keys`, although `has`\n          will be faster.\n\n        examples:\n          - program: 'map(has(\"foo\"))'\n            input: '[{\"foo\": 42}, {}]'\n            output: ['[true, false]']\n          - program: 'map(has(2))'\n            input: '[[0,1], [\"a\",\"b\",\"c\"]]'\n            output: ['[false, true]']\n\n      - title: \"`in`\"\n        body: |\n\n          The builtin function `in` returns whether or not the input key is in the\n          given object, or the input index corresponds to an element\n          in the given array. It is, essentially, an inversed version\n          of `has`.\n\n        examples:\n          - program: '.[] | in({\"foo\": 42})'\n            input: '[\"foo\", \"bar\"]'\n            output: ['true', 'false']\n          - program: 'map(in([0,1]))'\n            input: '[2, 0]'\n            output: ['[false, true]']\n\n      - title: \"`map(f)`, `map_values(f)`\"\n        body: |\n\n          For any filter `f`, `map(f)` and `map_values(f)` apply `f`\n          to each of the values in the input array or object, that is,\n          to the values of `.[]`.\n\n          In the absence of errors, `map(f)` always outputs an array\n          whereas `map_values(f)` outputs an array if given an array,\n          or an object if given an object.\n\n          When the input to `map_values(f)` is an object, the output\n          object has the same keys as the input object except for\n          those keys whose values when piped to `f` produce no values\n          at all.\n\n          The key difference between `map(f)` and `map_values(f)` is\n          that the former simply forms an array from all the values of\n          `($x|f)` for each value, `$x`, in the input array or object,\n          but `map_values(f)` only uses `first($x|f)`.\n\n          Specifically, for object inputs, `map_values(f)` constructs\n          the output object by examining in turn the value of\n          `first(.[$k]|f)` for each key, `$k`, of the input.  If this\n          expression produces no values, then the corresponding key\n          will be dropped; otherwise, the output object will have that\n          value at the key, `$k`.\n\n          Here are some examples to clarify the behavior of `map` and\n          `map_values` when applied to arrays. These examples assume the\n          input is `[1]` in all cases:\n\n              map(.+1)          #=>  [2]\n              map(., .)         #=>  [1,1]\n              map(empty)        #=>  []\n\n              map_values(.+1)   #=>  [2]\n              map_values(., .)  #=>  [1]\n              map_values(empty) #=>  []\n\n          `map(f)` is equivalent to `[.[] | f]` and\n          `map_values(f)` is equivalent to `.[] |= f`.\n\n          In fact, these are their implementations.\n\n\n        examples:\n          - program: 'map(.+1)'\n            input: '[1,2,3]'\n            output: ['[2,3,4]']\n\n          - program: 'map_values(.+1)'\n            input: '{\"a\": 1, \"b\": 2, \"c\": 3}'\n            output: ['{\"a\": 2, \"b\": 3, \"c\": 4}']\n\n          - program: 'map(., .)'\n            input: '[1,2]'\n            output: ['[1,1,2,2]']\n\n          - program: 'map_values(. // empty)'\n            input: '{\"a\": null, \"b\": true, \"c\": false}'\n            output: ['{\"b\":true}']\n\n\n      - title: \"`pick(pathexps)`\"\n        body: |\n\n          Emit the projection of the input object or array defined by the\n          specified sequence of path expressions, such that if `p` is any\n          one of these specifications, then `(. | p)` will evaluate to the\n          same value as `(. | pick(pathexps) | p)`. For arrays, negative\n          indices and `.[m:n]` specifications should not be used.\n\n        examples:\n          - program: 'pick(.a, .b.c, .x)'\n            input: '{\"a\": 1, \"b\": {\"c\": 2, \"d\": 3}, \"e\": 4}'\n            output: ['{\"a\":1,\"b\":{\"c\":2},\"x\":null}']\n\n          - program: 'pick(.[2], .[0], .[0])'\n            input: '[1,2,3,4]'\n            output: ['[1,null,3]']\n\n\n      - title: \"`path(path_expression)`\"\n        body: |\n\n          Outputs array representations of the given path expression\n          in `.`.  The outputs are arrays of strings (object keys)\n          and/or numbers (array indices).\n\n          Path expressions are jq expressions like `.a`, but also `.[]`.\n          There are two types of path expressions: ones that can match\n          exactly, and ones that cannot.  For example, `.a.b.c` is an\n          exact match path expression, while `.a[].b` is not.\n\n          `path(exact_path_expression)` will produce the array\n          representation of the path expression even if it does not\n          exist in `.`, if `.` is `null` or an array or an object.\n\n          `path(pattern)` will produce array representations of the\n          paths matching `pattern` if the paths exist in `.`.\n\n          Note that the path expressions are not different from normal\n          expressions.  The expression\n          `path(..|select(type==\"boolean\"))` outputs all the paths to\n          boolean values in `.`, and only those paths.\n\n        examples:\n          - program: 'path(.a[0].b)'\n            input: 'null'\n            output: ['[\"a\",0,\"b\"]']\n          - program: '[path(..)]'\n            input: '{\"a\":[{\"b\":1}]}'\n            output: ['[[],[\"a\"],[\"a\",0],[\"a\",0,\"b\"]]']\n\n      - title: \"`del(path_expression)`\"\n        body: |\n\n          The builtin function `del` removes a key and its corresponding\n          value from an object.\n\n        examples:\n          - program: 'del(.foo)'\n            input: '{\"foo\": 42, \"bar\": 9001, \"baz\": 42}'\n            output: ['{\"bar\": 9001, \"baz\": 42}']\n          - program: 'del(.[1, 2])'\n            input: '[\"foo\", \"bar\", \"baz\"]'\n            output: ['[\"foo\"]']\n\n      - title: \"`getpath(PATHS)`\"\n        body: |\n\n          The builtin function `getpath` outputs the values in `.` found\n          at each path in `PATHS`.\n\n        examples:\n          - program: 'getpath([\"a\",\"b\"])'\n            input: 'null'\n            output: ['null']\n          - program: '[getpath([\"a\",\"b\"], [\"a\",\"c\"])]'\n            input: '{\"a\":{\"b\":0, \"c\":1}}'\n            output: ['[0, 1]']\n\n      - title: \"`setpath(PATHS; VALUE)`\"\n        body: |\n\n          The builtin function `setpath` sets the `PATHS` in `.` to `VALUE`.\n\n        examples:\n          - program: 'setpath([\"a\",\"b\"]; 1)'\n            input: 'null'\n            output: ['{\"a\": {\"b\": 1}}']\n          - program: 'setpath([\"a\",\"b\"]; 1)'\n            input: '{\"a\":{\"b\":0}}'\n            output: ['{\"a\": {\"b\": 1}}']\n          - program: 'setpath([0,\"a\"]; 1)'\n            input: 'null'\n            output: ['[{\"a\":1}]']\n\n      - title: \"`delpaths(PATHS)`\"\n        body: |\n\n          The builtin function `delpaths` deletes the `PATHS` in `.`.\n          `PATHS` must be an array of paths, where each path is an array\n          of strings and numbers.\n\n        examples:\n          - program: 'delpaths([[\"a\",\"b\"]])'\n            input: '{\"a\":{\"b\":1},\"x\":{\"y\":2}}'\n            output: ['{\"a\":{},\"x\":{\"y\":2}}']\n\n      - title: \"`to_entries`, `from_entries`, `with_entries(f)`\"\n        body: |\n\n          These functions convert between an object and an array of\n          key-value pairs. If `to_entries` is passed an object, then\n          for each `k: v` entry in the input, the output array\n          includes `{\"key\": k, \"value\": v}`.\n\n          `from_entries` does the opposite conversion, and `with_entries(f)`\n          is a shorthand for `to_entries | map(f) | from_entries`, useful for\n          doing some operation to all keys and values of an object.\n          `from_entries` accepts `\"key\"`, `\"Key\"`, `\"name\"`, `\"Name\"`,\n          `\"value\"`, and `\"Value\"` as keys.\n\n        examples:\n          - program: 'to_entries'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]']\n          - program: 'from_entries'\n            input: '[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]'\n            output: ['{\"a\": 1, \"b\": 2}']\n          - program: 'with_entries(.key |= \"KEY_\" + .)'\n            input: '{\"a\": 1, \"b\": 2}'\n            output: ['{\"KEY_a\": 1, \"KEY_b\": 2}']\n\n\n      - title: \"`select(boolean_expression)`\"\n        body: |\n\n          The function `select(f)` produces its input unchanged if\n          `f` returns true for that input, and produces no output\n          otherwise.\n\n          It's useful for filtering lists: `[1,2,3] | map(select(. >= 2))`\n          will give you `[2,3]`.\n\n        examples:\n          - program: 'map(select(. >= 2))'\n            input: '[1,5,3,0,7]'\n            output: ['[5,3,7]']\n          - program: '.[] | select(.id == \"second\")'\n            input: '[{\"id\": \"first\", \"val\": 1}, {\"id\": \"second\", \"val\": 2}]'\n            output: ['{\"id\": \"second\", \"val\": 2}']\n\n\n      - title: \"`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `normals`, `finites`, `strings`, `nulls`, `values`, `scalars`\"\n        body: |\n\n          These built-ins select only inputs that are arrays, objects,\n          iterables (arrays or objects), booleans, numbers, normal\n          numbers, finite numbers, strings, null, non-null values, and\n          non-iterables, respectively.\n\n        examples:\n          - program: '.[]|numbers'\n            input: '[[],{},1,\"foo\",null,true,false]'\n            output: ['1']\n\n      - title: \"`empty`\"\n        body: |\n\n          `empty` returns no results. None at all. Not even `null`.\n\n          It's useful on occasion. You'll know if you need it :)\n\n        examples:\n          - program: '1, empty, 2'\n            input: 'null'\n            output: ['1', '2']\n          - program: '[1,2,empty,3]'\n            input: 'null'\n            output: ['[1,2,3]']\n\n      - title: \"`error`, `error(message)`\"\n        body: |\n\n          Produces an error with the input value, or with the message\n          given as the argument. Errors can be caught with try/catch;\n          see below.\n\n        examples:\n          - program: 'try error catch .'\n            input: '\"error message\"'\n            output: ['\"error message\"']\n\n          - program: 'try error(\"invalid value: \\(.)\") catch .'\n            input: '42'\n            output: ['\"invalid value: 42\"']\n\n      - title: \"`halt`\"\n        body: |\n\n          Stops the jq program with no further outputs.  jq will exit\n          with exit status `0`.\n\n      - title: \"`halt_error`, `halt_error(exit_code)`\"\n        body: |\n\n          Stops the jq program with no further outputs.  The input will\n          be printed on `stderr` as raw output (i.e., strings will not\n          have double quotes) with no decoration, not even a newline.\n\n          The given `exit_code` (defaulting to `5`) will be jq's exit\n          status.\n\n          For example, `\"Error: something went wrong\\n\"|halt_error(1)`.\n\n      - title: \"`$__loc__`\"\n        body: |\n\n          Produces an object with a \"file\" key and a \"line\" key, with\n          the filename and line number where `$__loc__` occurs, as\n          values.\n\n        examples:\n          - program: 'try error(\"\\($__loc__)\") catch .'\n            input: 'null'\n            output: ['\"{\\\"file\\\":\\\"<top-level>\\\",\\\"line\\\":1}\"']\n\n      - title: \"`paths`, `paths(node_filter)`\"\n        body: |\n\n          `paths` outputs the paths to all the elements in its input\n          (except it does not output the empty list, representing .\n          itself).\n\n          `paths(f)` outputs the paths to any values for which `f` is `true`.\n          That is, `paths(type == \"number\")` outputs the paths to all numeric\n          values.\n\n        examples:\n          - program: '[paths]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1],[1,0],[1,1],[1,1,\"a\"]]']\n          - program: '[paths(type == \"number\")]'\n            input: '[1,[[],{\"a\":2}]]'\n            output: ['[[0],[1,1,\"a\"]]']\n\n      - title: \"`add`, `add(generator)`\"\n        body: |\n\n          The filter `add` takes as input an array, and produces as\n          output the elements of the array added together. This might\n          mean summed, concatenated or merged depending on the types\n          of the elements of the input array - the rules are the same\n          as those for the `+` operator (described above).\n\n          If the input is an empty array, `add` returns `null`.\n\n          `add(generator)` operates on the given generator rather than\n          the input.\n\n        examples:\n          - program: add\n            input: '[\"a\",\"b\",\"c\"]'\n            output: ['\"abc\"']\n          - program: add\n            input: '[1, 2, 3]'\n            output: ['6']\n          - program: add\n            input: '[]'\n            output: [\"null\"]\n          - program: add(.[].a)\n            input: '[{\"a\":3}, {\"a\":5}, {\"b\":6}]'\n            output: ['8']\n\n      - title: \"`any`, `any(condition)`, `any(generator; condition)`\"\n        body: |\n\n          The filter `any` takes as input an array of boolean values,\n          and produces `true` as output if any of the elements of\n          the array are `true`.\n\n          If the input is an empty array, `any` returns `false`.\n\n          The `any(condition)` form applies the given condition to the\n          elements of the input array.\n\n          The `any(generator; condition)` form applies the given\n          condition to all the outputs of the given generator.\n\n        examples:\n          - program: any\n            input: '[true, false]'\n            output: [\"true\"]\n          - program: any\n            input: '[false, false]'\n            output: [\"false\"]\n          - program: any\n            input: '[]'\n            output: [\"false\"]\n\n      - title: \"`all`, `all(condition)`, `all(generator; condition)`\"\n        body: |\n\n          The filter `all` takes as input an array of boolean values,\n          and produces `true` as output if all of the elements of\n          the array are `true`.\n\n          The `all(condition)` form applies the given condition to the\n          elements of the input array.\n\n          The `all(generator; condition)` form applies the given\n          condition to all the outputs of the given generator.\n\n          If the input is an empty array, `all` returns `true`.\n\n        examples:\n          - program: all\n            input: '[true, false]'\n            output: [\"false\"]\n          - program: all\n            input: '[true, true]'\n            output: [\"true\"]\n          - program: all\n            input: '[]'\n            output: [\"true\"]\n\n      - title: \"`flatten`, `flatten(depth)`\"\n        body: |\n\n          The filter `flatten` takes as input an array of nested arrays,\n          and produces a flat array in which all arrays inside the original\n          array have been recursively replaced by their values. You can pass\n          an argument to it to specify how many levels of nesting to flatten.\n\n          `flatten(2)` is like `flatten`, but going only up to two\n          levels deep.\n\n        examples:\n          - program: flatten\n            input: '[1, [2], [[3]]]'\n            output: [\"[1, 2, 3]\"]\n          - program: flatten(1)\n            input: '[1, [2], [[3]]]'\n            output: [\"[1, 2, [3]]\"]\n          - program: flatten\n            input: '[[]]'\n            output: [\"[]\"]\n          - program: flatten\n            input: '[{\"foo\": \"bar\"}, [{\"foo\": \"baz\"}]]'\n            output: ['[{\"foo\": \"bar\"}, {\"foo\": \"baz\"}]']\n\n      - title: \"`range(upto)`, `range(from; upto)`, `range(from; upto; by)`\"\n        body: |\n\n          The `range` function produces a range of numbers. `range(4; 10)`\n          produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers\n          are produced as separate outputs. Use `[range(4; 10)]` to get a range as\n          an array.\n\n          The one argument form generates numbers from 0 to the given\n          number, with an increment of 1.\n\n          The two argument form generates numbers from `from` to `upto`\n          with an increment of 1.\n\n          The three argument form generates numbers `from` to `upto`\n          with an increment of `by`.\n\n        examples:\n          - program: 'range(2; 4)'\n            input: 'null'\n            output: ['2', '3']\n          - program: '[range(2; 4)]'\n            input: 'null'\n            output: ['[2,3]']\n          - program: '[range(4)]'\n            input: 'null'\n            output: ['[0,1,2,3]']\n          - program: '[range(0; 10; 3)]'\n            input: 'null'\n            output: ['[0,3,6,9]']\n          - program: '[range(0; 10; -1)]'\n            input: 'null'\n            output: ['[]']\n          - program: '[range(0; -5; -1)]'\n            input: 'null'\n            output: ['[0,-1,-2,-3,-4]']\n\n      - title: \"`floor`\"\n        body: |\n\n          The `floor` function returns the floor of its numeric input.\n\n        examples:\n          - program: 'floor'\n            input: '3.14159'\n            output: ['3']\n\n      - title: \"`sqrt`\"\n        body: |\n\n          The `sqrt` function returns the square root of its numeric input.\n\n        examples:\n          - program: 'sqrt'\n            input: '9'\n            output: ['3']\n\n      - title: \"`tonumber`\"\n        body: |\n\n          The `tonumber` function parses its input as a number. It\n          will convert correctly-formatted strings to their numeric\n          equivalent, leave numbers alone, and give an error on all other input.\n\n        examples:\n          - program: '.[] | tonumber'\n            input: '[1, \"1\"]'\n            output: ['1', '1']\n\n      - title: \"`toboolean`\"\n        body: |\n\n          The `toboolean` function parses its input as a boolean. It\n          will convert correctly-formatted strings to their boolean\n          equivalent, leave booleans alone, and give an error on all other input.\n\n        examples:\n          - program: '.[] | toboolean'\n            input: '[\"true\", \"false\", true, false]'\n            output: ['true', 'false', 'true', 'false']\n\n      - title: \"`tostring`\"\n        body: |\n\n          The `tostring` function prints its input as a\n          string. Strings are left unchanged, and all other values are\n          JSON-encoded.\n\n        examples:\n          - program: '.[] | tostring'\n            input: '[1, \"1\", [1]]'\n            output: ['\"1\"', '\"1\"', '\"[1]\"']\n\n      - title: \"`type`\"\n        body: |\n\n          The `type` function returns the type of its argument as a\n          string, which is one of null, boolean, number, string, array\n          or object.\n\n        examples:\n          - program: 'map(type)'\n            input: '[0, false, [], {}, null, \"hello\"]'\n            output: ['[\"number\", \"boolean\", \"array\", \"object\", \"null\", \"string\"]']\n\n      - title: \"`infinite`, `nan`, `isinfinite`, `isnan`, `isfinite`, `isnormal`\"\n        body: |\n\n          Some arithmetic operations can yield infinities and \"not a\n          number\" (NaN) values.  The `isinfinite` builtin returns `true`\n          if its input is infinite.  The `isnan` builtin returns `true`\n          if its input is a NaN.  The `infinite` builtin returns a\n          positive infinite value.  The `nan` builtin returns a NaN.\n          The `isnormal` builtin returns true if its input is a normal\n          number.\n\n          Note that division by zero raises an error.\n\n          Currently most arithmetic operations operating on infinities,\n          NaNs, and sub-normals do not raise errors.\n\n        examples:\n          - program: '.[] | (infinite * .) < 0'\n            input: '[-1, 1]'\n            output: ['true', 'false']\n          - program: 'infinite, nan | type'\n            input: 'null'\n            output: ['\"number\"', '\"number\"']\n\n      - title: \"`sort`, `sort_by(path_expression)`\"\n        body: |\n\n          The `sort` functions sorts its input, which must be an\n          array. Values are sorted in the following order:\n\n          * `null`\n          * `false`\n          * `true`\n          * numbers\n          * strings, in alphabetical order (by unicode codepoint value)\n          * arrays, in lexical order\n          * objects\n\n          The ordering for objects is a little complex: first they're\n          compared by comparing their sets of keys (as arrays in\n          sorted order), and if their keys are equal then the values\n          are compared key by key.\n\n          `sort_by` may be used to sort by a particular field of an\n          object, or by applying any jq filter. `sort_by(f)` compares\n          two elements by comparing the result of `f` on each element.\n          When `f` produces multiple values, it firstly compares the\n          first values, and the second values if the first values are\n          equal, and so on.\n\n        examples:\n          - program: 'sort'\n            input: '[8,3,null,6]'\n            output: ['[null,3,6,8]']\n\n          - program: 'sort_by(.foo)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":10}, {\"foo\":2, \"bar\":1}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":4, \"bar\":10}]']\n\n          - program: 'sort_by(.foo, .bar)'\n            input: '[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}]'\n            output: ['[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":4, \"bar\":10}]']\n\n      - title: \"`group_by(path_expression)`\"\n        body: |\n\n          `group_by(.foo)` takes as input an array, groups the\n          elements having the same `.foo` field into separate arrays,\n          and produces all of these arrays as elements of a larger\n          array, sorted by the value of the `.foo` field.\n\n          Any jq expression, not just a field access, may be used in\n          place of `.foo`. The sorting order is the same as described\n          in the `sort` function above.\n\n        examples:\n          - program: 'group_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":10}, {\"foo\":3, \"bar\":100}, {\"foo\":1, \"bar\":1}]'\n            output: ['[[{\"foo\":1, \"bar\":10}, {\"foo\":1, \"bar\":1}], [{\"foo\":3, \"bar\":100}]]']\n\n      - title: \"`min`, `max`, `min_by(path_exp)`, `max_by(path_exp)`\"\n        body: |\n\n          Find the minimum or maximum element of the input array.\n\n          The `min_by(path_exp)` and `max_by(path_exp)` functions allow\n          you to specify a particular field or property to examine, e.g.\n          `min_by(.foo)` finds the object with the smallest `foo` field.\n\n        examples:\n          - program: 'min'\n            input: '[5,4,2,7]'\n            output: ['2']\n          - program: 'max_by(.foo)'\n            input: '[{\"foo\":1, \"bar\":14}, {\"foo\":2, \"bar\":3}]'\n            output: ['{\"foo\":2, \"bar\":3}']\n\n      - title: \"`unique`, `unique_by(path_exp)`\"\n        body: |\n\n          The `unique` function takes as input an array and produces\n          an array of the same elements, in sorted order, with\n          duplicates removed.\n\n          The `unique_by(path_exp)` function will keep only one element\n          for each value obtained by applying the argument. Think of it\n          as making an array by taking one element out of every group\n          produced by `group`.\n\n        examples:\n          - program: 'unique'\n            input: '[1,2,5,3,5,3,1,3]'\n            output: ['[1,2,3,5]']\n          - program: 'unique_by(.foo)'\n            input: '[{\"foo\": 1, \"bar\": 2}, {\"foo\": 1, \"bar\": 3}, {\"foo\": 4, \"bar\": 5}]'\n            output: ['[{\"foo\": 1, \"bar\": 2}, {\"foo\": 4, \"bar\": 5}]']\n          - program: 'unique_by(length)'\n            input: '[\"chunky\", \"bacon\", \"kitten\", \"cicada\", \"asparagus\"]'\n            output: ['[\"bacon\", \"chunky\", \"asparagus\"]']\n\n      - title: \"`reverse`\"\n        body: |\n\n          This function reverses an array.\n\n        examples:\n          - program: 'reverse'\n            input: '[1,2,3,4]'\n            output: ['[4,3,2,1]']\n\n      - title: \"`contains(element)`\"\n        body: |\n\n          The filter `contains(b)` will produce true if b is\n          completely contained within the input. A string B is\n          contained in a string A if B is a substring of A. An array B\n          is contained in an array A if all elements in B are\n          contained in any element in A. An object B is contained in\n          object A if all of the values in B are contained in the\n          value in A with the same key. All other types are assumed to\n          be contained in each other if they are equal.\n\n        examples:\n          - program: 'contains(\"bar\")'\n            input: '\"foobar\"'\n            output: ['true']\n          - program: 'contains([\"baz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['true']\n          - program: 'contains([\"bazzzzz\", \"bar\"])'\n            input: '[\"foobar\", \"foobaz\", \"blarp\"]'\n            output: ['false']\n          - program: 'contains({foo: 12, bar: [{barp: 12}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['true']\n          - program: 'contains({foo: 12, bar: [{barp: 15}]})'\n            input: '{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}'\n            output: ['false']\n\n      - title: \"`indices(s)`\"\n        body: |\n\n          Outputs an array containing the indices in `.` where `s`\n          occurs.  The input may be an array, in which case if `s` is an\n          array then the indices output will be those where all elements\n          in `.` match those of `s`.\n\n        examples:\n          - program: 'indices(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['[3,7,12]']\n          - program: 'indices(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['[1,3,5]']\n          - program: 'indices([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['[1,8]']\n\n      - title: \"`index(s)`, `rindex(s)`\"\n        body: |\n\n          Outputs the index of the first (`index`) or last (`rindex`)\n          occurrence of `s` in the input.\n\n        examples:\n          - program: 'index(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['3']\n          - program: 'index(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['1']\n          - program: 'index([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['1']\n          - program: 'rindex(\", \")'\n            input: '\"a,b, cd, efg, hijk\"'\n            output: ['12']\n          - program: 'rindex(1)'\n            input: '[0,1,2,1,3,1,4]'\n            output: ['5']\n          - program: 'rindex([1,2])'\n            input: '[0,1,2,3,1,4,2,5,1,2,6,7]'\n            output: ['8']\n\n      - title: \"`inside`\"\n        body: |\n\n          The filter `inside(b)` will produce true if the input is\n          completely contained within b. It is, essentially, an\n          inversed version of `contains`.\n\n        examples:\n          - program: 'inside(\"foobar\")'\n            input: '\"bar\"'\n            output: ['true']\n          - program: 'inside([\"foobar\", \"foobaz\", \"blarp\"])'\n            input: '[\"baz\", \"bar\"]'\n            output: ['true']\n          - program: 'inside([\"foobar\", \"foobaz\", \"blarp\"])'\n            input: '[\"bazzzzz\", \"bar\"]'\n            output: ['false']\n          - program: 'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})'\n            input: '{\"foo\": 12, \"bar\": [{\"barp\": 12}]}'\n            output: ['true']\n          - program: 'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})'\n            input: '{\"foo\": 12, \"bar\": [{\"barp\": 15}]}'\n            output: ['false']\n\n      - title: \"`startswith(str)`\"\n        body: |\n\n          Outputs `true` if . starts with the given string argument.\n\n        examples:\n          - program: '[.[]|startswith(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"barfoob\"]'\n            output: ['[false, true, false, true, false]']\n\n      - title: \"`endswith(str)`\"\n        body: |\n\n          Outputs `true` if . ends with the given string argument.\n\n        examples:\n          - program: '[.[]|endswith(\"foo\")]'\n            input: '[\"foobar\", \"barfoo\"]'\n            output: ['[false, true]']\n\n      - title: \"`combinations`, `combinations(n)`\"\n        body: |\n\n          Outputs all combinations of the elements of the arrays in the\n          input array. If given an argument `n`, it outputs all combinations\n          of `n` repetitions of the input array.\n\n        examples:\n          - program: 'combinations'\n            input: '[[1,2], [3, 4]]'\n            output: ['[1, 3]', '[1, 4]', '[2, 3]', '[2, 4]']\n          - program: 'combinations(2)'\n            input: '[0, 1]'\n            output: ['[0, 0]', '[0, 1]', '[1, 0]', '[1, 1]']\n\n      - title: \"`ltrimstr(str)`\"\n        body: |\n\n          Outputs its input with the given prefix string removed, if it\n          starts with it.\n\n        examples:\n          - program: '[.[]|ltrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"afoo\"]'\n            output: ['[\"fo\",\"\",\"barfoo\",\"bar\",\"afoo\"]']\n\n      - title: \"`rtrimstr(str)`\"\n        body: |\n\n          Outputs its input with the given suffix string removed, if it\n          ends with it.\n\n        examples:\n          - program: '[.[]|rtrimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"foob\"]'\n            output: ['[\"fo\",\"\",\"bar\",\"foobar\",\"foob\"]']\n\n      - title: \"`trimstr(str)`\"\n        body: |\n\n          Outputs its input with the given string removed at both ends, if it\n          starts or ends with it.\n\n        examples:\n          - program: '[.[]|trimstr(\"foo\")]'\n            input: '[\"fo\", \"foo\", \"barfoo\", \"foobarfoo\", \"foob\"]'\n            output: ['[\"fo\",\"\",\"bar\",\"bar\",\"b\"]']\n\n      - title: \"`trim`, `ltrim`, `rtrim`\"\n        body: |\n\n          `trim` trims both leading and trailing whitespace.\n\n          `ltrim` trims only leading (left side) whitespace.\n\n          `rtrim` trims only trailing (right side) whitespace.\n\n          Whitespace characters are the usual `\" \"`, `\"\\n\"` `\"\\t\"`, `\"\\r\"`\n          and also all characters in the Unicode character database with the\n          whitespace property. Note that what considers whitespace might\n          change in the future.\n\n        examples:\n          - program: 'trim, ltrim, rtrim'\n            input: '\" abc \"'\n            output: ['\"abc\"', '\"abc \"', '\" abc\"']\n\n      - title: \"`explode`\"\n        body: |\n\n          Converts an input string into an array of the string's\n          codepoint numbers.\n\n        examples:\n          - program: 'explode'\n            input: '\"foobar\"'\n            output: ['[102,111,111,98,97,114]']\n\n      - title: \"`implode`\"\n        body: |\n\n          The inverse of explode.\n\n        examples:\n          - program: 'implode'\n            input: '[65, 66, 67]'\n            output: ['\"ABC\"']\n\n      - title: \"`split(str)`\"\n        body: |\n\n          Splits an input string on the separator argument.\n\n          `split` can also split on regex matches when called with\n          two arguments (see the regular expressions section below).\n\n        examples:\n          - program: 'split(\", \")'\n            input: '\"a, b,c,d, e, \"'\n            output: ['[\"a\",\"b,c,d\",\"e\",\"\"]']\n\n      - title: \"`join(str)`\"\n        body: |\n\n          Joins the array of elements given as input, using the\n          argument as separator. It is the inverse of `split`: that is,\n          running `split(\"foo\") | join(\"foo\")` over any input string\n          returns said input string.\n\n          Numbers and booleans in the input are converted to strings.\n          Null values are treated as empty strings. Arrays and objects\n          in the input are not supported.\n\n        examples:\n          - program: 'join(\", \")'\n            input: '[\"a\",\"b,c,d\",\"e\"]'\n            output: ['\"a, b,c,d, e\"']\n          - program: 'join(\" \")'\n            input: '[\"a\",1,2.3,true,null,false]'\n            output: ['\"a 1 2.3 true  false\"']\n\n      - title: \"`ascii_downcase`, `ascii_upcase`\"\n        body: |\n\n          Emit a copy of the input string with its alphabetic characters (a-z and A-Z)\n          converted to the specified case.\n\n        examples:\n          - program: 'ascii_upcase'\n            input: '\"useful but not for é\"'\n            output: ['\"USEFUL BUT NOT FOR é\"']\n\n      - title: \"`while(cond; update)`\"\n        body: |\n\n          The `while(cond; update)` function allows you to repeatedly\n          apply an update to `.` until `cond` is false.\n\n          Note that `while(cond; update)` is internally defined as a\n          recursive jq function.  Recursive calls within `while` will\n          not consume additional memory if `update` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[while(.<100; .*2)]'\n            input: '1'\n            output: ['[1,2,4,8,16,32,64]']\n\n      - title: \"`repeat(exp)`\"\n        body: |\n\n          The `repeat(exp)` function allows you to repeatedly\n          apply expression `exp` to `.` until an error is raised.\n\n          Note that `repeat(exp)` is internally defined as a\n          recursive jq function.  Recursive calls within `repeat` will\n          not consume additional memory if `exp` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[repeat(.*2, error)?]'\n            input: '1'\n            output: ['[2]']\n\n      - title: \"`until(cond; next)`\"\n        body: |\n\n          The `until(cond; next)` function allows you to repeatedly\n          apply the expression `next`, initially to `.` then to its own\n          output, until `cond` is true.  For example, this can be used\n          to implement a factorial function (see below).\n\n          Note that `until(cond; next)` is internally defined as a\n          recursive jq function.  Recursive calls within `until()` will\n          not consume additional memory if `next` produces at most one\n          output for each input.  See advanced topics below.\n\n        examples:\n          - program: '[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]'\n            input: '4'\n            output: ['24']\n\n\n      - title: \"`recurse(f)`, `recurse`, `recurse(f; condition)`\"\n        body: |\n\n          The `recurse(f)` function allows you to search through a\n          recursive structure, and extract interesting data from all\n          levels. Suppose your input represents a filesystem:\n\n              {\"name\": \"/\", \"children\": [\n                {\"name\": \"/bin\", \"children\": [\n                  {\"name\": \"/bin/ls\", \"children\": []},\n                  {\"name\": \"/bin/sh\", \"children\": []}]},\n                {\"name\": \"/home\", \"children\": [\n                  {\"name\": \"/home/stephen\", \"children\": [\n                    {\"name\": \"/home/stephen/jq\", \"children\": []}]}]}]}\n\n          Now suppose you want to extract all of the filenames\n          present. You need to retrieve `.name`, `.children[].name`,\n          `.children[].children[].name`, and so on. You can do this\n          with:\n\n              recurse(.children[]) | .name\n\n          When called without an argument, `recurse` is equivalent to\n          `recurse(.[]?)`.\n\n          `recurse(f)` is identical to `recurse(f; true)` and can be\n          used without concerns about recursion depth.\n\n          `recurse(f; condition)` is a generator which begins by\n          emitting . and then emits in turn .|f, .|f|f, .|f|f|f, ...  so long\n          as the computed value satisfies the condition. For example,\n          to generate all the integers, at least in principle, one\n          could write `recurse(.+1; true)`.\n\n          The recursive calls in `recurse` will not consume additional\n          memory whenever `f` produces at most a single output for each\n          input.\n\n        examples:\n          - program: 'recurse(.foo[])'\n            input: '{\"foo\":[{\"foo\": []}, {\"foo\":[{\"foo\":[]}]}]}'\n            output:\n              - '{\"foo\":[{\"foo\":[]},{\"foo\":[{\"foo\":[]}]}]}'\n              - '{\"foo\":[]}'\n              - '{\"foo\":[{\"foo\":[]}]}'\n              - '{\"foo\":[]}'\n\n          - program: 'recurse'\n            input: '{\"a\":0,\"b\":[1]}'\n            output:\n              - '{\"a\":0,\"b\":[1]}'\n              - '0'\n              - '[1]'\n              - '1'\n\n          - program: 'recurse(. * .; . < 20)'\n            input: '2'\n            output: ['2', '4', '16']\n\n      - title: \"`walk(f)`\"\n        body: |\n\n          The `walk(f)` function applies f recursively to every\n          component of the input entity.  When an array is\n          encountered, f is first applied to its elements and then to\n          the array itself; when an object is encountered, f is first\n          applied to all the values and then to the object.  In\n          practice, f will usually test the type of its input, as\n          illustrated in the following examples.  The first example\n          highlights the usefulness of processing the elements of an\n          array of arrays before processing the array itself.  The second\n          example shows how all the keys of all the objects within the\n          input can be considered for alteration.\n\n        examples:\n          - program: 'walk(if type == \"array\" then sort else . end)'\n            input: '[[4, 1, 7], [8, 5, 2], [3, 6, 9]]'\n            output:\n              - '[[1,4,7],[2,5,8],[3,6,9]]'\n\n          - program: 'walk( if type == \"object\" then with_entries( .key |= sub( \"^_+\"; \"\") ) else . end )'\n            input: '[ { \"_a\": { \"__b\": 2 } } ]'\n            output:\n              - '[{\"a\":{\"b\":2}}]'\n\n      - title: \"`have_literal_numbers`\"\n        body: |\n\n          This builtin returns true if jq's build configuration\n          includes support for preservation of input number literals.\n\n      - title: \"`have_decnum`\"\n        body: |\n\n          This builtin returns true if jq was built with \"decnum\",\n          which is the current literal number preserving numeric\n          backend implementation for jq.\n\n      - title: \"`$JQ_BUILD_CONFIGURATION`\"\n        body: |\n\n          This builtin binding shows the jq executable's build\n          configuration.  Its value has no particular format, but\n          it can be expected to be at least the `./configure`\n          command-line arguments, and may be enriched in the\n          future to include the version strings for the build\n          tooling used.\n\n          Note that this can be overridden in the command-line\n          with `--arg` and related options.\n\n      - title: \"`$ENV`, `env`\"\n        body: |\n\n          `$ENV` is an object representing the environment variables as\n          set when the jq program started.\n\n          `env` outputs an object representing jq's current environment.\n\n          At the moment there is no builtin for setting environment\n          variables.\n\n        examples:\n          - program: '$ENV.PAGER'\n            input: 'null'\n            output: ['\"less\"']\n\n          - program: 'env.PAGER'\n            input: 'null'\n            output: ['\"less\"']\n\n      - title: \"`transpose`\"\n        body: |\n\n          Transpose a possibly jagged matrix (an array of arrays).\n          Rows are padded with nulls so the result is always rectangular.\n\n        examples:\n          - program: 'transpose'\n            input: '[[1], [2,3]]'\n            output: ['[[1,2],[null,3]]']\n\n      - title: \"`bsearch(x)`\"\n        body: |\n\n          `bsearch(x)` conducts a binary search for x in the input\n          array.  If the input is sorted and contains x, then\n          `bsearch(x)` will return its index in the array; otherwise, if\n          the array is sorted, it will return (-1 - ix) where ix is an\n          insertion point such that the array would still be sorted\n          after the insertion of x at ix.  If the array is not sorted,\n          `bsearch(x)` will return an integer that is probably of no\n          interest.\n\n        examples:\n          - program: 'bsearch(0)'\n            input: '[0,1]'\n            output: ['0']\n          - program: 'bsearch(0)'\n            input: '[1,2,3]'\n            output: ['-1']\n          - program: 'bsearch(4) as $ix | if $ix < 0 then .[-(1+$ix)] = 4 else . end'\n            input: '[1,2,3]'\n            output: ['[1,2,3,4]']\n\n      - title: \"String interpolation: `\\\\(exp)`\"\n        body: |\n\n          Inside a string, you can put an expression inside parens\n          after a backslash. Whatever the expression returns will be\n          interpolated into the string.\n\n        examples:\n          - program: '\"The input was \\(.), which is one less than \\(.+1)\"'\n            input: '42'\n            output: ['\"The input was 42, which is one less than 43\"']\n\n      - title: \"Convert to/from JSON\"\n        body: |\n\n          The `tojson` and `fromjson` builtins dump values as JSON texts\n          or parse JSON texts into values, respectively.  The `tojson`\n          builtin differs from `tostring` in that `tostring` returns strings\n          unmodified, while `tojson` encodes strings as JSON strings.\n\n        examples:\n          - program: '[.[]|tostring]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"foo\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[\"1\",\"\\\"foo\\\"\",\"[\\\"foo\\\"]\"]']\n          - program: '[.[]|tojson|fromjson]'\n            input: '[1, \"foo\", [\"foo\"]]'\n            output: ['[1,\"foo\",[\"foo\"]]']\n\n      - title: \"Format strings and escaping\"\n        body: |\n\n          The `@foo` syntax is used to format and escape strings,\n          which is useful for building URLs, documents in a language\n          like HTML or XML, and so forth. `@foo` can be used as a\n          filter on its own, the possible escapings are:\n\n          * `@text`:\n\n            Calls `tostring`, see that function for details.\n\n          * `@json`:\n\n            Serializes the input as JSON.\n\n          * `@html`:\n\n            Applies HTML/XML escaping, by mapping the characters\n            `<>&'\"` to their entity equivalents `&lt;`, `&gt;`,\n            `&amp;`, `&apos;`, `&quot;`.\n\n          * `@uri`:\n\n            Applies percent-encoding, by mapping all reserved URI\n            characters to a `%XX` sequence.\n\n          * `@urid`:\n\n            The inverse of `@uri`, applies percent-decoding, by mapping\n            all `%XX` sequences to their corresponding URI characters.\n\n          * `@csv`:\n\n            The input must be an array, and it is rendered as CSV\n            with double quotes for strings, and quotes escaped by\n            repetition.\n\n          * `@tsv`:\n\n            The input must be an array, and it is rendered as TSV\n            (tab-separated values). Each input array will be printed as\n            a single line. Fields are separated by a single\n            tab (ascii `0x09`). Input characters line-feed (ascii `0x0a`),\n            carriage-return (ascii `0x0d`), tab (ascii `0x09`) and\n            backslash (ascii `0x5c`) will be output as escape sequences\n            `\\n`, `\\r`, `\\t`, `\\\\` respectively.\n\n          * `@sh`:\n\n            The input is escaped suitable for use in a command-line\n            for a POSIX shell. If the input is an array, the output\n            will be a series of space-separated strings.\n\n          * `@base64`:\n\n            The input is converted to base64 as specified by RFC 4648.\n\n          * `@base64d`:\n\n            The inverse of `@base64`, input is decoded as specified by RFC 4648.\n            Note\\: If the decoded string is not UTF-8, the results are undefined.\n\n          This syntax can be combined with string interpolation in a\n          useful way. You can follow a `@foo` token with a string\n          literal. The contents of the string literal will *not* be\n          escaped. However, all interpolations made inside that string\n          literal will be escaped. For instance,\n\n              @uri \"https://www.google.com/search?q=\\(.search)\"\n\n          will produce the following output for the input\n          `{\"search\":\"what is jq?\"}`:\n\n              \"https://www.google.com/search?q=what%20is%20jq%3F\"\n\n          Note that the slashes, question mark, etc. in the URL are\n          not escaped, as they were part of the string literal.\n\n        examples:\n          - program: '@html'\n            input: '\"This works if x < y\"'\n            output: ['\"This works if x &lt; y\"']\n\n          - program: '@sh \"echo \\(.)\"'\n            input: \"\\\"O'Hara's Ale\\\"\"\n            output: [\"\\\"echo 'O'\\\\\\\\''Hara'\\\\\\\\''s Ale'\\\"\"]\n\n          - program: '@base64'\n            input: '\"This is a message\"'\n            output: ['\"VGhpcyBpcyBhIG1lc3NhZ2U=\"']\n\n          - program: '@base64d'\n            input: '\"VGhpcyBpcyBhIG1lc3NhZ2U=\"'\n            output: ['\"This is a message\"']\n\n      - title: \"Dates\"\n        body: |\n\n          jq provides some basic date handling functionality, with some\n          high-level and low-level builtins.  In all cases these\n          builtins deal exclusively with time in UTC.\n\n          The `fromdateiso8601` builtin parses datetimes in the ISO 8601\n          format to a number of seconds since the Unix epoch\n          (1970-01-01T00:00:00Z).  The `todateiso8601` builtin does the\n          inverse.\n\n          The `fromdate` builtin parses datetime strings.  Currently\n          `fromdate` only supports ISO 8601 datetime strings, but in the\n          future it will attempt to parse datetime strings in more\n          formats.\n\n          The `todate` builtin is an alias for `todateiso8601`.\n\n          The `now` builtin outputs the current time, in seconds since\n          the Unix epoch.\n\n          Low-level jq interfaces to the C-library time functions are\n          also provided: `strptime`, `strftime`, `strflocaltime`,\n          `mktime`, `gmtime`, and `localtime`.  Refer to your host\n          operating system's documentation for the format strings used\n          by `strptime` and `strftime`.  Note: these are not necessarily\n          stable interfaces in jq, particularly as to their localization\n          functionality.\n\n          The `gmtime` builtin consumes a number of seconds since the\n          Unix epoch and outputs a \"broken down time\" representation of\n          Greenwich Mean Time as an array of numbers representing\n          (in this order): the year, the month (zero-based), the day of\n          the month (one-based), the hour of the day, the minute of the\n          hour, the second of the minute, the day of the week, and the\n          day of the year -- all one-based unless otherwise stated.  The\n          day of the week number may be wrong on some systems for dates\n          before March 1st 1900, or after December 31 2099.\n\n          The `localtime` builtin works like the `gmtime` builtin, but\n          using the local timezone setting.\n\n          The `mktime` builtin consumes \"broken down time\"\n          representations of time output by `gmtime` and `strptime`.\n\n          The `strptime(fmt)` builtin parses input strings matching the\n          `fmt` argument.  The output is in the \"broken down time\"\n          representation consumed by `mktime` and output by `gmtime`.\n\n          The `strftime(fmt)` builtin formats a time (GMT) with the\n          given format.  The `strflocaltime` does the same, but using\n          the local timezone setting.\n\n          The format strings for `strptime` and `strftime` are described\n          in typical C library documentation.  The format string for ISO\n          8601 datetime is `\"%Y-%m-%dT%H:%M:%SZ\"`.\n\n          jq may not support some or all of this date functionality on\n          some systems. In particular, the `%u` and `%j` specifiers for\n          `strptime(fmt)` are not supported on macOS.\n\n        examples:\n          - program: 'fromdate'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['1425599507']\n\n          - program: 'strptime(\"%Y-%m-%dT%H:%M:%SZ\")'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['[2015,2,5,23,51,47,4,63]']\n\n          - program: 'strptime(\"%Y-%m-%dT%H:%M:%SZ\")|mktime'\n            input: '\"2015-03-05T23:51:47Z\"'\n            output: ['1425599507']\n\n      - title: \"SQL-Style Operators\"\n        body: |\n\n          jq provides a few SQL-style operators.\n\n          * `INDEX(stream; index_expression)`:\n\n            This builtin produces an object whose keys are computed by\n            the given index expression applied to each value from the\n            given stream.\n\n          * `JOIN($idx; stream; idx_expr; join_expr)`:\n\n            This builtin joins the values from the given stream to the\n            given index.  The index's keys are computed by applying the\n            given index expression to each value from the given stream.\n            An array of the value in the stream and the corresponding\n            value from the index is fed to the given join expression to\n            produce each result.\n\n          * `JOIN($idx; stream; idx_expr)`:\n\n            Same as `JOIN($idx; stream; idx_expr; .)`.\n\n          * `JOIN($idx; idx_expr)`:\n\n            This builtin joins the input `.` to the given index, applying\n            the given index expression to `.` to compute the index key.\n            The join operation is as described above.\n\n          * `IN(s)`:\n\n            This builtin outputs `true` if `.` appears in the given\n            stream, otherwise it outputs `false`.\n\n          * `IN(source; s)`:\n\n            This builtin outputs `true` if any value in the source stream\n            appears in the second stream, otherwise it outputs `false`.\n\n      - title: \"`builtins`\"\n        body: |\n\n          Returns a list of all builtin functions in the format `name/arity`.\n          Since functions with the same name but different arities are considered\n          separate functions, `all/0`, `all/1`, and `all/2` would all be present\n          in the list.\n\n  - title: Conditionals and Comparisons\n    entries:\n      - title: \"`==`, `!=`\"\n        body: |\n\n          The expression 'a == b' will produce 'true' if the results of evaluating\n          a and b are equal (that is, if they represent equivalent JSON values) and\n          'false' otherwise. In particular, strings are never considered equal\n          to numbers.  In checking for the equality of JSON objects, the ordering of keys\n          is irrelevant.  If you're coming from JavaScript, please note that jq's `==` is like\n          JavaScript's `===`, the \"strict equality\" operator.\n\n          != is \"not equal\", and 'a != b' returns the opposite value of 'a == b'\n\n        examples:\n          - program: '. == false'\n            input: 'null'\n            output: ['false']\n\n          - program: '. == {\"b\": {\"d\": (4 + 1e-20), \"c\": 3}, \"a\":1}'\n            input: '{\"a\":1, \"b\": {\"c\": 3, \"d\": 4}}'\n            output: ['true']\n\n          - program: '.[] == 1'\n            input: '[1, 1.0, \"1\", \"banana\"]'\n            output: ['true', 'true', 'false', 'false']\n\n      - title: if-then-else-end\n        body: |\n\n          `if A then B else C end` will act the same as `B` if `A`\n          produces a value other than false or null, but act the same\n          as `C` otherwise.\n\n          `if A then B end` is the same as `if A then B else .  end`.\n          That is, the `else` branch is optional, and if absent is the\n          same as `.`. This also applies to `elif` with absent ending `else` branch.\n\n          Checking for false or null is a simpler notion of\n          \"truthiness\" than is found in JavaScript or Python, but it\n          means that you'll sometimes have to be more explicit about\n          the condition you want.  You can't test whether, e.g. a\n          string is empty using `if .name then A else B end`; you'll\n          need something like `if .name == \"\" then A else B end` instead.\n\n          If the condition `A` produces multiple results, then `B` is evaluated\n          once for each result that is not false or null, and `C` is evaluated\n          once for each false or null.\n\n          More cases can be added to an if using `elif A then B` syntax.\n\n        examples:\n          - program: |-\n              if . == 0 then\n                \"zero\"\n              elif . == 1 then\n                \"one\"\n              else\n                \"many\"\n              end\n            input: '2'\n            output: ['\"many\"']\n\n      - title: \"`>`, `>=`, `<=`, `<`\"\n        body: |\n\n          The comparison operators `>`, `>=`, `<=`, `<` return whether\n          their left argument is greater than, greater than or equal\n          to, less than or equal to or less than their right argument\n          (respectively).\n\n          The ordering is the same as that described for `sort`, above.\n\n        examples:\n          - program: '. < 5'\n            input: '2'\n            output: ['true']\n\n      - title: \"`and`, `or`, `not`\"\n        body: |\n\n          jq supports the normal Boolean operators `and`, `or`, `not`.\n          They have the same standard of truth as if expressions -\n          `false` and `null` are considered \"false values\", and\n          anything else is a \"true value\".\n\n          If an operand of one of these operators produces multiple\n          results, the operator itself will produce a result for each input.\n\n          `not` is in fact a builtin function rather than an operator,\n          so it is called as a filter to which things can be piped\n          rather than with special syntax, as in `.foo and .bar |\n          not`.\n\n          These three only produce the values `true` and `false`, and\n          so are only useful for genuine Boolean operations, rather\n          than the common Perl/Python/Ruby idiom of\n          \"value_that_may_be_null or default\". If you want to use this\n          form of \"or\", picking between two values rather than\n          evaluating a condition, see the `//` operator below.\n\n        examples:\n          - program: '42 and \"a string\"'\n            input: 'null'\n            output: ['true']\n          - program: '(true, false) or false'\n            input: 'null'\n            output: ['true', 'false']\n          - program: '(true, true) and (true, false)'\n            input: 'null'\n            output: ['true', 'false', 'true', 'false']\n          - program: '[true, false | not]'\n            input: 'null'\n            output: ['[false, true]']\n\n      - title: \"Alternative operator: `//`\"\n        body: |\n\n          The `//` operator produces all the values of its left-hand\n          side that are neither `false` nor `null`. If the\n          left-hand side produces no values other than `false` or\n          `null`, then `//` produces all the values of its right-hand\n          side.\n\n          A filter of the form `a // b` produces all the results of\n          `a` that are not `false` or `null`.  If `a` produces no\n          results, or no results other than `false` or `null`, then `a\n          // b` produces the results of `b`.\n\n          This is useful for providing defaults: `.foo // 1` will\n          evaluate to `1` if there's no `.foo` element in the\n          input. It's similar to how `or` is sometimes used in Python\n          (jq's `or` operator is reserved for strictly Boolean\n          operations).\n\n          Note: `some_generator // defaults_here` is not the same\n          as `some_generator | . // defaults_here`.  The latter will\n          produce default values for all non-`false`, non-`null`\n          values of the left-hand side, while the former will not.\n          Precedence rules can make this confusing.  For example, in\n          `false, 1 // 2` the left-hand side of `//` is `1`, not\n          `false, 1` -- `false, 1 // 2` parses the same way as `false,\n          (1 // 2)`.  In `(false, null, 1) | . // 42` the left-hand\n          side of `//` is `.`, which always produces just one value,\n          while in `(false, null, 1) // 42` the left-hand side is a\n          generator of three values, and since it produces a\n          value other `false` and `null`, the default `42` is not\n          produced.\n\n        examples:\n          - program: 'empty // 42'\n            input: 'null'\n            output: ['42']\n          - program: '.foo // 42'\n            input: '{\"foo\": 19}'\n            output: ['19']\n          - program: '.foo // 42'\n            input: '{}'\n            output: ['42']\n          - program: '(false, null, 1) // 42'\n            input: 'null'\n            output: ['1']\n          - program: '(false, null, 1) | . // 42'\n            input: 'null'\n            output: ['42', '42', '1']\n\n      - title: try-catch\n        body: |\n\n          Errors can be caught by using `try EXP catch EXP`.  The first\n          expression is executed, and if it fails then the second is\n          executed with the error message.  The output of the handler,\n          if any, is output as if it had been the output of the\n          expression to try.\n\n          The `try EXP` form uses `empty` as the exception handler.\n\n        examples:\n          - program: 'try .a catch \". is not an object\"'\n            input: 'true'\n            output: ['\". is not an object\"']\n          - program: '[.[]|try .a]'\n            input: '[{}, true, {\"a\":1}]'\n            output: ['[null, 1]']\n          - program: 'try error(\"some exception\") catch .'\n            input: 'true'\n            output: ['\"some exception\"']\n\n      - title: Breaking out of control structures\n        body: |\n\n          A convenient use of try/catch is to break out of control\n          structures like `reduce`, `foreach`, `while`, and so on.\n\n          For example:\n\n              # Repeat an expression until it raises \"break\" as an\n              # error, then stop repeating without re-raising the error.\n              # But if the error caught is not \"break\" then re-raise it.\n              try repeat(exp) catch if .==\"break\" then empty else error\n\n          jq has a syntax for named lexical labels to \"break\" or \"go (back) to\":\n\n              label $out | ... break $out ...\n\n          The `break $label_name` expression will cause the program to\n          act as though the nearest (to the left) `label $label_name`\n          produced `empty`.\n\n          The relationship between the `break` and corresponding `label`\n          is lexical: the label has to be \"visible\" from the break.\n\n          To break out of a `reduce`, for example:\n\n              label $out | reduce .[] as $item (null; if .==false then break $out else ... end)\n\n          The following jq program produces a syntax error:\n\n              break $out\n\n          because no label `$out` is visible.\n\n      - title: \"Error Suppression / Optional Operator: `?`\"\n        body: |\n\n          The `?` operator, used as `EXP?`, is shorthand for `try EXP`.\n\n        examples:\n          - program: '[.[] | .a?]'\n            input: '[{}, true, {\"a\":1}]'\n            output: ['[null, 1]']\n          - program: '[.[] | tonumber?]'\n            input: '[\"1\", \"invalid\", \"3\", 4]'\n            output: ['[1, 3, 4]']\n\n  - title: Regular expressions\n    body: |\n\n      jq uses the\n      [Oniguruma regular expression library](https://github.com/kkos/oniguruma/blob/master/doc/RE),\n      as do PHP, TextMate, Sublime Text, etc, so the\n      description here will focus on jq specifics.\n\n      Oniguruma supports several flavors of regular expression, so it is important to know\n      that jq uses the [\"Perl NG\" (Perl with named groups)](https://github.com/kkos/oniguruma/blob/master/doc/SYNTAX.md) flavor.\n\n      The jq regex filters are defined so that they can be used using\n      one of these patterns:\n\n          STRING | FILTER(REGEX)\n          STRING | FILTER(REGEX; FLAGS)\n          STRING | FILTER([REGEX])\n          STRING | FILTER([REGEX, FLAGS])\n\n      where:\n\n      * STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;\n      * REGEX, after string interpolation, should be a valid regular expression;\n      * FILTER is one of `test`, `match`, or `capture`, as described below.\n\n      Since REGEX must evaluate to a JSON string, some characters that are needed\n      to form a regular expression must be escaped. For example, the regular expression\n      `\\s` signifying a whitespace character would be written as `\"\\\\s\"`.\n\n      FLAGS is a string consisting of one of more of the supported flags:\n\n      * `g` - Global search (find all matches, not just the first)\n      * `i` - Case insensitive search\n      * `m` - Multi line mode (`.` will match newlines)\n      * `n` - Ignore empty matches\n      * `p` - Both s and m modes are enabled\n      * `s` - Single line mode (`^` -> `\\A`, `$` -> `\\Z`)\n      * `l` - Find longest possible matches\n      * `x` - Extended regex format (ignore whitespace and comments)\n\n      To match a whitespace with the `x` flag, use `\\s`, e.g.\n\n          jq -n '\"a b\" | test(\"a\\\\sb\"; \"x\")'\n\n      Note that certain flags may also be specified within REGEX, e.g.\n\n          jq -n '(\"test\", \"TEst\", \"teST\", \"TEST\") | test(\"(?i)te(?-i)st\")'\n\n      evaluates to: `true`, `true`, `false`, `false`.\n\n    entries:\n      - title: \"`test(val)`, `test(regex; flags)`\"\n        body: |\n\n          Like `match`, but does not return match objects, only `true` or `false`\n          for whether or not the regex matches the input.\n\n        examples:\n          - program: 'test(\"foo\")'\n            input: '\"foo\"'\n            output: ['true']\n          - program: '.[] | test(\"a b c # spaces are ignored\"; \"ix\")'\n            input: '[\"xabcd\", \"ABC\"]'\n            output: ['true', 'true']\n\n      - title: \"`match(val)`, `match(regex; flags)`\"\n        body: |\n\n          **match** outputs an object for each match it finds.  Matches have\n          the following fields:\n\n          * `offset` - offset in UTF-8 codepoints from the beginning of the input\n          * `length` - length in UTF-8 codepoints of the match\n          * `string` - the string that it matched\n          * `captures` - an array of objects representing capturing groups.\n\n          Capturing group objects have the following fields:\n\n          * `offset` - offset in UTF-8 codepoints from the beginning of the input\n          * `length` - length in UTF-8 codepoints of this capturing group\n          * `string` - the string that was captured\n          * `name` - the name of the capturing group (or `null` if it was unnamed)\n\n          Capturing groups that did not match anything return an offset of -1\n\n        examples:\n          - program: 'match(\"(abc)+\"; \"g\")'\n            input: '\"abc abc\"'\n            output:\n             - '{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"name\": null}]}'\n             - '{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"name\": null}]}'\n          - program: 'match(\"foo\")'\n            input: '\"foo bar foo\"'\n            output: ['{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}']\n          - program: 'match([\"foo\", \"ig\"])'\n            input: '\"foo bar FOO\"'\n            output:\n             - '{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}'\n             - '{\"offset\": 8, \"length\": 3, \"string\": \"FOO\", \"captures\": []}'\n          - program: 'match(\"foo (?<bar123>bar)? foo\"; \"ig\")'\n            input: '\"foo bar foo foo  foo\"'\n            output:\n             - '{\"offset\": 0, \"length\": 11, \"string\": \"foo bar foo\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"bar\", \"name\": \"bar123\"}]}'\n             - '{\"offset\": 12, \"length\": 8, \"string\": \"foo  foo\", \"captures\": [{\"offset\": -1, \"length\": 0, \"string\": null, \"name\": \"bar123\"}]}'\n\n          - program: '[ match(\".\"; \"g\")] | length'\n            input: '\"abc\"'\n            output: ['3']\n\n\n      - title: \"`capture(val)`, `capture(regex; flags)`\"\n        body: |\n\n         Collects the named captures in a JSON object, with the name\n         of each capture as the key, and the matched string as the\n         corresponding value.\n\n        examples:\n          - program: 'capture(\"(?<a>[a-z]+)-(?<n>[0-9]+)\")'\n            input: '\"xyzzy-14\"'\n            output: ['{ \"a\": \"xyzzy\", \"n\": \"14\" }']\n\n      - title: \"`scan(regex)`, `scan(regex; flags)`\"\n        body: |\n\n          Emit a stream of the non-overlapping substrings of the input\n          that match the regex in accordance with the flags, if any\n          have been specified.  If there is no match, the stream is empty.\n          To capture all the matches for each input string, use the idiom\n          `[ expr ]`, e.g. `[ scan(regex) ]`.  If the regex contains capturing\n          groups, the filter emits a stream of arrays, each of which contains\n          the captured strings.\n\n        examples:\n          - program: 'scan(\"c\")'\n            input: '\"abcdefabc\"'\n            output: ['\"c\"', '\"c\"']\n          - program: 'scan(\"(a+)(b+)\")'\n            input: '\"abaabbaaabbb\"'\n            output: ['[\"a\",\"b\"]', '[\"aa\",\"bb\"]', '[\"aaa\",\"bbb\"]']\n\n      - title: \"`split(regex; flags)`\"\n        body: |\n\n          Splits an input string on each regex match.\n\n          For backwards compatibility, when called with a single argument,\n          `split` splits on a string, not a regex.\n\n        examples:\n          - program: 'split(\", *\"; null)'\n            input: '\"ab,cd, ef\"'\n            output: ['[\"ab\",\"cd\",\"ef\"]']\n\n\n      - title: \"`splits(regex)`, `splits(regex; flags)`\"\n        body: |\n\n          These provide the same results as their `split` counterparts,\n          but as a stream instead of an array.\n\n        examples:\n          - program: 'splits(\", *\")'\n            input: '\"ab,cd,   ef, gh\"'\n            output: ['\"ab\"','\"cd\"','\"ef\"','\"gh\"']\n          - program: 'splits(\",? *\"; \"n\")'\n            input: '\"ab,cd ef,  gh\"'\n            output: ['\"ab\"','\"cd\"','\"ef\"','\"gh\"']\n\n      - title: \"`sub(regex; tostring)`, `sub(regex; tostring; flags)`\"\n        body: |\n\n          Emit the string obtained by replacing the first match of\n          regex in the input string with `tostring`, after\n          interpolation.  `tostring` should be a jq string or a stream\n          of such strings, each of which may contain references to\n          named captures. The named captures are, in effect, presented\n          as a JSON object (as constructed by `capture`) to\n          `tostring`, so a reference to a captured variable named \"x\"\n          would take the form: `\"\\(.x)\"`.\n\n        examples:\n          - program: 'sub(\"[^a-z]*(?<x>[a-z]+)\"; \"Z\\(.x)\"; \"g\")'\n            input: '\"123abc456def\"'\n            output: ['\"ZabcZdef\"']\n\n          - program: '[sub(\"(?<a>.)\"; \"\\(.a|ascii_upcase)\", \"\\(.a|ascii_downcase)\")]'\n            input: '\"aB\"'\n            output: ['[\"AB\",\"aB\"]']\n\n      - title: \"`gsub(regex; tostring)`, `gsub(regex; tostring; flags)`\"\n        body: |\n\n          `gsub` is like `sub` but all the non-overlapping occurrences of the regex are\n          replaced by `tostring`, after interpolation. If the second argument is a stream\n          of jq strings, then `gsub` will produce a corresponding stream of JSON strings.\n\n        examples:\n          - program: 'gsub(\"(?<x>.)[^a]*\"; \"+\\(.x)-\")'\n            input: '\"Abcabc\"'\n            output: ['\"+A-+a-\"']\n\n          - program: '[gsub(\"p\"; \"a\", \"b\")]'\n            input: '\"p\"'\n            output: ['[\"a\",\"b\"]']\n\n\n  - title: Advanced features\n    body: |\n      Variables are an absolute necessity in most programming languages, but\n      they're relegated to an \"advanced feature\" in jq.\n\n      In most languages, variables are the only means of passing around\n      data. If you calculate a value, and you want to use it more than once,\n      you'll need to store it in a variable. To pass a value to another part\n      of the program, you'll need that part of the program to define a\n      variable (as a function parameter, object member, or whatever) in\n      which to place the data.\n\n      It is also possible to define functions in jq, although this is\n      is a feature whose biggest use is defining jq's standard library\n      (many jq functions such as `map` and `select` are in fact written\n      in jq).\n\n      jq has reduction operators, which are very powerful but a bit\n      tricky.  Again, these are mostly used internally, to define some\n      useful bits of jq's standard library.\n\n      It may not be obvious at first, but jq is all about generators\n      (yes, as often found in other languages).  Some utilities are\n      provided to help deal with generators.\n\n      Some minimal I/O support (besides reading JSON from standard\n      input, and writing JSON to standard output) is available.\n\n      Finally, there is a module/library system.\n\n    entries:\n      - title: \"Variable / Symbolic Binding Operator: `... as $identifier | ...`\"\n        body: |\n\n          In jq, all filters have an input and an output, so manual\n          plumbing is not necessary to pass a value from one part of a program\n          to the next. Many expressions, for instance `a + b`, pass their input\n          to two distinct subexpressions (here `a` and `b` are both passed the\n          same input), so variables aren't usually necessary in order to use a\n          value twice.\n\n          For instance, calculating the average value of an array of numbers\n          requires a few variables in most languages - at least one to hold the\n          array, perhaps one for each element or for a loop counter. In jq, it's\n          simply `add / length` - the `add` expression is given the array and\n          produces its sum, and the `length` expression is given the array and\n          produces its length.\n\n          So, there's generally a cleaner way to solve most problems in jq than\n          defining variables. Still, sometimes they do make things easier, so jq\n          lets you define variables using `expression as $variable`. All\n          variable names start with `$`. Here's a slightly uglier version of the\n          array-averaging example:\n\n              length as $array_length | add / $array_length\n\n          We'll need a more complicated problem to find a situation where using\n          variables actually makes our lives easier.\n\n\n          Suppose we have an array of blog posts, with \"author\" and \"title\"\n          fields, and another object which is used to map author usernames to\n          real names. Our input looks like:\n\n              {\"posts\": [{\"title\": \"First post\", \"author\": \"anon\"},\n                         {\"title\": \"A well-written article\", \"author\": \"person1\"}],\n               \"realnames\": {\"anon\": \"Anonymous Coward\",\n                             \"person1\": \"Person McPherson\"}}\n\n          We want to produce the posts with the author field containing a real\n          name, as in:\n\n              {\"title\": \"First post\", \"author\": \"Anonymous Coward\"}\n              {\"title\": \"A well-written article\", \"author\": \"Person McPherson\"}\n\n          We use a variable, `$names`, to store the realnames object, so that we\n          can refer to it later when looking up author usernames:\n\n              .realnames as $names | .posts[] | {title, author: $names[.author]}\n\n          The expression `exp as $x | ...` means: for each value of expression\n          `exp`, run the rest of the pipeline with the entire original input, and\n          with `$x` set to that value.  Thus `as` functions as something of a\n          foreach loop.\n\n          Just as `{foo}` is a handy way of writing `{foo: .foo}`, so\n          `{$foo}` is a handy way of writing `{foo: $foo}`.\n\n          Multiple variables may be declared using a single `as` expression by\n          providing a pattern that matches the structure of the input\n          (this is known as \"destructuring\"):\n\n              . as {realnames: $names, posts: [$first, $second]} | ...\n\n          The variable declarations in array patterns (e.g., `. as\n          [$first, $second]`) bind to the elements of the array in from\n          the element at index zero on up, in order.  When there is no\n          value at the index for an array pattern element, `null` is\n          bound to that variable.\n\n          Variables are scoped over the rest of the expression that defines\n          them, so\n\n              .realnames as $names | (.posts[] | {title, author: $names[.author]})\n\n          will work, but\n\n              (.realnames as $names | .posts[]) | {title, author: $names[.author]}\n\n          won't.\n\n          For programming language theorists, it's more accurate to\n          say that jq variables are lexically-scoped bindings.  In\n          particular there's no way to change the value of a binding;\n          one can only setup a new binding with the same name, but which\n          will not be visible where the old one was.\n\n        examples:\n          - program: '.bar as $x | .foo | . + $x'\n            input: '{\"foo\":10, \"bar\":200}'\n            output: ['210']\n          - program: '. as $i|[(.*2|. as $i| $i), $i]'\n            input: '5'\n            output: ['[10,5]']\n          - program: '. as [$a, $b, {c: $c}] | $a + $b + $c'\n            input: '[2, 3, {\"c\": 4, \"d\": 5}]'\n            output: ['9']\n          - program: '.[] as [$a, $b] | {a: $a, b: $b}'\n            input: '[[0], [0, 1], [2, 1, 0]]'\n            output: ['{\"a\":0,\"b\":null}', '{\"a\":0,\"b\":1}', '{\"a\":2,\"b\":1}']\n\n      - title: 'Destructuring Alternative Operator: `?//`'\n        body: |\n\n          The destructuring alternative operator provides a concise mechanism\n          for destructuring an input that can take one of several forms.\n\n          Suppose we have an API that returns a list of resources and events\n          associated with them, and we want to get the user_id and timestamp of\n          the first event for each resource. The API (having been clumsily\n          converted from XML) will only wrap the events in an array if the resource\n          has multiple events:\n\n              {\"resources\": [{\"id\": 1, \"kind\": \"widget\", \"events\": {\"action\": \"create\", \"user_id\": 1, \"ts\": 13}},\n                             {\"id\": 2, \"kind\": \"widget\", \"events\": [{\"action\": \"create\", \"user_id\": 1, \"ts\": 14}, {\"action\": \"destroy\", \"user_id\": 1, \"ts\": 15}]}]}\n\n          We can use the destructuring alternative operator to handle this structural change simply:\n\n              .resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}\n\n          Or, if we aren't sure if the input is an array of values or an object:\n\n              .[] as [$id, $kind, $user_id, $ts] ?// {$id, $kind, $user_id, $ts} | ...\n\n          Each alternative need not define all of the same variables, but all named\n          variables will be available to the subsequent expression. Variables not\n          matched in the alternative that succeeded will be `null`:\n\n              .resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$first_user_id, $first_ts}]} | {$user_id, $first_user_id, $kind, $id, $ts, $first_ts}\n\n          Additionally, if the subsequent expression returns an error, the\n          alternative operator will attempt to try the next binding. Errors\n          that occur during the final alternative are passed through.\n\n              [[3]] | .[] as [$a] ?// [$b] | if $a != null then error(\"err: \\($a)\") else {$a,$b} end\n\n        examples:\n          - program: '.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}'\n            input: '[{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]'\n            output: ['{\"a\":1,\"b\":2,\"d\":3,\"e\":4}', '{\"a\":1,\"b\":2,\"d\":3,\"e\":4}']\n          - program: '.[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}'\n            input: '[{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]'\n            output: ['{\"a\":1,\"b\":2,\"d\":3,\"e\":null}', '{\"a\":1,\"b\":2,\"d\":null,\"e\":4}']\n          - program: '.[] as [$a] ?// [$b] | if $a != null then error(\"err: \\($a)\") else {$a,$b} end'\n            input: '[[3]]'\n            output: ['{\"a\":null,\"b\":3}']\n\n      - title: 'Defining Functions'\n        body: |\n\n          You can give a filter a name using \"def\" syntax:\n\n              def increment: . + 1;\n\n          From then on, `increment` is usable as a filter just like a\n          builtin function (in fact, this is how many of the builtins\n          are defined). A function may take arguments:\n\n              def map(f): [.[] | f];\n\n          Arguments are passed as _filters_ (functions with no\n          arguments), _not_ as values. The same argument may be\n          referenced multiple times with different inputs (here `f` is\n          run for each element of the input array).  Arguments to a\n          function work more like callbacks than like value arguments.\n          This is important to understand.  Consider:\n\n              def foo(f): f|f;\n              5|foo(.*2)\n\n          The result will be 20 because `f` is `.*2`, and during the\n          first invocation of `f` `.` will be 5, and the second time it\n          will be 10 (5 * 2), so the result will be 20.  Function\n          arguments are filters, and filters expect an input when\n          invoked.\n\n          If you want the value-argument behaviour for defining simple\n          functions, you can just use a variable:\n\n              def addvalue(f): f as $f | map(. + $f);\n\n          Or use the short-hand:\n\n              def addvalue($f): ...;\n\n          With either definition, `addvalue(.foo)` will add the current\n          input's `.foo` field to each element of the array.  Do note\n          that calling `addvalue(.[])` will cause the `map(. + $f)` part\n          to be evaluated once per value in the value of `.` at the call\n          site.\n\n          Multiple definitions using the same function name are allowed.\n          Each re-definition replaces the previous one for the same\n          number of function arguments, but only for references from\n          functions (or main program) subsequent to the re-definition.\n          See also the section below on scoping.\n\n        examples:\n          - program: 'def addvalue(f): . + [f]; map(addvalue(.[0]))'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1], [10,20,10]]']\n          - program: 'def addvalue(f): f as $x | map(. + $x); addvalue(.[0])'\n            input: '[[1,2],[10,20]]'\n            output: ['[[1,2,1,2], [10,20,1,2]]']\n\n      - title: 'Scoping'\n        body: |\n\n          There are two types of symbols in jq: value bindings (a.k.a.,\n          \"variables\"), and functions.  Both are scoped lexically,\n          with expressions being able to refer only to symbols that\n          have been defined \"to the left\" of them.  The only exception\n          to this rule is that functions can refer to themselves so as\n          to be able to create recursive functions.\n\n          For example, in the following expression there is a binding\n          which is visible \"to the right\" of it, `... | .*3 as\n          $times_three | [. + $times_three] | ...`, but not \"to the\n          left\".  Consider this expression now, `... | (.*3 as\n          $times_three | [. + $times_three]) | ...`: here the binding\n          `$times_three` is _not_ visible past the closing parenthesis.\n\n      - title: \"`isempty(exp)`\"\n        body: |\n\n          Returns true if `exp` produces no outputs, false otherwise.\n\n        examples:\n          - program: 'isempty(empty)'\n            input: 'null'\n            output: ['true']\n\n          - program: 'isempty(.[])'\n            input: '[]'\n            output: ['true']\n\n          - program: 'isempty(.[])'\n            input: '[1,2,3]'\n            output: ['false']\n\n      - title: \"`limit(n; expr)`\"\n        body: |\n\n          The `limit` function extracts up to `n` outputs from `expr`.\n\n        examples:\n          - program: '[limit(3; .[])]'\n            input: '[0,1,2,3,4,5,6,7,8,9]'\n            output: ['[0,1,2]']\n\n      - title: \"`skip(n; expr)`\"\n        body: |\n\n          The `skip` function skips the first `n` outputs from `expr`.\n\n        examples:\n          - program: '[skip(3; .[])]'\n            input: '[0,1,2,3,4,5,6,7,8,9]'\n            output: ['[3,4,5,6,7,8,9]']\n\n      - title: \"`first(expr)`, `last(expr)`, `nth(n; expr)`\"\n        body: |\n\n          The `first(expr)` and `last(expr)` functions extract the first\n          and last values from `expr`, respectively.\n\n          The `nth(n; expr)` function extracts the nth value output by `expr`.\n          Note that `nth(n; expr)` doesn't support negative values of `n`.\n\n        examples:\n          - program: '[first(range(.)), last(range(.)), nth(5; range(.))]'\n            input: '10'\n            output: ['[0,9,5]']\n          - program: '[first(empty), last(empty), nth(5; empty)]'\n            input: 'null'\n            output: ['[]']\n\n      - title: \"`first`, `last`, `nth(n)`\"\n        body: |\n\n          The `first` and `last` functions extract the first\n          and last values from any array at `.`.\n\n          The `nth(n)` function extracts the nth value of any array at `.`.\n\n        examples:\n          - program: '[range(.)]|[first, last, nth(5)]'\n            input: '10'\n            output: ['[0,9,5]']\n\n      - title: \"`reduce`\"\n        body: |\n\n          The `reduce` syntax allows you to combine all of the results of\n          an expression by accumulating them into a single answer.\n          The form is `reduce EXP as $var (INIT; UPDATE)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              reduce .[] as $item (0; . + $item)\n\n          For each result that `.[]` produces, `. + $item` is run to\n          accumulate a running total, starting from 0 as the input value.\n          In this example, `.[]` produces the results `1`, `2`, and `3`,\n          so the effect is similar to running something like this:\n\n              0 | 1 as $item | . + $item |\n                  2 as $item | . + $item |\n                  3 as $item | . + $item\n\n        examples:\n          - program: 'reduce .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['15']\n\n          - program: 'reduce .[] as [$i,$j] (0; . + $i * $j)'\n            input: '[[1,2],[3,4],[5,6]]'\n            output: ['44']\n\n          - program: 'reduce .[] as {$x,$y} (null; .x += $x | .y += [$y])'\n            input: '[{\"x\":\"a\",\"y\":1},{\"x\":\"b\",\"y\":2},{\"x\":\"c\",\"y\":3}]'\n            output: ['{\"x\":\"abc\",\"y\":[1,2,3]}']\n\n      - title: \"`foreach`\"\n        body: |\n\n          The `foreach` syntax is similar to `reduce`, but intended to\n          allow the construction of `limit` and reducers that produce\n          intermediate results.\n\n          The form is `foreach EXP as $var (INIT; UPDATE; EXTRACT)`.\n          As an example, we'll pass `[1,2,3]` to this expression:\n\n              foreach .[] as $item (0; . + $item; [$item, . * 2])\n\n          Like the `reduce` syntax, `. + $item` is run for each result\n          that `.[]` produces, but `[$item, . * 2]` is run for each\n          intermediate values. In this example, since the intermediate\n          values are `1`, `3`, and `6`, the `foreach` expression produces\n          `[1,2]`, `[2,6]`, and `[3,12]`. So the effect is similar\n          to running something like this:\n\n              0 | 1 as $item | . + $item | [$item, . * 2],\n                  2 as $item | . + $item | [$item, . * 2],\n                  3 as $item | . + $item | [$item, . * 2]\n\n          When `EXTRACT` is omitted, the identity filter is used.\n          That is, it outputs the intermediate values as they are.\n\n        examples:\n          - program: 'foreach .[] as $item (0; . + $item)'\n            input: '[1,2,3,4,5]'\n            output: ['1','3','6','10','15']\n\n          - program: 'foreach .[] as $item (0; . + $item; [$item, . * 2])'\n            input: '[1,2,3,4,5]'\n            output: ['[1,2]','[2,6]','[3,12]','[4,20]','[5,30]']\n\n          - program: 'foreach .[] as $item (0; . + 1; {index: ., $item})'\n            input: '[\"foo\", \"bar\", \"baz\"]'\n            output:\n              - '{\"index\":1,\"item\":\"foo\"}'\n              - '{\"index\":2,\"item\":\"bar\"}'\n              - '{\"index\":3,\"item\":\"baz\"}'\n\n      - title: Recursion\n        body: |\n\n          As described above, `recurse` uses recursion, and any jq\n          function can be recursive.  The `while` builtin is also\n          implemented in terms of recursion.\n\n          Tail calls are optimized whenever the expression to the left of\n          the recursive call outputs its last value.  In practice this\n          means that the expression to the left of the recursive call\n          should not produce more than one output for each input.\n\n          For example:\n\n              def recurse(f): def r: ., (f | select(. != null) | r); r;\n\n              def while(cond; update):\n                def _while:\n                  if cond then ., (update | _while) else empty end;\n                _while;\n\n              def repeat(exp):\n                def _repeat:\n                  exp, _repeat;\n                _repeat;\n\n      - title: Generators and iterators\n        body: |\n\n            Some jq operators and functions are actually generators in\n            that they can produce zero, one, or more values for each\n            input, just as one might expect in other programming\n            languages that have generators.  For example, `.[]`\n            generates all the values in its input (which must be an\n            array or an object), `range(0; 10)` generates the integers\n            between 0 and 10, and so on.\n\n            Even the comma operator is a generator, generating first\n            the values generated by the expression to the left of the\n            comma, then the values generated by the expression on the\n            right of the comma.\n\n            The `empty` builtin is the generator that produces zero\n            outputs.  The `empty` builtin backtracks to the preceding\n            generator expression.\n\n            All jq functions can be generators just by using builtin\n            generators.  It is also possible to construct new generators\n            using only recursion and the comma operator.  If\n            recursive calls are \"in tail position\" then the\n            generator will be efficient.  In the example below the\n            recursive call by `_range` to itself is in tail position.\n            The example shows off three advanced topics: tail recursion,\n            generator construction, and sub-functions.\n\n        examples:\n          - program: 'def range(init; upto; by):\n                    def _range:\n                        if (by > 0 and . < upto) or (by < 0 and . > upto)\n                        then ., ((.+by)|_range)\n                        else empty end;\n                    if init == upto then empty elif by == 0 then init else init|_range end;\n                range(0; 10; 3)'\n            input: 'null'\n            output: ['0', '3', '6', '9']\n          - program: 'def while(cond; update):\n                    def _while:\n                        if cond then ., (update | _while) else empty end;\n                    _while;\n                [while(.<100; .*2)]'\n            input: '1'\n            output: ['[1,2,4,8,16,32,64]']\n\n  - title: 'Math'\n    body: |\n\n      jq currently only has IEEE754 double-precision (64-bit) floating\n      point number support.\n\n      Besides simple arithmetic operators such as `+`, jq also has most\n      standard math functions from the C math library.  C math functions\n      that take a single input argument (e.g., `sin()`) are available as\n      zero-argument jq functions.  C math functions that take two input\n      arguments (e.g., `pow()`) are available as two-argument jq\n      functions that ignore `.`.  C math functions that take three input\n      arguments are available as three-argument jq functions that ignore\n      `.`.\n\n      Availability of standard math functions depends on the\n      availability of the corresponding math functions in your operating\n      system and C math library.  Unavailable math functions will be\n      defined but will raise an error.\n\n      One-input C math functions: `acos` `acosh` `asin` `asinh` `atan`\n      `atanh` `cbrt` `ceil` `cos` `cosh` `erf` `erfc` `exp` `exp10`\n      `exp2` `expm1` `fabs` `floor` `gamma` `j0` `j1` `lgamma` `log`\n      `log10` `log1p` `log2` `logb` `nearbyint` `rint` `round`\n      `significand` `sin` `sinh` `sqrt` `tan` `tanh` `tgamma` `trunc`\n      `y0` `y1`.\n\n      Two-input C math functions: `atan2` `copysign` `drem` `fdim`\n      `fmax` `fmin` `fmod` `frexp` `hypot` `jn` `ldexp` `modf`\n      `nextafter` `nexttoward` `pow` `remainder` `scalb` `scalbln` `yn`.\n\n      Three-input C math functions: `fma`.\n\n      See your system's manual for more information on each of these.\n\n  - title: 'I/O'\n    body: |\n\n      At this time jq has minimal support for I/O, mostly in the\n      form of control over when inputs are read.  Two builtins functions\n      are provided for this, `input` and `inputs`, that read from the\n      same sources (e.g., `stdin`, files named on the command-line) as\n      jq itself.  These two builtins, and jq's own reading actions, can\n      be interleaved with each other.  They are commonly used in combination\n      with the null input option `-n` to prevent one input from being read\n      implicitly.\n\n      Two builtins provide minimal output capabilities, `debug`, and\n      `stderr`.  (Recall that a jq program's output values are always\n      output as JSON texts on `stdout`.) The `debug` builtin can have\n      application-specific behavior, such as for executables that use\n      the libjq C API but aren't the jq executable itself.  The `stderr`\n      builtin outputs its input in raw mode to stderr with no additional\n      decoration, not even a newline.\n\n      Most jq builtins are referentially transparent, and yield constant\n      and repeatable value streams when applied to constant inputs.\n      This is not true of I/O builtins.\n\n    entries:\n      - title: \"`input`\"\n        body: |\n\n          Outputs one new input.\n\n          Note that when using `input` it is generally necessary to\n          invoke jq with the `-n` command-line option, otherwise\n          the first entity will be lost.\n\n              echo 1 2 3 4 | jq '[., input]' # [1,2] [3,4]\n\n      - title: \"`inputs`\"\n        body: |\n\n          Outputs all remaining inputs, one by one.\n\n          This is primarily useful for reductions over a program's\n          inputs.  Note that when using `inputs` it is generally necessary\n          to invoke jq with the `-n` command-line option, otherwise\n          the first entity will be lost.\n\n              echo 1 2 3 | jq -n 'reduce inputs as $i (0; . + $i)' # 6\n\n      - title: \"`debug`, `debug(msgs)`\"\n        body: |\n\n          These two filters are like `.` but have as a side-effect the\n          production of one or more messages on stderr.\n\n          The message produced by the `debug` filter has the form\n\n              [\"DEBUG:\",<input-value>]\n\n          where `<input-value>` is a compact rendition of the input\n          value.  This format may change in the future.\n\n          The `debug(msgs)` filter is defined as `(msgs | debug | empty), .`\n          thus allowing great flexibility in the content of the message,\n          while also allowing multi-line debugging statements to be created.\n\n          For example, the expression:\n\n              1 as $x | 2 | debug(\"Entering function foo with $x == \\($x)\", .) | (.+1)\n\n          would produce the value 3 but with the following two lines\n          being written to stderr:\n\n              [\"DEBUG:\",\"Entering function foo with $x == 1\"]\n              [\"DEBUG:\",2]\n\n      - title: \"`stderr`\"\n        body: |\n\n          Prints its input in raw and compact mode to stderr with no\n          additional decoration, not even a newline.\n\n      - title: \"`input_filename`\"\n        body: |\n\n          Returns the name of the file whose input is currently being\n          filtered.  Note that this will not work well unless jq is\n          running in a UTF-8 locale.\n\n      - title: \"`input_line_number`\"\n        body: |\n\n          Returns the line number of the input currently being filtered.\n\n  - title: 'Streaming'\n    body: |\n\n      With the `--stream` option jq can parse input texts in a streaming\n      fashion, allowing jq programs to start processing large JSON texts\n      immediately rather than after the parse completes.  If you have a\n      single JSON text that is 1GB in size, streaming it will allow you\n      to process it much more quickly.\n\n      However, streaming isn't easy to deal with as the jq program will\n      have `[<path>, <leaf-value>]` (and a few other forms) as inputs.\n\n      Several builtins are provided to make handling streams easier.\n\n      The examples below use the streamed form of `[\"a\",[\"b\"]]`, which is\n      `[[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]]`.\n\n      Streaming forms include `[<path>, <leaf-value>]` (to indicate any\n      scalar value, empty array, or empty object), and `[<path>]` (to\n      indicate the end of an array or object).  Future versions of jq\n      run with `--stream` and `--seq` may output additional forms such\n      as `[\"error message\"]` when an input text fails to parse.\n\n    entries:\n      - title: \"`truncate_stream(stream_expression)`\"\n        body: |\n\n          Consumes a number as input and truncates the corresponding\n          number of path elements from the left of the outputs of the\n          given streaming expression.\n\n        examples:\n          - program: 'truncate_stream([[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]])'\n            input: '1'\n            output: ['[[0],\"b\"]', '[[0]]']\n\n      - title: \"`fromstream(stream_expression)`\"\n        body: |\n\n          Outputs values corresponding to the stream expression's\n          outputs.\n\n        examples:\n          - program: 'fromstream(1|truncate_stream([[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]]))'\n            input: 'null'\n            output: ['[\"b\"]']\n\n      - title: \"`tostream`\"\n        body: |\n\n          The `tostream` builtin outputs the streamed form of its input.\n\n        examples:\n          - program: '. as $dot|fromstream($dot|tostream)|.==$dot'\n            input: '[0,[1,{\"a\":1},{\"b\":2}]]'\n            output: ['true']\n\n  - title: Assignment\n    body: |\n      Assignment works a little differently in jq than in most\n      programming languages. jq doesn't distinguish between references\n      to and copies of something - two objects or arrays are either\n      equal or not equal, without any further notion of being \"the\n      same object\" or \"not the same object\".\n\n      If an object has two fields which are arrays, `.foo` and `.bar`,\n      and you append something to `.foo`, then `.bar` will not get\n      bigger, even if you've previously set `.bar = .foo`.  If you're\n      used to programming in languages like Python, Java, Ruby,\n      JavaScript, etc. then you can think of it as though jq does a full\n      deep copy of every object before it does the assignment (for\n      performance it doesn't actually do that, but that's the general\n      idea).\n\n      This means that it's impossible to build circular values in jq\n      (such as an array whose first element is itself). This is quite\n      intentional, and ensures that anything a jq program can produce\n      can be represented in JSON.\n\n      All the assignment operators in jq have path expressions on the\n      left-hand side (LHS).  The right-hand side (RHS) provides values\n      to set to the paths named by the LHS path expressions.\n\n      Values in jq are always immutable.  Internally, assignment works\n      by using a reduction to compute new, replacement values for `.` that\n      have had all the desired assignments applied to `.`, then\n      outputting the modified value.  This might be made clear by this\n      example: `{a:{b:{c:1}}} | (.a.b|=3), .`.  This will output\n      `{\"a\":{\"b\":3}}` and `{\"a\":{\"b\":{\"c\":1}}}` because the last\n      sub-expression, `.`, sees the original value, not the modified\n      value.\n\n      Most users will want to use modification assignment operators,\n      such as `|=` or `+=`, rather than `=`.\n\n      Note that the LHS of assignment operators refers to a value in\n      `.`.  Thus `$var.foo = 1` won't work as expected (`$var.foo` is\n      not a valid or useful path expression in `.`); use `$var | .foo =\n      1` instead.\n\n      Note too that `.a,.b=0` does not set `.a` and `.b`, but\n      `(.a,.b)=0` sets both.\n\n    entries:\n      - title: \"Update-assignment: `|=`\"\n        body: |\n          This is the \"update\" operator `|=`.  It takes a filter on the\n          right-hand side and works out the new value for the property\n          of `.` being assigned to by running the old value through this\n          expression. For instance, `(.foo, .bar) |= .+1` will build an\n          object with the `foo` field set to the input's `foo` plus 1,\n          and the `bar` field set to the input's `bar` plus 1.\n\n          The left-hand side can be any general path expression; see `path()`.\n\n          Note that the left-hand side of `|=` refers to a value in `.`.\n          Thus `$var.foo |= . + 1` won't work as expected (`$var.foo` is\n          not a valid or useful path expression in `.`); use `$var |\n          .foo |= . + 1` instead.\n\n          If the right-hand side outputs no values (i.e., `empty`), then\n          the left-hand side path will be deleted, as with `del(path)`.\n\n          If the right-hand side outputs multiple values, only the first\n          one will be used (COMPATIBILITY NOTE: in jq 1.5 and earlier\n          releases, it used to be that only the last one was used).\n\n        examples:\n          - program: '(..|select(type==\"boolean\")) |= if . then 1 else 0 end'\n            input: '[true,false,[5,true,[true,[false]],false]]'\n            output: ['[1,0,[5,1,[1,[0]],0]]']\n\n      - title: \"Arithmetic update-assignment: `+=`, `-=`, `*=`, `/=`, `%=`, `//=`\"\n        body: |\n\n          jq has a few operators of the form `a op= b`, which are all\n          equivalent to `a |= . op b`. So, `+= 1` can be used to\n          increment values, being the same as `|= . + 1`.\n\n        examples:\n          - program: .foo += 1\n            input: '{\"foo\": 42}'\n            output: ['{\"foo\": 43}']\n\n      - title: \"Plain assignment: `=`\"\n        body: |\n\n          This is the plain assignment operator.  Unlike the others, the\n          input to the right-hand side (RHS) is the same as the input to\n          the left-hand side (LHS) rather than the value at the LHS\n          path, and all values output by the RHS will be used (as shown\n          below).\n\n          If the RHS of `=` produces multiple values, then for each such\n          value jq will set the paths on the left-hand side to the value\n          and then it will output the modified `.`.  For example,\n          `(.a,.b) = range(2)` outputs `{\"a\":0,\"b\":0}`, then\n          `{\"a\":1,\"b\":1}`.  The \"update\" assignment forms (see above) do\n          not do this.\n\n          This example should show the difference between `=` and `|=`:\n\n          Provide input `{\"a\": {\"b\": 10}, \"b\": 20}` to the programs\n\n              .a = .b\n\n          and\n\n              .a |= .b\n\n          The former will set the `a` field of the input to the `b`\n          field of the input, and produce the output `{\"a\": 20, \"b\": 20}`.\n          The latter will set the `a` field of the input to the `a`\n          field's `b` field, producing `{\"a\": 10, \"b\": 20}`.\n\n        examples:\n          - program: .a = .b\n            input: '{\"a\": {\"b\": 10}, \"b\": 20}'\n            output: ['{\"a\":20,\"b\":20}']\n\n          - program: .a |= .b\n            input: '{\"a\": {\"b\": 10}, \"b\": 20}'\n            output: ['{\"a\":10,\"b\":20}']\n\n          - program: (.a, .b) = range(3)\n            input: 'null'\n            output:\n              - '{\"a\":0,\"b\":0}'\n              - '{\"a\":1,\"b\":1}'\n              - '{\"a\":2,\"b\":2}'\n\n          - program: (.a, .b) |= range(3)\n            input: 'null'\n            output: ['{\"a\":0,\"b\":0}']\n\n      - title: Complex assignments\n        body: |\n          Lots more things are allowed on the left-hand side of a jq assignment\n          than in most languages. We've already seen simple field accesses on\n          the left hand side, and it's no surprise that array accesses work just\n          as well:\n\n              .posts[0].title = \"JQ Manual\"\n\n          What may come as a surprise is that the expression on the left may\n          produce multiple results, referring to different points in the input\n          document:\n\n              .posts[].comments |= . + [\"this is great\"]\n\n          That example appends the string \"this is great\" to the \"comments\"\n          array of each post in the input (where the input is an object with a\n          field \"posts\" which is an array of posts).\n\n          When jq encounters an assignment like 'a = b', it records the \"path\"\n          taken to select a part of the input document while executing a. This\n          path is then used to find which part of the input to change while\n          executing the assignment. Any filter may be used on the\n          left-hand side of an equals - whichever paths it selects from the\n          input will be where the assignment is performed.\n\n          This is a very powerful operation. Suppose we wanted to add a comment\n          to blog posts, using the same \"blog\" input above. This time, we only\n          want to comment on the posts written by \"stedolan\". We can find those\n          posts using the \"select\" function described earlier:\n\n              .posts[] | select(.author == \"stedolan\")\n\n          The paths provided by this operation point to each of the posts that\n          \"stedolan\" wrote, and we can comment on each of them in the same way\n          that we did before:\n\n              (.posts[] | select(.author == \"stedolan\") | .comments) |=\n                  . + [\"terrible.\"]\n\n  - title: Comments\n\n    body: |\n\n      You can write comments in your jq filters using `#`.\n\n      A `#` character (not part of a string) starts a comment.\n      All characters from `#` to the end of the line are ignored.\n\n      If the end of the line is preceded by an odd number of backslash\n      characters, the following line is also considered part of the\n      comment and is ignored.\n\n      For example, the following code outputs `[1,3,4,7]`\n\n          [\n            1,\n            # foo \\\n            2,\n            # bar \\\\\n            3,\n            4, # baz \\\\\\\n            5, \\\n            6,\n            7\n            # comment \\\n              comment \\\n              comment\n          ]\n\n      Backslash continuing the comment on the next line can be useful\n      when writing the \"shebang\" for a jq script:\n\n          #!/bin/sh --\n          # total - Output the sum of the given arguments (or stdin)\n          # usage: total [numbers...]\n          # \\\n          exec jq --args -MRnf -- \"$0\" \"$@\"\n\n          $ARGS.positional |\n          reduce (\n            if . == []\n              then inputs\n              else .[]\n            end |\n            . as $dot |\n            try tonumber catch false |\n            if not or isnan then\n              @json \"total: Invalid number \\($dot).\\n\" | halt_error(1)\n            end\n          ) as $n (0; . + $n)\n\n      The `exec` line is considered a comment by jq, so it is ignored.\n      But it is not ignored by `sh`, since in `sh` a backslash at the\n      end of the line does not continue the comment.\n      With this trick, when the script is invoked as `total 1 2`,\n      `/bin/sh -- /path/to/total 1 2` will be run, and `sh` will then\n      run `exec jq --args -MRnf -- /path/to/total 1 2` replacing itself\n      with a `jq` interpreter invoked with the specified options (`-M`,\n      `-R`, `-n`, `--args`), that evaluates the current file (`$0`),\n      with the arguments (`$@`) that were passed to `sh`.\n\n  - title: Modules\n    body: |\n\n      jq has a library/module system.  Modules are files whose names end\n      in `.jq`.\n\n      Modules imported by a program are searched for in a default search\n      path (see below).  The `import` and `include` directives allow the\n      importer to alter this path.\n\n      Paths in the search path are subject to various substitutions.\n\n      For paths starting with `~/`, the user's home directory is\n      substituted for `~`.\n\n      For paths starting with `$ORIGIN/`, the directory where the jq\n      executable is located is substituted for `$ORIGIN`.\n\n      For paths starting with `./` or paths that are `.`, the path of\n      the including file is substituted for `.`.  For top-level programs\n      given on the command-line, the current directory is used.\n\n      Import directives can optionally specify a search path to which\n      the default is appended.\n\n      The default search path is the search path given to the `-L`\n      command-line option, else `[\"~/.jq\", \"$ORIGIN/../lib/jq\",\n      \"$ORIGIN/../lib\"]`.\n\n      Null and empty string path elements terminate search path\n      processing.\n\n      A dependency with relative path `foo/bar` would be searched for in\n      `foo/bar.jq` and `foo/bar/bar.jq` in the given search path. This\n      is intended to allow modules to be placed in a directory along\n      with, for example, version control files, README files, and so on,\n      but also to allow for single-file modules.\n\n      Consecutive components with the same name are not allowed to avoid\n      ambiguities (e.g., `foo/foo`).\n\n      For example, with `-L$HOME/.jq` a module `foo` can be found in\n      `$HOME/.jq/foo.jq` and `$HOME/.jq/foo/foo.jq`.\n\n      If `.jq` exists in the user's home directory, and is a file (not a\n      directory), it is automatically sourced into the main program.\n\n    entries:\n      - title: \"`import RelativePathString as NAME [<metadata>];`\"\n        body: |\n\n          Imports a module found at the given path relative to a\n          directory in a search path.  A `.jq` suffix will be added to\n          the relative path string.  The module's symbols are prefixed\n          with `NAME::`.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like `homepage` and so on.  At\n          this time jq only uses the `search` key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n          The `search` key in the metadata, if present, should have a\n          string or array value (array of strings); this is the search\n          path to be prefixed to the top-level search path.\n\n      - title: \"`include RelativePathString [<metadata>];`\"\n        body: |\n\n          Imports a module found at the given path relative to a\n          directory in a search path as if it were included in place.  A\n          `.jq` suffix will be added to the relative path string.  The\n          module's symbols are imported into the caller's namespace as\n          if the module's content had been included directly.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like `homepage` and so on.  At\n          this time jq only uses the `search` key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n      - title: \"`import RelativePathString as $NAME [<metadata>];`\"\n        body: |\n\n          Imports a JSON file found at the given path relative to a\n          directory in a search path.  A `.json` suffix will be added to\n          the relative path string.  The file's data will be available\n          as `$NAME::NAME`.\n\n          The optional metadata must be a constant jq expression.  It\n          should be an object with keys like `homepage` and so on.  At\n          this time jq only uses the `search` key/value of the metadata.\n          The metadata is also made available to users via the\n          `modulemeta` builtin.\n\n          The `search` key in the metadata, if present, should have a\n          string or array value (array of strings); this is the search\n          path to be prefixed to the top-level search path.\n\n      - title: \"`module <metadata>;`\"\n        body: |\n\n          This directive is entirely optional.  It's not required for\n          proper operation.  It serves only the purpose of providing\n          metadata that can be read with the `modulemeta` builtin.\n\n          The metadata must be a constant jq expression.  It should be\n          an object with keys like `homepage`.  At this time jq doesn't\n          use this metadata, but it is made available to users via the\n          `modulemeta` builtin.\n\n      - title: \"`modulemeta`\"\n        body: |\n\n          Takes a module name as input and outputs the module's metadata\n          as an object, with the module's imports (including metadata)\n          as an array value for the `deps` key and the module's defined\n          functions as an array value for the `defs` key.\n\n          Programs can use this to query a module's metadata, which they\n          could then use to, for example, search for, download, and\n          install missing dependencies.\n\n  - title: Colors\n    body: |\n\n      To configure alternative colors just set the `JQ_COLORS`\n      environment variable to colon-delimited list of partial terminal\n      escape sequences like `\"1;31\"`, in this order:\n\n        - color for `null`\n        - color for `false`\n        - color for `true`\n        - color for numbers\n        - color for strings\n        - color for arrays\n        - color for objects\n        - color for object keys\n\n      The default color scheme is the same as setting\n      `JQ_COLORS=\"0;90:0;39:0;39:0;39:0;32:1;39:1;39:1;34\"`.\n\n      This is not a manual for VT100/ANSI escapes.  However, each of\n      these color specifications should consist of two numbers separated\n      by a semi-colon, where the first number is one of these:\n\n        - 1 (bright)\n        - 2 (dim)\n        - 4 (underscore)\n        - 5 (blink)\n        - 7 (reverse)\n        - 8 (hidden)\n\n      and the second is one of these:\n\n        - 30 (black)\n        - 31 (red)\n        - 32 (green)\n        - 33 (yellow)\n        - 34 (blue)\n        - 35 (magenta)\n        - 36 (cyan)\n        - 37 (white)\n"
  },
  {
    "path": "docs/content/tutorial/default.yml",
    "content": "headline: Tutorial\nbody:\n  - text: |\n\n      GitHub has a JSON API, so let's play with that. This URL gets us the last\n      5 commits from the jq repo.\n\n  - command: \"curl 'https://api.github.com/repos/jqlang/jq/commits?per_page=5'\"\n    result: |\n      [\n        {\n          \"sha\": \"cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n          \"node_id\": \"C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg\",\n          \"commit\": {\n            \"author\": {\n              \"name\": \"Mattias Wadman\",\n              \"email\": \"mattias.wadman@gmail.com\",\n              \"date\": \"2021-06-09T14:02:22Z\"\n            },\n            \"committer\": {\n              \"name\": \"Nico Williams\",\n              \"email\": \"nico@cryptonector.com\",\n              \"date\": \"2022-05-26T21:04:32Z\"\n            },\n            \"message\": \"docs: Document repeat(exp)\",\n            \"tree\": {\n              \"sha\": \"d67d5542df1f16d1a48e1fb75749f60482cd874b\",\n              \"url\": \"https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b\"\n            },\n            \"url\": \"https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n            \"comment_count\": 0,\n            \"verification\": {\n              \"verified\": false,\n              \"reason\": \"unsigned\",\n              \"signature\": null,\n              \"payload\": null\n            }\n          },\n          \"url\": \"https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n          \"html_url\": \"https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n          \"comments_url\": \"https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments\",\n          \"author\": {\n      ...\n\n  - text: |\n\n      GitHub returns nicely formatted JSON. For servers that don't, it can be\n      helpful to pipe the response through jq to pretty-print it. The simplest\n      jq program is the expression `.`, which takes the input and produces it\n      unchanged as output.\n\n  - command: \"curl 'https://api.github.com/repos/jqlang/jq/commits?per_page=5' | jq '.'\"\n    result: |\n      [\n        {\n          \"sha\": \"cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n          \"node_id\": \"C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg\",\n          \"commit\": {\n            \"author\": {\n              \"name\": \"Mattias Wadman\",\n              \"email\": \"mattias.wadman@gmail.com\",\n              \"date\": \"2021-06-09T14:02:22Z\"\n            },\n            \"committer\": {\n              \"name\": \"Nico Williams\",\n              \"email\": \"nico@cryptonector.com\",\n              \"date\": \"2022-05-26T21:04:32Z\"\n            },\n            \"message\": \"docs: Document repeat(exp)\",\n            \"tree\": {\n              \"sha\": \"d67d5542df1f16d1a48e1fb75749f60482cd874b\",\n              \"url\": \"https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b\"\n            },\n            \"url\": \"https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n            \"comment_count\": 0,\n            \"verification\": {\n              \"verified\": false,\n              \"reason\": \"unsigned\",\n              \"signature\": null,\n              \"payload\": null\n            }\n          },\n          \"url\": \"https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n          \"html_url\": \"https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n          \"comments_url\": \"https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments\",\n          \"author\": {\n      ...\n\n  - text: |\n\n      We can use jq to extract just the first commit.\n\n  - command: \"curl 'https://api.github.com/repos/jqlang/jq/commits?per_page=5' | jq '.[0]'\"\n    result: |\n      {\n        \"sha\": \"cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n        \"node_id\": \"C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg\",\n        \"commit\": {\n          \"author\": {\n            \"name\": \"Mattias Wadman\",\n            \"email\": \"mattias.wadman@gmail.com\",\n            \"date\": \"2021-06-09T14:02:22Z\"\n          },\n          \"committer\": {\n            \"name\": \"Nico Williams\",\n            \"email\": \"nico@cryptonector.com\",\n            \"date\": \"2022-05-26T21:04:32Z\"\n          },\n          \"message\": \"docs: Document repeat(exp)\",\n          \"tree\": {\n            \"sha\": \"d67d5542df1f16d1a48e1fb75749f60482cd874b\",\n            \"url\": \"https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b\"\n          },\n          \"url\": \"https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n          \"comment_count\": 0,\n          \"verification\": {\n            \"verified\": false,\n            \"reason\": \"unsigned\",\n            \"signature\": null,\n            \"payload\": null\n          }\n        },\n        \"url\": \"https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n        \"html_url\": \"https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8\",\n        \"comments_url\": \"https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments\",\n        \"author\": {\n          \"login\": \"wader\",\n          \"id\": 185566,\n          \"node_id\": \"MDQ6VXNlcjE4NTU2Ng==\",\n          \"avatar_url\": \"https://avatars.githubusercontent.com/u/185566?v=4\",\n          \"gravatar_id\": \"\",\n          \"url\": \"https://api.github.com/users/wader\",\n          \"html_url\": \"https://github.com/wader\",\n          \"followers_url\": \"https://api.github.com/users/wader/followers\",\n          \"following_url\": \"https://api.github.com/users/wader/following{/other_user}\",\n          \"gists_url\": \"https://api.github.com/users/wader/gists{/gist_id}\",\n          \"starred_url\": \"https://api.github.com/users/wader/starred{/owner}{/repo}\",\n          \"subscriptions_url\": \"https://api.github.com/users/wader/subscriptions\",\n          \"organizations_url\": \"https://api.github.com/users/wader/orgs\",\n          \"repos_url\": \"https://api.github.com/users/wader/repos\",\n          \"events_url\": \"https://api.github.com/users/wader/events{/privacy}\",\n          \"received_events_url\": \"https://api.github.com/users/wader/received_events\",\n          \"type\": \"User\",\n          \"site_admin\": false\n        },\n        \"committer\": {\n          \"login\": \"nicowilliams\",\n          \"id\": 604851,\n          \"node_id\": \"MDQ6VXNlcjYwNDg1MQ==\",\n          \"avatar_url\": \"https://avatars.githubusercontent.com/u/604851?v=4\",\n          \"gravatar_id\": \"\",\n          \"url\": \"https://api.github.com/users/nicowilliams\",\n          \"html_url\": \"https://github.com/nicowilliams\",\n          \"followers_url\": \"https://api.github.com/users/nicowilliams/followers\",\n          \"following_url\": \"https://api.github.com/users/nicowilliams/following{/other_user}\",\n          \"gists_url\": \"https://api.github.com/users/nicowilliams/gists{/gist_id}\",\n          \"starred_url\": \"https://api.github.com/users/nicowilliams/starred{/owner}{/repo}\",\n          \"subscriptions_url\": \"https://api.github.com/users/nicowilliams/subscriptions\",\n          \"organizations_url\": \"https://api.github.com/users/nicowilliams/orgs\",\n          \"repos_url\": \"https://api.github.com/users/nicowilliams/repos\",\n          \"events_url\": \"https://api.github.com/users/nicowilliams/events{/privacy}\",\n          \"received_events_url\": \"https://api.github.com/users/nicowilliams/received_events\",\n          \"type\": \"User\",\n          \"site_admin\": false\n        },\n        \"parents\": [\n          {\n            \"sha\": \"f2ad9517c72f6267ae317639ab56bbfd4a8653d4\",\n            \"url\": \"https://api.github.com/repos/jqlang/jq/commits/f2ad9517c72f6267ae317639ab56bbfd4a8653d4\",\n            \"html_url\": \"https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4\"\n          }\n        ]\n      }\n\n  - text: |\n\n      For the rest of the examples, I'll leave out the `curl` command - it's not\n      going to change.\n\n      There's a lot of info we don't care about there, so we'll restrict it down\n      to the most interesting fields.\n\n  - command: \"jq '.[0] | {message: .commit.message, name: .commit.committer.name}'\"\n    result: |\n      {\n        \"message\": \"docs: Document repeat(exp)\",\n        \"name\": \"Nico Williams\"\n      }\n\n  - text: |\n\n      The `|` operator in jq feeds the output of one filter (`.[0]` which gets\n      the first element of the array in the response) into the input of another\n      (`{...}` which builds an object out of those fields). You can access\n      nested attributes, such as `.commit.message`.\n\n      Now let's get the rest of the commits.\n\n  - command:  \"jq '.[] | {message: .commit.message, name: .commit.committer.name}'\"\n    result: |\n      {\n        \"message\": \"docs: Document repeat(exp)\",\n        \"name\": \"Nico Williams\"\n      }\n      {\n        \"message\": \"Mention -n in IO-section and for input/inputs\",\n        \"name\": \"Nico Williams\"\n      }\n      {\n        \"message\": \"Fix iteration problem for non decimal string\\n\\nWhen the string transformation to number failed, all following\\ntransformation failed too.\\n\\nThis happend because status in decNumberFromString function is\\nupdated just in error case. Reusing the DEC_CONTEXT that failed\\nbefore results into error even if the string is valid number.\",\n        \"name\": \"Nico Williams\"\n      }\n      {\n        \"message\": \"docs: point to Libera.Chat instead of Freenode\",\n        \"name\": \"Nico Williams\"\n      }\n      {\n        \"message\": \"Missing \\\"va_end\\\" call. This was found by running the cppcheck static analysis where it shows as error.\",\n        \"name\": \"Nico Williams\"\n      }\n\n  - text: |\n\n      `.[]` returns each element of the array returned in the response, one at a\n      time, which are all fed into\n      `{message: .commit.message, name: .commit.committer.name}`.\n\n      Data in jq is represented as streams of JSON values - every jq\n      expression runs for each value in its input stream, and can\n      produce any number of values to its output stream.\n\n      Streams are serialised by just separating JSON values with\n      whitespace. This is a `cat`-friendly format - you can just join\n      two JSON streams together and get a valid JSON stream.\n\n      If you want to get the output as a single array, you can tell jq to\n      \"collect\" all of the answers by wrapping the filter in square\n      brackets:\n\n  - command: \"jq '[.[] | {message: .commit.message, name: .commit.committer.name}]'\"\n    result: |\n      [\n        {\n          \"message\": \"docs: Document repeat(exp)\",\n          \"name\": \"Nico Williams\"\n        },\n        {\n          \"message\": \"Mention -n in IO-section and for input/inputs\",\n          \"name\": \"Nico Williams\"\n        },\n        {\n          \"message\": \"Fix iteration problem for non decimal string\\n\\nWhen the string transformation to number failed, all following\\ntransformation failed too.\\n\\nThis happend because status in decNumberFromString function is\\nupdated just in error case. Reusing the DEC_CONTEXT that failed\\nbefore results into error even if the string is valid number.\",\n          \"name\": \"Nico Williams\"\n        },\n        {\n          \"message\": \"docs: point to Libera.Chat instead of Freenode\",\n          \"name\": \"Nico Williams\"\n        },\n        {\n          \"message\": \"Missing \\\"va_end\\\" call. This was found by running the cppcheck static analysis where it shows as error.\",\n          \"name\": \"Nico Williams\"\n        }\n      ]\n\n  - text: |\n\n      - - -\n\n      Next, let's try getting the URLs of the parent commits out of the\n      API results as well. In each commit, the GitHub API includes information\n      about \"parent\" commits. There can be one or many.\n\n          \"parents\": [\n            {\n              \"sha\": \"f2ad9517c72f6267ae317639ab56bbfd4a8653d4\",\n              \"url\": \"https://api.github.com/repos/jqlang/jq/commits/f2ad9517c72f6267ae317639ab56bbfd4a8653d4\",\n              \"html_url\": \"https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4\"\n            }\n          ]\n\n      We want to pull out all of the \"html_url\" fields inside that array of parent\n      commits and make a simple list of strings to go along with the\n      \"message\" and \"author\" fields we already have.\n\n  - command: \"jq '[.[] | {message: .commit.message, name: .commit.committer.name, parents: [.parents[].html_url]}]'\"\n    result: |\n      [\n        {\n          \"message\": \"docs: Document repeat(exp)\",\n          \"name\": \"Nico Williams\",\n          \"parents\": [\n            \"https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4\"\n          ]\n        },\n        {\n          \"message\": \"Mention -n in IO-section and for input/inputs\",\n          \"name\": \"Nico Williams\",\n          \"parents\": [\n            \"https://github.com/jqlang/jq/commit/c4d39c4d22f2b12225ca1b311708f7e084ad9ff8\"\n          ]\n        },\n        {\n          \"message\": \"Fix iteration problem for non decimal string\\n\\nWhen the string transformation to number failed, all following\\ntransformation failed too.\\n\\nThis happend because status in decNumberFromString function is\\nupdated just in error case. Reusing the DEC_CONTEXT that failed\\nbefore results into error even if the string is valid number.\",\n          \"name\": \"Nico Williams\",\n          \"parents\": [\n            \"https://github.com/jqlang/jq/commit/174db0f93552bdb551ae1f3c5c64744df0ad8e2f\"\n          ]\n        },\n        {\n          \"message\": \"docs: point to Libera.Chat instead of Freenode\",\n          \"name\": \"Nico Williams\",\n          \"parents\": [\n            \"https://github.com/jqlang/jq/commit/29cf77977ef52eec708982b19bf9d2ec17443337\"\n          ]\n        },\n        {\n          \"message\": \"Missing \\\"va_end\\\" call. This was found by running the cppcheck static analysis where it shows as error.\",\n          \"name\": \"Nico Williams\",\n          \"parents\": [\n            \"https://github.com/jqlang/jq/commit/55e6e2c21829bd866bd4b18ee254b05c9020320a\"\n          ]\n        }\n      ]\n\n  - text: |\n\n      Here we're making an object as before, but this time the `parents`\n      field is being set to `[.parents[].html_url]`, which collects\n      all of the parent commit URLs defined in the parents object.\n\n  - text: |\n\n      - - -\n\n      Here endeth the tutorial! There's lots more to play with. Go\n      read [the manual](../manual/) if you're interested, and [download\n      jq](../download/) if you haven't already.\n"
  },
  {
    "path": "docs/manual_schema.yml",
    "content": "type: object\nrequired:\n  - headline\n  - body\n  - manpage_intro\n  - manpage_epilogue\n  - sections\nadditionalProperties: false\nproperties:\n  headline:\n    type: string\n  body:\n    type: string\n  manpage_intro:\n    type: string\n  manpage_epilogue:\n    type: string\n  sections:\n    type: array\n    items:\n      type: object\n      required:\n        - title\n      additionalProperties: false\n      properties:\n        title:\n          type: string\n        body:\n          type: string\n        entries:\n          type: array\n          items:\n            type: object\n            required:\n              - title\n              - body\n            additionalProperties: false\n            properties:\n              title:\n                type: string\n              body:\n                type: string\n              examples:\n                type: array\n                items:\n                  type: object\n                  required:\n                    - program\n                    - input\n                    - output\n                  additionalProperties: false\n                  properties:\n                    program:\n                      type: string\n                    input:\n                      type: string\n                    output:\n                      type: array\n                      items:\n                        type: string\n"
  },
  {
    "path": "docs/public/.htaccess",
    "content": "DirectoryIndex index.html\nFileETag All\n\n# Compress all static assets\n<IfModule mod_deflate.c>\n\t# compress content with type html, text, and css\n  AddOutputFilterByType DEFLATE text/css text/html text/javascript application/javascript application/x-javascript text/js text/plain text/xml\n\n\t<IfModule mod_headers.c>\n\t\t# properly handle requests coming from behind proxies\n\t\tHeader append Vary User-Agent\n\t</IfModule>\n</IfModule>\n\n# Cache, aggressively\n<IfModule mod_expires.c>\n  ExpiresActive On\n  ExpiresDefault \"access plus 10 days\"\n\n\t<FilesMatch \"\\.(eot|ttf|otf)$\">\n\t\tExpiresDefault \"access plus 10 years\"\n\t</filesMatch>\n</IfModule>\n\n# Mime-types\nAddType application/vnd.ms-fontobject .eot\nAddType font/ttf .ttf\nAddType font/otf .otf\n"
  },
  {
    "path": "docs/public/CNAME",
    "content": "jqlang.org\n"
  },
  {
    "path": "docs/public/css/style.css",
    "content": "main {\n  padding: 1rem;\n\n  & * {\n    scroll-margin-top: 4rem;\n  }\n\n  @media print {\n    width: 100%!important;\n    --bs-code-color: --bs-body-color;\n  }\n}\n\nheader {\n  z-index: 1050!important; /* higher than #contents */\n}\n\nsection[id] {\n  display: flow-root;\n\n  > :first-child {\n    .icon-link {\n      opacity: 0;\n\n      &:focus {\n        opacity: .8;\n      }\n    }\n\n    &:hover .icon-link {\n      opacity: 1;\n    }\n  }\n}\n\n.offcanvas[aria-modal=true] .nav-link {\n  padding: .7rem;\n}\n.offcanvas-md {\n  --bs-offcanvas-width: auto;\n}\n\nul {\n  list-style: none;\n  padding-left: 1rem;\n}\n\npre {\n  margin: 0 .5rem 1rem;\n  padding: .5rem 1rem;\n  background-color: var(--bs-secondary-bg-subtle);\n  border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);\n}\n\nbutton {\n  &[aria-expanded=false] {\n    .bi-chevron-down, .hide-result-text {\n      display: none;\n    }\n  }\n\n  &[aria-expanded=true] {\n    .bi-chevron-right, .show-result-text {\n      display: none;\n    }\n  }\n}\n\nmark {\n  padding: 0;\n}\n\n.container-searchbox {\n  position: relative;\n\n  & input:focus ~ kbd {\n    display: none;\n  }\n\n  & ul {\n    position: absolute;\n    width: 100%;\n    top: 100%;\n    padding: 0;\n    background-color: var(--bs-body-bg);\n    border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);\n  }\n\n  & li {\n    padding: .3em .6em;\n    white-space: nowrap;\n    overflow-x: hidden;\n\n    &[aria-selected=true] {\n      background-color: var(--bs-secondary-bg);\n    }\n\n    &:hover {\n      cursor: pointer;\n      background-color: var(--bs-secondary-bg-subtle);\n    }\n  }\n}\n"
  },
  {
    "path": "docs/public/js/manual-search.js",
    "content": "(() => {\n  const searchInput = document.querySelector('input#searchbox');\n  const sectionIDs = JSON.parse(document.querySelector('#section-ids').innerText);\n  const sanitize = (string) => string.replaceAll('<', '&lt;').replaceAll('>', '&gt;');\n  new autoComplete({\n    selector: `#${searchInput.id}`,\n    wrapper: false,\n    data: {\n      src: Object.keys(sectionIDs),\n      filter: (list) => list.sort((x, y) =>\n        x.match.indexOf('<') - y.match.indexOf('<') || x.value.length - y.value.length),\n    },\n    searchEngine: (query, value) => {\n      const index = value.toLowerCase().indexOf(query.toLowerCase());\n      if (index >= 0) {\n        return sanitize(value.substring(0, index)) +\n          `<mark>${sanitize(value.substring(index, index + query.length))}</mark>` +\n          sanitize(value.substring(index + query.length));\n      }\n    },\n  });\n  searchInput.addEventListener('selection', (event) => {\n    event.target.value = event.detail.selection.value;\n    location.hash = `#${sectionIDs[event.detail.selection.value]}`;\n  });\n  document.addEventListener('keydown', (event) => {\n    if (event.code === 'Slash' && !event.altKey && !event.ctrlKey && !event.metaKey\n      && !event.shiftKey && !/^(INPUT|TEXTAREA)$/.test(event.target.nodeName)) {\n      searchInput.focus();\n      searchInput.select();\n      event.preventDefault();\n    }\n  });\n})();\n"
  },
  {
    "path": "docs/public/robots.txt",
    "content": "User-agent: *\nAllow: /"
  },
  {
    "path": "docs/templates/default.html.j2",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n{% include \"shared/_head.html.j2\" %}\n\n  <body>\n{% include \"shared/_navbar.html.j2\" %}\n\n    <main id=\"main\" class=\"container-lg\">\n      <h1>{{ headline }}</h1>\n      {%- for item in body %}\n      {%- if item.text %}\n      {{ item.text | markdownify }}\n      {%- endif %}\n\n      {%- if item.command %}\n      {%- set resultID = unique_id() %}\n      <div class=\"tutorial-example mb-3\">\n        <div class=\"d-flex accordion-heading me-2\">\n          <pre class=\"flex-grow-1 me-0 mb-0\" tabindex=\"0\">{{ item.command }}</pre>\n          <button type=\"button\" class=\"btn btn-sm btn-secondary text-body-secondary bg-secondary-subtle link-body-emphasis flex-shrink-0 d-flex align-items-center border border-start-0 d-print-none\"\n            data-bs-toggle=\"collapse\" data-bs-target=\"#result{{ resultID }}\" aria-expanded=\"false\" aria-controls=\"result{{ resultID }}\"><span class=\"show-result-text\">Show result</span><span class=\"hide-result-text\">Hide result</span></button>\n        </div>\n        <pre id=\"result{{ resultID }}\" class=\"accordion-body collapse p-3 border-top-0 d-print-block\" tabindex=\"0\">{{ item.result }}</pre>\n      </div>\n      {%- endif %}\n      {%- endfor %}\n    </main>\n\n{% include \"shared/_footer.html.j2\" %}\n  </body>\n</html>\n"
  },
  {
    "path": "docs/templates/index.html.j2",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n{% include \"shared/_head.html.j2\" %}\n\n  <body>\n{% include \"shared/_navbar.html.j2\" %}\n\n    <main id=\"main\" class=\"container-lg\">\n      <div class=\"row\">\n        <div class=\"col-md-6 text-center p-3\">\n          <h1><img src=\"/jq.svg\" class=\"img-fluid\" alt=\"jq\" width=\"400\" height=\"220\"></h1>\n        </div>\n        <div class=\"col-md-6 d-flex flex-column justify-content-center text-center align-items-center\">\n          <h2 class=\"px-1\" style=\"width:16em\">{{ blurb }}</h2>\n          <div class=\"btn-group d-print-none\" role=\"group\">\n            <button type=\"button\" class=\"btn btn-primary dropdown-toggle text-nowrap\" data-bs-toggle=\"dropdown\" aria-expanded=\"false\">\n              Download jq 1.8.1\n              <span class=\"caret\"></span>\n            </button>\n            <ul class=\"dropdown-menu\">\n              <li><a class=\"dropdown-item\" href=\"https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-linux-amd64\" aria-label=\"Link to download executable: Linux (AMD64)\"><span class=\"bi bi-download me-2\" aria-hidden=\"true\"></span>Linux (AMD64)</a></li>\n              <li><a class=\"dropdown-item\" href=\"https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-linux-arm64\" aria-label=\"Link to download executable: Linux (ARM64)\"><span class=\"bi bi-download me-2\" aria-hidden=\"true\"></span>Linux (ARM64)</a></li>\n              <li><a class=\"dropdown-item\" href=\"https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-macos-arm64\" aria-label=\"Link to download executable: macOS (Apple Silicon)\"><span class=\"bi bi-download me-2\" aria-hidden=\"true\"></span>macOS (Apple Silicon)</a></li>\n              <li><a class=\"dropdown-item\" href=\"https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-macos-amd64\" aria-label=\"Link to download executable: macOS (Intel Mac)\"><span class=\"bi bi-download me-2\" aria-hidden=\"true\"></span>macOS (Intel Mac)</a></li>\n              <li><a class=\"dropdown-item\" href=\"https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-windows-amd64.exe\" aria-label=\"Link to download executable: Windows (AMD64)\"><span class=\"bi bi-download me-2\" aria-hidden=\"true\"></span>Windows (AMD64)</a></li>\n              <li><a class=\"dropdown-item\" href=\"/download/\">Other platforms, older versions, and source</a></li>\n            </ul>\n            <a class=\"btn btn-primary text-nowrap\" href=\"https://play.jqlang.org\" rel=\"noopener\">\n              Try online!\n            </a>\n          </div>\n        </div>\n      </div>\n\n      <div class=\"row my-3\">\n        <div class=\"col-md-4\">{{ body1 | markdownify }}</div>\n        <div class=\"col-md-4\">{{ body2 | markdownify }}</div>\n        <div class=\"col-md-4\">{{ body3 | markdownify }}</div>\n      </div>\n\n      <div class=\"text-center my-3\">\n        {{ tail | markdownify }}\n      </div>\n\n      <h2>News</h2>\n      <ul>\n        {%- for item in news %}\n        <li>\n          <span class=\"fst-italic\">{{ item.date }}</span>\n          {{ item.body | markdownify }}\n        </li>\n        {%- endfor %}\n      </ul>\n    </main>\n\n{% include \"shared/_footer.html.j2\" %}\n  </body>\n</html>\n"
  },
  {
    "path": "docs/templates/manual.html.j2",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n{% include \"shared/_head.html.j2\" %}\n\n  <body>\n{% include \"shared/_navbar.html.j2\" %}\n\n    <div class=\"container-lg row align-items-start mx-auto p-3\">\n\n      <button type=\"button\" class=\"d-md-none w-auto position-fixed bottom-0 end-0 p-2 m-3 bg-body-secondary border-0 text-body d-print-none\"\n        data-bs-toggle=\"offcanvas\" data-bs-target=\"#contents\" aria-controls=\"contents\" aria-expanded=\"false\" aria-label=\"Toggle table of contents\">\n        <span class=\"bi bi-list\" aria-hidden=\"true\"></span>\n      </button>\n      <nav id=\"contents\" class=\"col-md-3 sticky-md-top p-3 overflow-y-auto offcanvas-md offcanvas-end d-print-none\" style=\"top:4.5rem; height:calc(100dvh - 5.5rem);\" aria-label=\"Table of contents\">\n        <div class=\"d-flex justify-content-between\">\n          <h4>Contents</h4>\n          <button type=\"button\" class=\"btn-close d-md-none\" data-bs-dismiss=\"offcanvas\" data-bs-target=\"#contents\" aria-label=\"Close table of contents\"></button>\n        </div>\n        <ul class=\"offcanvas-md-body nav nav-pills flex-column\">\n          {%- for section in sections %}\n          <li class=\"nav-item\" data-bs-dismiss=\"offcanvas\" data-bs-target=\"#contents\">\n            <a class=\"nav-link\" href=\"#{{ section.title | section_id }}\">{{ section.title }}</a>\n          </li>\n          {%- endfor %}\n        </ul>\n      </nav>\n      {%- set section_ids = {} %}\n      {%- macro check_section_id(id) -%}\n        {%- if section_ids.__contains__(id) %}\n          {{- raise('Duplicate section id: ' ~ id) }}\n        {%- endif %}\n        {%- set _ = section_ids.__setitem__(id, true) %}\n      {%- endmacro %}\n      <main id=\"main\" class=\"col-md-9\" data-bs-spy=\"scroll\" data-bs-target=\"#contents\" data-bs-threshold=\"0,1\" data-bs-root-margin=\"-30% 0% -70%\">\n        <h1>{{ headline }}</h1>\n        <p>\n          <em>\n            For other versions, see\n            <a href=\"/manual/v1.8/\">1.8</a>,\n            <a href=\"/manual/v1.7/\">1.7</a>,\n            <a href=\"/manual/v1.6/\">1.6</a>,\n            <a href=\"/manual/v1.5/\">1.5</a>,\n            <a href=\"/manual/v1.4/\">1.4</a>,\n            <a href=\"/manual/v1.3/\">1.3</a> or\n            <a href=\"/manual/dev/\">development version</a>.\n          </em>\n        </p>\n        {{ body | markdownify }}\n        {%- for section in sections %}\n        <section id=\"{{ section.title | section_id }}\">{{ check_section_id(section.title | section_id) }}\n          <h2>{{ section.title }} <a href=\"#{{ section.title | section_id }}\" class=\"icon-link\" aria-label=\"Link to this section: {{ section.title }}\"><span class=\"bi bi-link-45deg\" aria-hidden=\"true\"></span></a></h2>\n          {{ section.body | markdownify if section.body }}\n          {%- for entry in section.entries %}\n          <section id=\"{{ entry.title | entry_id }}\">{{ check_section_id(entry.title | entry_id) }}\n            <h3>\n              {{ entry.title | markdownify | no_paragraph }}\n              <a href=\"#{{ entry.title | entry_id }}\" class=\"icon-link\" aria-label=\"Link to this section: {{ entry.title }}\"><span class=\"bi bi-link-45deg\" aria-hidden=\"true\"></span></a>\n            </h3>\n            {{ entry.body | markdownify }}\n            {%- if entry.examples %}\n            <div class=\"pb-3\">\n              {%- set exampleID = unique_id() %}\n              <button type=\"button\" class=\"btn btn-sm btn-secondary text-body-secondary bg-transparent link-body-emphasis border-0\" data-bs-toggle=\"collapse\" data-bs-target=\"#example{{ exampleID }}\" aria-expanded=\"false\" aria-controls=\"example{{ exampleID }}\">\n                <span class=\"me-1 d-print-none\" aria-hidden=\"true\"><span class=\"bi bi-chevron-right\"></span><span class=\"bi bi-chevron-down\"></span></span>Example{% if entry.examples | length > 1 %}s{% endif %}\n              </button>\n              <div id=\"example{{ exampleID }}\" class=\"collapse mx-3 small d-print-block\">\n                {%- for example in entry.examples %}\n                <table class=\"table table-borderless table-sm w-auto\">\n                  <tr>\n                    <th class=\"pe-3\">Command</th>\n                    <td class=\"font-monospace\">jq '{{ example.program }}'</td>\n                  </tr>\n                  <tr>\n                    <th>Input</th>\n                    <td class=\"font-monospace\">{{ example.input }}</td>\n                  </tr>\n                  {%- if not example.output[0] %}\n                  <tr>\n                    <th>Output</th>\n                    <td class=\"fst-italic\">none</td>\n                  </tr>\n                  {%- endif %}\n                  {%- for output in example.output %}\n                  <tr>\n                    <th>{% if loop.first %}Output{% endif %}</th>\n                    <td class=\"font-monospace\">{{ output }}</td>\n                  </tr>\n                  {%- endfor %}\n                  <tr class=\"d-print-none\">\n                    <th><a href=\"https://play.jqlang.org/?q={{ example.program | urlencode }}&j={{ example.input | urlencode }}\" class=\"btn btn-outline-primary btn-sm\" target=\"_blank\" rel=\"noopener\">Run<span class=\"bi bi-box-arrow-up-right ms-2\" aria-hidden=\"true\"></span></a></th>\n                    <td></td>\n                  </tr>\n                </table>\n                {%- endfor %}\n              </div>\n            </div>\n            {%- endif %}\n          </section>\n          {%- endfor %}\n        </section>\n        {%- endfor %}\n      </main>\n\n    </div>\n\n{% include \"shared/_footer.html.j2\" %}\n    <script src=\"https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/autoComplete.min.js\"\n      integrity=\"sha384-xbzjoN6H5XHmAqoSSR42hZVRninPGx85y+XZQGlWxVu2y91lTmr/oD80i5cjeUBv\" crossorigin=\"anonymous\"></script>\n    <script id=\"section-ids\" type=\"application/json\">\n      {\n        {%- for section in sections %}\n        {%- for entry in section.entries %}\n        {{ entry.title | search_id | tojson }}: {{ entry.title | entry_id | tojson }},\n        {%- endfor %}\n        {{ section.title | search_id | tojson }}: {{ section.title | section_id | tojson }}{{ \",\" if not loop.last }}\n        {%- endfor %}\n      }\n    </script>\n    <script src=\"/js/manual-search.js\"></script>\n  </body>\n</html>\n"
  },
  {
    "path": "docs/templates/shared/_footer.html.j2",
    "content": "    <footer class=\"bd-footer bg-body-tertiary\">\n      <div class=\"py-3 text-center\">\n        <p>\n          This website is made with <a href=\"https://getbootstrap.com\" target=\"_blank\" rel=\"noopener\">Bootstrap</a>,\n          themed with <a href=\"https://bootswatch.com\" target=\"_blank\" rel=\"noopener\">Bootswatch</a>.\n        </p>\n        <p>\n          jq is licensed under the MIT license (code) and the\n          <a href=\"https://creativecommons.org/licenses/by/3.0/\" target=\"_blank\" rel=\"noopener\">CC-BY-3.0</a> license (docs).\n        </p>\n      </div>\n    </footer>\n    <script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js\"\n      integrity=\"sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm\" crossorigin=\"anonymous\"></script>\n"
  },
  {
    "path": "docs/templates/shared/_head.html.j2",
    "content": "  <head>\n    <meta charset=\"utf-8\">\n    <title>{{ headline }}</title>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <meta property=\"og:title\" content=\"{{ headline }}\">\n    <meta property=\"og:description\" content=\"jq is a lightweight and flexible command-line JSON processor\">\n    <meta property=\"og:type\" content=\"website\">\n    <meta property=\"og:image\" content=\"{{ url }}/icon.png\">\n    <meta property=\"og:url\" content=\"{{ url }}/{{ permalink }}\">\n    <link rel=\"icon\" href=\"/icon.svg\" type=\"image/svg+xml\">\n    <link rel=\"apple-touch-icon\" href=\"/icon.png\" type=\"image/png\">\n    <link rel=\"canonical\" href=\"{{ url }}/{{ permalink }}\">\n    <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootswatch@5.3.1/dist/cosmo/bootstrap.min.css\"\n      integrity=\"sha384-dulfW0vmzZ638jigSgZXvDxMmd70GCnIv6oa+riKq6Kk4E0MKf7qmBfwP02wltv5\" crossorigin=\"anonymous\">\n    <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css\"\n      integrity=\"sha384-Ay26V7L8bsJTsX9Sxclnvsn+hkdiwRnrjZJXqKmkIDobPgIIWBOVguEcQQLDuhfN\" crossorigin=\"anonymous\">\n    <link rel=\"stylesheet\" href=\"/css/style.css\" type=\"text/css\">\n    <script>\n      (function() {\n        function setTheme(mediaQuery) {\n          document.documentElement.setAttribute('data-bs-theme',\n            document.documentElement.style.colorScheme = mediaQuery.matches ? 'dark' : 'light');\n        }\n        const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n        setTheme(mediaQuery); mediaQuery.addEventListener('change', setTheme);\n      })();\n    </script>\n  </head>\n"
  },
  {
    "path": "docs/templates/shared/_navbar.html.j2",
    "content": "    <div class=\"container visually-hidden-focusable\">\n      <a class=\"d-inline-flex p-2\" href=\"#main\">Skip to main content</a>\n      {%- if navitem.startswith('manual') %}\n      <a class=\"d-inline-flex p-2 m-1\" href=\"#contents\">Skip to table of contents</a>\n      {%- endif %}\n    </div>\n    <header class=\"navbar navbar-expand-md sticky-top bg-body-tertiary d-print-none\">\n      <nav class=\"container-lg\" aria-label=\"Page navigation\">\n        <button type=\"button\" class=\"navbar-toggler\" data-bs-toggle=\"offcanvas\" data-bs-target=\"#navbar-collapse\"\n          aria-controls=\"navbar-collapse\" aria-expanded=\"false\" aria-label=\"Toggle page navigation\">\n          <span class=\"navbar-toggler-icon\"></span>\n        </button>\n        <a class=\"navbar-brand\" href=\"/\" aria-label=\"Top page\"><img src=\"/jq.svg\" alt=\"jq logo\" style=\"height:1.5rem\"></a>\n        <div id=\"navbar-collapse\" class=\"offcanvas offcanvas-start navbar-collapse w-auto\" aria-labelledby=\"navbar-title\">\n          <div class=\"offcanvas-header\">\n            <h3 id=\"navbar-title\" class=\"me-3\">jq</h3>\n            <button type=\"button\" class=\"d-md-none btn-close\" data-bs-dismiss=\"offcanvas\" aria-label=\"Close page navigation\"></button>\n          </div>\n          <ul class=\"offcanvas-body navbar-nav me-auto text-nowrap\">\n            <li class=\"nav-item d-md-none\"><a class=\"nav-link{% if not navitem %} active{% endif %}\"{% if not navitem %} aria-current=\"page\"{% endif %} href=\"/\">Top page</a></li>\n            {%- for item in ['tutorial', 'download', 'manual'] %}\n            <li class=\"nav-item\"><a class=\"nav-link{% if item == navitem %} active{% endif %}\"{% if item == navitem %} aria-current=\"page\"{% endif %} href=\"/{{ item }}/\">{{ item | capitalize }}</a></li>\n            {%- endfor %}\n            <li class=\"nav-item\"><a class=\"nav-link\" href=\"https://github.com/jqlang/jq\" target=\"_blank\" rel=\"noopener\">GitHub</a></li>\n            <li class=\"nav-item\"><a class=\"nav-link\" href=\"https://github.com/jqlang/jq/issues\" target=\"_blank\" rel=\"noopener\">Issues</a></li>\n            <li class=\"nav-item\"><a class=\"nav-link\" href=\"https://play.jqlang.org\" rel=\"noopener\">Try online!</a></li>\n            <li class=\"nav-item\"><a class=\"nav-link\" href=\"https://raw.githubusercontent.com/jqlang/jq/master/NEWS.md\" target=\"_blank\" rel=\"noopener\">News</a></li>\n            <li class=\"nav-item\"><a class=\"nav-link\" href=\"https://github.com/jqlang/jq/wiki\" target=\"_blank\" rel=\"noopener\">Wiki</a></li>\n          </ul>\n        </div>\n        {%- if navitem.startswith('manual') %}\n        <div class=\"container-searchbox form-control p-0 d-none d-md-flex d-print-none border\" style=\"width:16rem\">\n          <span class=\"bi bi-search my-auto ms-2 me-1\" aria-hidden=\"true\"></span>\n          <input type=\"text\" id=\"searchbox\" class=\"form-control border-0 px-1\" placeholder=\"Search manual\" role=\"combobox\"\n            aria-label=\"Search manual\" aria-keyshortcuts=\"/\" aria-expanded=\"false\" autocomplete=\"off\" spellcheck=\"false\">\n          <kbd class=\"mx-1 my-auto text-body bg-body rounded border\" style=\"padding:.1rem .2rem\" aria-hidden=\"true\">/</kbd>\n        </div>\n        {%- endif %}\n        <a class=\"d-md-none bi bi-github fs-4 text-body\" href=\"https://github.com/jqlang/jq\" target=\"_blank\" rel=\"noopener\" aria-label=\"GitHub\"></a>\n      </nav>\n    </header>\n"
  },
  {
    "path": "docs/validate_manual_schema.py",
    "content": "#!/usr/bin/env python3\nimport jsonschema\nimport sys\nimport yaml\n\nif len(sys.argv) < 2:\n    sys.exit(\"Usage: {} MANUAL_FILE ...\".format(sys.argv[0]))\n\nwith open(\"manual_schema.yml\", \"r\") as schema_file:\n    manual_schema = yaml.safe_load(schema_file)\n\nfor path in sys.argv[1:]:\n    with open(path, \"r\") as manual_file:\n        manual_data = yaml.safe_load(manual_file)\n    try:\n        jsonschema.validate(instance=manual_data, schema=manual_schema)\n    except jsonschema.exceptions.ValidationError as e:\n        print(\"Failed to validate:\", path, file=sys.stderr)\n        sys.exit(e)\n"
  },
  {
    "path": "jq.1.prebuilt",
    "content": ".\n.TH \"JQ\" \"1\" \"May 2025\" \"\" \"\"\n.\n.SH \"NAME\"\n\\fBjq\\fR \\- Command\\-line JSON processor\n.\n.SH \"SYNOPSIS\"\n\\fBjq\\fR [\\fIoptions\\fR\\.\\.\\.] \\fIfilter\\fR [\\fIfiles\\fR\\.\\.\\.]\n.\n.P\n\\fBjq\\fR can transform JSON in various ways, by selecting, iterating, reducing and otherwise mangling JSON documents\\. For instance, running the command \\fBjq \\'map(\\.price) | add\\'\\fR will take an array of JSON objects as input and return the sum of their \"price\" fields\\.\n.\n.P\n\\fBjq\\fR can accept text input as well, but by default, \\fBjq\\fR reads a stream of JSON entities (including numbers and other literals) from \\fBstdin\\fR\\. Whitespace is only needed to separate entities such as 1 and 2, and true and false\\. One or more \\fIfiles\\fR may be specified, in which case \\fBjq\\fR will read input from those instead\\.\n.\n.P\nThe \\fIoptions\\fR are described in the [INVOKING JQ] section; they mostly concern input and output formatting\\. The \\fIfilter\\fR is written in the jq language and specifies how to transform the input file or document\\.\n.\n.SH \"FILTERS\"\nA jq program is a \"filter\": it takes an input, and produces an output\\. There are a lot of builtin filters for extracting a particular field of an object, or converting a number to a string, or various other standard tasks\\.\n.\n.P\nFilters can be combined in various ways \\- you can pipe the output of one filter into another filter, or collect the output of a filter into an array\\.\n.\n.P\nSome filters produce multiple results, for instance there\\'s one that produces all the elements of its input array\\. Piping that filter into a second runs the second filter for each element of the array\\. Generally, things that would be done with loops and iteration in other languages are just done by gluing filters together in jq\\.\n.\n.P\nIt\\'s important to remember that every filter has an input and an output\\. Even literals like \"hello\" or 42 are filters \\- they take an input but always produce the same literal as output\\. Operations that combine two filters, like addition, generally feed the same input to both and combine the results\\. So, you can implement an averaging filter as \\fBadd / length\\fR \\- feeding the input array both to the \\fBadd\\fR filter and the \\fBlength\\fR filter and then performing the division\\.\n.\n.P\nBut that\\'s getting ahead of ourselves\\. :) Let\\'s start with something simpler:\n.\n.SH \"INVOKING JQ\"\njq filters run on a stream of JSON data\\. The input to jq is parsed as a sequence of whitespace\\-separated JSON values which are passed through the provided filter one at a time\\. The output(s) of the filter are written to standard output, as a sequence of newline\\-separated JSON data\\.\n.\n.P\nThe simplest and most common filter (or jq program) is \\fB\\.\\fR, which is the identity operator, copying the inputs of the jq processor to the output stream\\. Because the default behavior of the jq processor is to read JSON texts from the input stream, and to pretty\\-print outputs, the \\fB\\.\\fR program\\'s main use is to validate and pretty\\-print the inputs\\. The jq programming language is quite rich and allows for much more than just validation and pretty\\-printing\\.\n.\n.P\nNote: it is important to mind the shell\\'s quoting rules\\. As a general rule it\\'s best to always quote (with single\\-quote characters on Unix shells) the jq program, as too many characters with special meaning to jq are also shell meta\\-characters\\. For example, \\fBjq \"foo\"\\fR will fail on most Unix shells because that will be the same as \\fBjq foo\\fR, which will generally fail because \\fBfoo is not defined\\fR\\. When using the Windows command shell (cmd\\.exe) it\\'s best to use double quotes around your jq program when given on the command\\-line (instead of the \\fB\\-f program\\-file\\fR option), but then double\\-quotes in the jq program need backslash escaping\\. When using the Powershell (\\fBpowershell\\.exe\\fR) or the Powershell Core (\\fBpwsh\\fR/\\fBpwsh\\.exe\\fR), use single\\-quote characters around the jq program and backslash\\-escaped double\\-quotes (\\fB\\e\"\\fR) inside the jq program\\.\n.\n.IP \"\\(bu\" 4\nUnix shells: \\fBjq \\'\\.[\"foo\"]\\'\\fR\n.\n.IP \"\\(bu\" 4\nPowershell: \\fBjq \\'\\.[\\e\"foo\\e\"]\\'\\fR\n.\n.IP \"\\(bu\" 4\nWindows command shell: \\fBjq \"\\.[\\e\"foo\\e\"]\"\\fR\n.\n.IP \"\" 0\n.\n.P\nNote: jq allows user\\-defined functions, but every jq program must have a top\\-level expression\\.\n.\n.P\nYou can affect how jq reads and writes its input and output using some command\\-line options:\n.\n.TP\n\\fB\\-\\-null\\-input\\fR / \\fB\\-n\\fR:\n.\n.IP\nDon\\'t read any input at all\\. Instead, the filter is run once using \\fBnull\\fR as the input\\. This is useful when using jq as a simple calculator or to construct JSON data from scratch\\.\n.\n.TP\n\\fB\\-\\-raw\\-input\\fR / \\fB\\-R\\fR:\n.\n.IP\nDon\\'t parse the input as JSON\\. Instead, each line of text is passed to the filter as a string\\. If combined with \\fB\\-\\-slurp\\fR, then the entire input is passed to the filter as a single long string\\.\n.\n.TP\n\\fB\\-\\-slurp\\fR / \\fB\\-s\\fR:\n.\n.IP\nInstead of running the filter for each JSON object in the input, read the entire input stream into a large array and run the filter just once\\.\n.\n.TP\n\\fB\\-\\-compact\\-output\\fR / \\fB\\-c\\fR:\n.\n.IP\nBy default, jq pretty\\-prints JSON output\\. Using this option will result in more compact output by instead putting each JSON object on a single line\\.\n.\n.TP\n\\fB\\-\\-raw\\-output\\fR / \\fB\\-r\\fR:\n.\n.IP\nWith this option, if the filter\\'s result is a string then it will be written directly to standard output rather than being formatted as a JSON string with quotes\\. This can be useful for making jq filters talk to non\\-JSON\\-based systems\\.\n.\n.TP\n\\fB\\-\\-raw\\-output0\\fR:\n.\n.IP\nLike \\fB\\-r\\fR but jq will print NUL instead of newline after each output\\. This can be useful when the values being output can contain newlines\\. When the output value contains NUL, jq exits with non\\-zero code\\.\n.\n.TP\n\\fB\\-\\-join\\-output\\fR / \\fB\\-j\\fR:\n.\n.IP\nLike \\fB\\-r\\fR but jq won\\'t print a newline after each output\\.\n.\n.TP\n\\fB\\-\\-ascii\\-output\\fR / \\fB\\-a\\fR:\n.\n.IP\njq usually outputs non\\-ASCII Unicode codepoints as UTF\\-8, even if the input specified them as escape sequences (like \"\\eu03bc\")\\. Using this option, you can force jq to produce pure ASCII output with every non\\-ASCII character replaced with the equivalent escape sequence\\.\n.\n.TP\n\\fB\\-\\-sort\\-keys\\fR / \\fB\\-S\\fR:\n.\n.IP\nOutput the fields of each object with the keys in sorted order\\.\n.\n.TP\n\\fB\\-\\-color\\-output\\fR / \\fB\\-C\\fR and \\fB\\-\\-monochrome\\-output\\fR / \\fB\\-M\\fR:\n.\n.IP\nBy default, jq outputs colored JSON if writing to a terminal\\. You can force it to produce color even if writing to a pipe or a file using \\fB\\-C\\fR, and disable color with \\fB\\-M\\fR\\. When the \\fBNO_COLOR\\fR environment variable is not empty, jq disables colored output by default, but you can enable it by \\fB\\-C\\fR\\.\n.\n.IP\nColors can be configured with the \\fBJQ_COLORS\\fR environment variable (see below)\\.\n.\n.TP\n\\fB\\-\\-tab\\fR:\n.\n.IP\nUse a tab for each indentation level instead of two spaces\\.\n.\n.TP\n\\fB\\-\\-indent n\\fR:\n.\n.IP\nUse the given number of spaces (no more than 7) for indentation\\.\n.\n.TP\n\\fB\\-\\-unbuffered\\fR:\n.\n.IP\nFlush the output after each JSON object is printed (useful if you\\'re piping a slow data source into jq and piping jq\\'s output elsewhere)\\.\n.\n.TP\n\\fB\\-\\-stream\\fR:\n.\n.IP\nParse the input in streaming fashion, outputting arrays of path and leaf values (scalars and empty arrays or empty objects)\\. For example, \\fB\"a\"\\fR becomes \\fB[[],\"a\"]\\fR, and \\fB[[],\"a\",[\"b\"]]\\fR becomes \\fB[[0],[]]\\fR, \\fB[[1],\"a\"]\\fR, and \\fB[[2,0],\"b\"]\\fR\\.\n.\n.IP\nThis is useful for processing very large inputs\\. Use this in conjunction with filtering and the \\fBreduce\\fR and \\fBforeach\\fR syntax to reduce large inputs incrementally\\.\n.\n.TP\n\\fB\\-\\-stream\\-errors\\fR:\n.\n.IP\nLike \\fB\\-\\-stream\\fR, but invalid JSON inputs yield array values where the first element is the error and the second is a path\\. For example, \\fB[\"a\",n]\\fR produces \\fB[\"Invalid literal at line 1, column 7\",[1]]\\fR\\.\n.\n.IP\nImplies \\fB\\-\\-stream\\fR\\. Invalid JSON inputs produce no error values when \\fB\\-\\-stream\\fR without \\fB\\-\\-stream\\-errors\\fR\\.\n.\n.TP\n\\fB\\-\\-seq\\fR:\n.\n.IP\nUse the \\fBapplication/json\\-seq\\fR MIME type scheme for separating JSON texts in jq\\'s input and output\\. This means that an ASCII RS (record separator) character is printed before each value on output and an ASCII LF (line feed) is printed after every output\\. Input JSON texts that fail to parse are ignored (but warned about), discarding all subsequent input until the next RS\\. This mode also parses the output of jq without the \\fB\\-\\-seq\\fR option\\.\n.\n.TP\n\\fB\\-f\\fR / \\fB\\-\\-from\\-file\\fR:\n.\n.IP\nRead the filter from a file rather than from a command line, like awk\\'s \\-f option\\. This changes the filter argument to be interpreted as a filename, instead of the source of a program\\.\n.\n.TP\n\\fB\\-L directory\\fR / \\fB\\-\\-library\\-path directory\\fR:\n.\n.IP\nPrepend \\fBdirectory\\fR to the search list for modules\\. If this option is used then no builtin search list is used\\. See the section on modules below\\.\n.\n.TP\n\\fB\\-\\-arg name value\\fR:\n.\n.IP\nThis option passes a value to the jq program as a predefined variable\\. If you run jq with \\fB\\-\\-arg foo bar\\fR, then \\fB$foo\\fR is available in the program and has the value \\fB\"bar\"\\fR\\. Note that \\fBvalue\\fR will be treated as a string, so \\fB\\-\\-arg foo 123\\fR will bind \\fB$foo\\fR to \\fB\"123\"\\fR\\.\n.\n.IP\nNamed arguments are also available to the jq program as \\fB$ARGS\\.named\\fR\\. When the name is not a valid identifier, this is the only way to access it\\.\n.\n.TP\n\\fB\\-\\-argjson name JSON\\-text\\fR:\n.\n.IP\nThis option passes a JSON\\-encoded value to the jq program as a predefined variable\\. If you run jq with \\fB\\-\\-argjson foo 123\\fR, then \\fB$foo\\fR is available in the program and has the value \\fB123\\fR\\.\n.\n.TP\n\\fB\\-\\-slurpfile variable\\-name filename\\fR:\n.\n.IP\nThis option reads all the JSON texts in the named file and binds an array of the parsed JSON values to the given global variable\\. If you run jq with \\fB\\-\\-slurpfile foo bar\\fR, then \\fB$foo\\fR is available in the program and has an array whose elements correspond to the texts in the file named \\fBbar\\fR\\.\n.\n.TP\n\\fB\\-\\-rawfile variable\\-name filename\\fR:\n.\n.IP\nThis option reads in the named file and binds its content to the given global variable\\. If you run jq with \\fB\\-\\-rawfile foo bar\\fR, then \\fB$foo\\fR is available in the program and has a string whose content is set to the text in the file named \\fBbar\\fR\\.\n.\n.TP\n\\fB\\-\\-args\\fR:\n.\n.IP\nRemaining arguments are positional string arguments\\. These are available to the jq program as \\fB$ARGS\\.positional[]\\fR\\.\n.\n.TP\n\\fB\\-\\-jsonargs\\fR:\n.\n.IP\nRemaining arguments are positional JSON text arguments\\. These are available to the jq program as \\fB$ARGS\\.positional[]\\fR\\.\n.\n.TP\n\\fB\\-\\-exit\\-status\\fR / \\fB\\-e\\fR:\n.\n.IP\nSets the exit status of jq to 0 if the last output value was neither \\fBfalse\\fR nor \\fBnull\\fR, 1 if the last output value was either \\fBfalse\\fR or \\fBnull\\fR, or 4 if no valid result was ever produced\\. Normally jq exits with 2 if there was any usage problem or system error, 3 if there was a jq program compile error, or 0 if the jq program ran\\.\n.\n.IP\nAnother way to set the exit status is with the \\fBhalt_error\\fR builtin function\\.\n.\n.TP\n\\fB\\-\\-binary\\fR / \\fB\\-b\\fR:\n.\n.IP\nWindows users using WSL, MSYS2, or Cygwin, should use this option when using a native jq\\.exe, otherwise jq will turn newlines (LFs) into carriage\\-return\\-then\\-newline (CRLF)\\.\n.\n.TP\n\\fB\\-\\-version\\fR / \\fB\\-V\\fR:\n.\n.IP\nOutput the jq version and exit with zero\\.\n.\n.TP\n\\fB\\-\\-build\\-configuration\\fR:\n.\n.IP\nOutput the build configuration of jq and exit with zero\\. This output has no supported format or structure and may change without notice in future releases\\.\n.\n.TP\n\\fB\\-\\-help\\fR / \\fB\\-h\\fR:\n.\n.IP\nOutput the jq help and exit with zero\\.\n.\n.TP\n\\fB\\-\\-\\fR:\n.\n.IP\nTerminates argument processing\\. Remaining arguments are not interpreted as options\\.\n.\n.TP\n\\fB\\-\\-run\\-tests [filename]\\fR:\n.\n.IP\nRuns the tests in the given file or standard input\\. This must be the last option given and does not honor all preceding options\\. The input consists of comment lines, empty lines, and program lines followed by one input line, as many lines of output as are expected (one per output), and a terminating empty line\\. Compilation failure tests start with a line containing only \\fB%%FAIL\\fR, then a line containing the program to compile, then a line containing an error message to compare to the actual\\.\n.\n.IP\nBe warned that this option can change backwards\\-incompatibly\\.\n.\n.SH \"BASIC FILTERS\"\n.\n.SS \"Identity: \\.\"\nThe absolute simplest filter is \\fB\\.\\fR \\. This filter takes its input and produces the same value as output\\. That is, this is the identity operator\\.\n.\n.P\nSince jq by default pretty\\-prints all output, a trivial program consisting of nothing but \\fB\\.\\fR can be used to format JSON output from, say, \\fBcurl\\fR\\.\n.\n.P\nAlthough the identity filter never modifies the value of its input, jq processing can sometimes make it appear as though it does\\. For example, using the current implementation of jq, we would see that the expression:\n.\n.IP \"\" 4\n.\n.nf\n\n1E1234567890 | \\.\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nproduces \\fB1\\.7976931348623157e+308\\fR on at least one platform\\. This is because, in the process of parsing the number, this particular version of jq has converted it to an IEEE754 double\\-precision representation, losing precision\\.\n.\n.P\nThe way in which jq handles numbers has changed over time and further changes are likely within the parameters set by the relevant JSON standards\\. Moreover, build configuration options can alter how jq processes numbers\\.\n.\n.P\nThe following remarks are therefore offered with the understanding that they are intended to be descriptive of the current version of jq and should not be interpreted as being prescriptive:\n.\n.P\n(1) Any arithmetic operation on a number that has not already been converted to an IEEE754 double precision representation will trigger a conversion to the IEEE754 representation\\.\n.\n.P\n(2) jq will attempt to maintain the original decimal precision of number literals (if the \\fB\\-\\-disable\\-decnum\\fR build configuration option was not used), but in expressions such \\fB1E1234567890\\fR, precision will be lost if the exponent is too large\\.\n.\n.P\n(3) Comparisons are carried out using the untruncated big decimal representation of numbers if available, as illustrated in one of the following examples\\.\n.\n.P\nThe examples below use the builtin function \\fBhave_decnum\\fR in order to demonstrate the expected effects of using / not using the \\fB\\-\\-disable\\-decnum\\fR build configuration option, and also to allow automated tests derived from these examples to pass regardless of whether that option is used\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.\\'\n   \"Hello, world!\"\n=> \"Hello, world!\"\n\njq \\'\\.\\'\n   0\\.12345678901234567890123456789\n=> 0\\.12345678901234567890123456789\n\njq \\'[\\., tojson] == if have_decnum then [12345678909876543212345,\"12345678909876543212345\"] else [12345678909876543000000,\"12345678909876543000000\"] end\\'\n   12345678909876543212345\n=> true\n\njq \\'[1234567890987654321,\\-1234567890987654321 | tojson] == if have_decnum then [\"1234567890987654321\",\"\\-1234567890987654321\"] else [\"1234567890987654400\",\"\\-1234567890987654400\"] end\\'\n   null\n=> true\n\njq \\'\\. < 0\\.12345678901234567890123456788\\'\n   0\\.12345678901234567890123456789\n=> false\n\njq \\'map([\\., \\. == 1]) | tojson == if have_decnum then \"[[1,true],[1\\.000,true],[1\\.0,true],[1\\.00,true]]\" else \"[[1,true],[1,true],[1,true],[1,true]]\" end\\'\n   [1, 1\\.000, 1\\.0, 100e\\-2]\n=> true\n\njq \\'\\. as $big | [$big, $big + 1] | map(\\. > 10000000000000000000000000000000) | \\. == if have_decnum then [true, false] else [false, false] end\\'\n   10000000000000000000000000000001\n=> true\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Object Identifier\\-Index: \\.foo, \\.foo\\.bar\"\nThe simplest \\fIuseful\\fR filter has the form \\fB\\.foo\\fR\\. When given a JSON object (aka dictionary or hash) as input, \\fB\\.foo\\fR produces the value at the key \"foo\" if the key is present, or null otherwise\\.\n.\n.P\nA filter of the form \\fB\\.foo\\.bar\\fR is equivalent to \\fB\\.foo | \\.bar\\fR\\.\n.\n.P\nThe \\fB\\.foo\\fR syntax only works for simple, identifier\\-like keys, that is, keys that are all made of alphanumeric characters and underscore, and which do not start with a digit\\.\n.\n.P\nIf the key contains special characters or starts with a digit, you need to surround it with double quotes like this: \\fB\\.\"foo$\"\\fR, or else \\fB\\.[\"foo$\"]\\fR\\.\n.\n.P\nFor example \\fB\\.[\"foo::bar\"]\\fR and \\fB\\.[\"foo\\.bar\"]\\fR work while \\fB\\.foo::bar\\fR does not\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.foo\\'\n   {\"foo\": 42, \"bar\": \"less interesting data\"}\n=> 42\n\njq \\'\\.foo\\'\n   {\"notfoo\": true, \"alsonotfoo\": false}\n=> null\n\njq \\'\\.[\"foo\"]\\'\n   {\"foo\": 42}\n=> 42\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Optional Object Identifier\\-Index: \\.foo?\"\nJust like \\fB\\.foo\\fR, but does not output an error when \\fB\\.\\fR is not an object\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.foo?\\'\n   {\"foo\": 42, \"bar\": \"less interesting data\"}\n=> 42\n\njq \\'\\.foo?\\'\n   {\"notfoo\": true, \"alsonotfoo\": false}\n=> null\n\njq \\'\\.[\"foo\"]?\\'\n   {\"foo\": 42}\n=> 42\n\njq \\'[\\.foo?]\\'\n   [1,2]\n=> []\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Object Index: \\.[<string>]\"\nYou can also look up fields of an object using syntax like \\fB\\.[\"foo\"]\\fR (\\fB\\.foo\\fR above is a shorthand version of this, but only for identifier\\-like strings)\\.\n.\n.SS \"Array Index: \\.[<number>]\"\nWhen the index value is an integer, \\fB\\.[<number>]\\fR can index arrays\\. Arrays are zero\\-based, so \\fB\\.[2]\\fR returns the third element\\.\n.\n.P\nNegative indices are allowed, with \\-1 referring to the last element, \\-2 referring to the next to last element, and so on\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.[0]\\'\n   [{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]\n=> {\"name\":\"JSON\", \"good\":true}\n\njq \\'\\.[2]\\'\n   [{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]\n=> null\n\njq \\'\\.[\\-2]\\'\n   [1,2,3]\n=> 2\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Array/String Slice: \\.[<number>:<number>]\"\nThe \\fB\\.[<number>:<number>]\\fR syntax can be used to return a subarray of an array or substring of a string\\. The array returned by \\fB\\.[10:15]\\fR will be of length 5, containing the elements from index 10 (inclusive) to index 15 (exclusive)\\. Either index may be negative (in which case it counts backwards from the end of the array), or omitted (in which case it refers to the start or end of the array)\\. Indices are zero\\-based\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.[2:4]\\'\n   [\"a\",\"b\",\"c\",\"d\",\"e\"]\n=> [\"c\", \"d\"]\n\njq \\'\\.[2:4]\\'\n   \"abcdefghi\"\n=> \"cd\"\n\njq \\'\\.[:3]\\'\n   [\"a\",\"b\",\"c\",\"d\",\"e\"]\n=> [\"a\", \"b\", \"c\"]\n\njq \\'\\.[\\-2:]\\'\n   [\"a\",\"b\",\"c\",\"d\",\"e\"]\n=> [\"d\", \"e\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Array/Object Value Iterator: \\.[]\"\nIf you use the \\fB\\.[index]\\fR syntax, but omit the index entirely, it will return \\fIall\\fR of the elements of an array\\. Running \\fB\\.[]\\fR with the input \\fB[1,2,3]\\fR will produce the numbers as three separate results, rather than as a single array\\. A filter of the form \\fB\\.foo[]\\fR is equivalent to \\fB\\.foo | \\.[]\\fR\\.\n.\n.P\nYou can also use this on an object, and it will return all the values of the object\\.\n.\n.P\nNote that the iterator operator is a generator of values\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.[]\\'\n   [{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]\n=> {\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}\n\njq \\'\\.[]\\'\n   []\n=> \n\njq \\'\\.foo[]\\'\n   {\"foo\":[1,2,3]}\n=> 1, 2, 3\n\njq \\'\\.[]\\'\n   {\"a\": 1, \"b\": 1}\n=> 1, 1\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"\\.[]?\"\nLike \\fB\\.[]\\fR, but no errors will be output if \\. is not an array or object\\. A filter of the form \\fB\\.foo[]?\\fR is equivalent to \\fB\\.foo | \\.[]?\\fR\\.\n.\n.SS \"Comma: ,\"\nIf two filters are separated by a comma, then the same input will be fed into both and the two filters\\' output value streams will be concatenated in order: first, all of the outputs produced by the left expression, and then all of the outputs produced by the right\\. For instance, filter \\fB\\.foo, \\.bar\\fR, produces both the \"foo\" fields and \"bar\" fields as separate outputs\\.\n.\n.P\nThe \\fB,\\fR operator is one way to construct generators\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.foo, \\.bar\\'\n   {\"foo\": 42, \"bar\": \"something else\", \"baz\": true}\n=> 42, \"something else\"\n\njq \\'\\.user, \\.projects[]\\'\n   {\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}\n=> \"stedolan\", \"jq\", \"wikiflow\"\n\njq \\'\\.[4,2]\\'\n   [\"a\",\"b\",\"c\",\"d\",\"e\"]\n=> \"e\", \"c\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Pipe: |\"\nThe | operator combines two filters by feeding the output(s) of the one on the left into the input of the one on the right\\. It\\'s similar to the Unix shell\\'s pipe, if you\\'re used to that\\.\n.\n.P\nIf the one on the left produces multiple results, the one on the right will be run for each of those results\\. So, the expression \\fB\\.[] | \\.foo\\fR retrieves the \"foo\" field of each element of the input array\\. This is a cartesian product, which can be surprising\\.\n.\n.P\nNote that \\fB\\.a\\.b\\.c\\fR is the same as \\fB\\.a | \\.b | \\.c\\fR\\.\n.\n.P\nNote too that \\fB\\.\\fR is the input value at the particular stage in a \"pipeline\", specifically: where the \\fB\\.\\fR expression appears\\. Thus \\fB\\.a | \\. | \\.b\\fR is the same as \\fB\\.a\\.b\\fR, as the \\fB\\.\\fR in the middle refers to whatever value \\fB\\.a\\fR produced\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.[] | \\.name\\'\n   [{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]\n=> \"JSON\", \"XML\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Parenthesis\"\nParenthesis work as a grouping operator just as in any typical programming language\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'(\\. + 2) * 5\\'\n   1\n=> 15\n.\n.fi\n.\n.IP \"\" 0\n.\n.SH \"TYPES AND VALUES\"\njq supports the same set of datatypes as JSON \\- numbers, strings, booleans, arrays, objects (which in JSON\\-speak are hashes with only string keys), and \"null\"\\.\n.\n.P\nBooleans, null, strings and numbers are written the same way as in JSON\\. Just like everything else in jq, these simple values take an input and produce an output \\- \\fB42\\fR is a valid jq expression that takes an input, ignores it, and returns 42 instead\\.\n.\n.P\nNumbers in jq are internally represented by their IEEE754 double precision approximation\\. Any arithmetic operation with numbers, whether they are literals or results of previous filters, will produce a double precision floating point result\\.\n.\n.P\nHowever, when parsing a literal jq will store the original literal string\\. If no mutation is applied to this value then it will make to the output in its original form, even if conversion to double would result in a loss\\.\n.\n.SS \"Array construction: []\"\nAs in JSON, \\fB[]\\fR is used to construct arrays, as in \\fB[1,2,3]\\fR\\. The elements of the arrays can be any jq expression, including a pipeline\\. All of the results produced by all of the expressions are collected into one big array\\. You can use it to construct an array out of a known quantity of values (as in \\fB[\\.foo, \\.bar, \\.baz]\\fR) or to \"collect\" all the results of a filter into an array (as in \\fB[\\.items[]\\.name]\\fR)\n.\n.P\nOnce you understand the \",\" operator, you can look at jq\\'s array syntax in a different light: the expression \\fB[1,2,3]\\fR is not using a built\\-in syntax for comma\\-separated arrays, but is instead applying the \\fB[]\\fR operator (collect results) to the expression 1,2,3 (which produces three different results)\\.\n.\n.P\nIf you have a filter \\fBX\\fR that produces four results, then the expression \\fB[X]\\fR will produce a single result, an array of four elements\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[\\.user, \\.projects[]]\\'\n   {\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}\n=> [\"stedolan\", \"jq\", \"wikiflow\"]\n\njq \\'[ \\.[] | \\. * 2]\\'\n   [1, 2, 3]\n=> [2, 4, 6]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Object Construction: {}\"\nLike JSON, \\fB{}\\fR is for constructing objects (aka dictionaries or hashes), as in: \\fB{\"a\": 42, \"b\": 17}\\fR\\.\n.\n.P\nIf the keys are \"identifier\\-like\", then the quotes can be left off, as in \\fB{a:42, b:17}\\fR\\. Variable references as key expressions use the value of the variable as the key\\. Key expressions other than constant literals, identifiers, or variable references, need to be parenthesized, e\\.g\\., \\fB{(\"a\"+\"b\"):59}\\fR\\.\n.\n.P\nThe value can be any expression (although you may need to wrap it in parentheses if, for example, it contains colons), which gets applied to the {} expression\\'s input (remember, all filters have an input and an output)\\.\n.\n.IP \"\" 4\n.\n.nf\n\n{foo: \\.bar}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nwill produce the JSON object \\fB{\"foo\": 42}\\fR if given the JSON object \\fB{\"bar\":42, \"baz\":43}\\fR as its input\\. You can use this to select particular fields of an object: if the input is an object with \"user\", \"title\", \"id\", and \"content\" fields and you just want \"user\" and \"title\", you can write\n.\n.IP \"\" 4\n.\n.nf\n\n{user: \\.user, title: \\.title}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nBecause that is so common, there\\'s a shortcut syntax for it: \\fB{user, title}\\fR\\.\n.\n.P\nIf one of the expressions produces multiple results, multiple dictionaries will be produced\\. If the input\\'s\n.\n.IP \"\" 4\n.\n.nf\n\n{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nthen the expression\n.\n.IP \"\" 4\n.\n.nf\n\n{user, title: \\.titles[]}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nwill produce two outputs:\n.\n.IP \"\" 4\n.\n.nf\n\n{\"user\":\"stedolan\", \"title\": \"JQ Primer\"}\n{\"user\":\"stedolan\", \"title\": \"More JQ\"}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nPutting parentheses around the key means it will be evaluated as an expression\\. With the same input as above,\n.\n.IP \"\" 4\n.\n.nf\n\n{(\\.user): \\.titles}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nproduces\n.\n.IP \"\" 4\n.\n.nf\n\n{\"stedolan\": [\"JQ Primer\", \"More JQ\"]}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nVariable references as keys use the value of the variable as the key\\. Without a value then the variable\\'s name becomes the key and its value becomes the value,\n.\n.IP \"\" 4\n.\n.nf\n\n\"f o o\" as $foo | \"b a r\" as $bar | {$foo, $bar:$foo}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nproduces\n.\n.IP \"\" 4\n.\n.nf\n\n{\"foo\":\"f o o\",\"b a r\":\"f o o\"}\n\njq \\'{user, title: \\.titles[]}\\'\n   {\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n=> {\"user\":\"stedolan\", \"title\": \"JQ Primer\"}, {\"user\":\"stedolan\", \"title\": \"More JQ\"}\n\njq \\'{(\\.user): \\.titles}\\'\n   {\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n=> {\"stedolan\": [\"JQ Primer\", \"More JQ\"]}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Recursive Descent: \\.\\.\"\nRecursively descends \\fB\\.\\fR, producing every value\\. This is the same as the zero\\-argument \\fBrecurse\\fR builtin (see below)\\. This is intended to resemble the XPath \\fB//\\fR operator\\. Note that \\fB\\.\\.a\\fR does not work; use \\fB\\.\\. | \\.a\\fR instead\\. In the example below we use \\fB\\.\\. | \\.a?\\fR to find all the values of object keys \"a\" in any object found \"below\" \\fB\\.\\fR\\.\n.\n.P\nThis is particularly useful in conjunction with \\fBpath(EXP)\\fR (also see below) and the \\fB?\\fR operator\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.\\. | \\.a?\\'\n   [[{\"a\":1}]]\n=> 1\n.\n.fi\n.\n.IP \"\" 0\n.\n.SH \"BUILTIN OPERATORS AND FUNCTIONS\"\nSome jq operators (for instance, \\fB+\\fR) do different things depending on the type of their arguments (arrays, numbers, etc\\.)\\. However, jq never does implicit type conversions\\. If you try to add a string to an object you\\'ll get an error message and no result\\.\n.\n.P\nPlease note that all numbers are converted to IEEE754 double precision floating point representation\\. Arithmetic and logical operators are working with these converted doubles\\. Results of all such operations are also limited to the double precision\\.\n.\n.P\nThe only exception to this behaviour of number is a snapshot of original number literal\\. When a number which originally was provided as a literal is never mutated until the end of the program then it is printed to the output in its original literal form\\. This also includes cases when the original literal would be truncated when converted to the IEEE754 double precision floating point number\\.\n.\n.SS \"Addition: +\"\nThe operator \\fB+\\fR takes two filters, applies them both to the same input, and adds the results together\\. What \"adding\" means depends on the types involved:\n.\n.IP \"\\(bu\" 4\n\\fBNumbers\\fR are added by normal arithmetic\\.\n.\n.IP \"\\(bu\" 4\n\\fBArrays\\fR are added by being concatenated into a larger array\\.\n.\n.IP \"\\(bu\" 4\n\\fBStrings\\fR are added by being joined into a larger string\\.\n.\n.IP \"\\(bu\" 4\n\\fBObjects\\fR are added by merging, that is, inserting all the key\\-value pairs from both objects into a single combined object\\. If both objects contain a value for the same key, the object on the right of the \\fB+\\fR wins\\. (For recursive merge use the \\fB*\\fR operator\\.)\n.\n.IP \"\" 0\n.\n.P\n\\fBnull\\fR can be added to any value, and returns the other value unchanged\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.a + 1\\'\n   {\"a\": 7}\n=> 8\n\njq \\'\\.a + \\.b\\'\n   {\"a\": [1,2], \"b\": [3,4]}\n=> [1,2,3,4]\n\njq \\'\\.a + null\\'\n   {\"a\": 1}\n=> 1\n\njq \\'\\.a + 1\\'\n   {}\n=> 1\n\njq \\'{a: 1} + {b: 2} + {c: 3} + {a: 42}\\'\n   null\n=> {\"a\": 42, \"b\": 2, \"c\": 3}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Subtraction: \\-\"\nAs well as normal arithmetic subtraction on numbers, the \\fB\\-\\fR operator can be used on arrays to remove all occurrences of the second array\\'s elements from the first array\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'4 \\- \\.a\\'\n   {\"a\":3}\n=> 1\n\njq \\'\\. \\- [\"xml\", \"yaml\"]\\'\n   [\"xml\", \"yaml\", \"json\"]\n=> [\"json\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Multiplication, division, modulo: *, /, %\"\nThese infix operators behave as expected when given two numbers\\. Division by zero raises an error\\. \\fBx % y\\fR computes x modulo y\\.\n.\n.P\nMultiplying a string by a number produces the concatenation of that string that many times\\. \\fB\"x\" * 0\\fR produces \\fB\"\"\\fR\\.\n.\n.P\nDividing a string by another splits the first using the second as separators\\.\n.\n.P\nMultiplying two objects will merge them recursively: this works like addition but if both objects contain a value for the same key, and the values are objects, the two are merged with the same strategy\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'10 / \\. * 3\\'\n   5\n=> 6\n\njq \\'\\. / \", \"\\'\n   \"a, b,c,d, e\"\n=> [\"a\",\"b,c,d\",\"e\"]\n\njq \\'{\"k\": {\"a\": 1, \"b\": 2}} * {\"k\": {\"a\": 0,\"c\": 3}}\\'\n   null\n=> {\"k\": {\"a\": 0, \"b\": 2, \"c\": 3}}\n\njq \\'\\.[] | (1 / \\.)?\\'\n   [1,0,\\-1]\n=> 1, \\-1\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"abs\"\nThe builtin function \\fBabs\\fR is defined naively as: \\fBif \\. < 0 then \\- \\. else \\. end\\fR\\.\n.\n.P\nFor numeric input, this is the absolute value\\. See the section on the identity filter for the implications of this definition for numeric input\\.\n.\n.P\nTo compute the absolute value of a number as a floating point number, you may wish use \\fBfabs\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'map(abs)\\'\n   [\\-10, \\-1\\.1, \\-1e\\-1]\n=> [10,1\\.1,1e\\-1]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"length\"\nThe builtin function \\fBlength\\fR gets the length of various different types of value:\n.\n.IP \"\\(bu\" 4\nThe length of a \\fBstring\\fR is the number of Unicode codepoints it contains (which will be the same as its JSON\\-encoded length in bytes if it\\'s pure ASCII)\\.\n.\n.IP \"\\(bu\" 4\nThe length of a \\fBnumber\\fR is its absolute value\\.\n.\n.IP \"\\(bu\" 4\nThe length of an \\fBarray\\fR is the number of elements\\.\n.\n.IP \"\\(bu\" 4\nThe length of an \\fBobject\\fR is the number of key\\-value pairs\\.\n.\n.IP \"\\(bu\" 4\nThe length of \\fBnull\\fR is zero\\.\n.\n.IP \"\\(bu\" 4\nIt is an error to use \\fBlength\\fR on a \\fBboolean\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.[] | length\\'\n   [[1,2], \"string\", {\"a\":2}, null, \\-5]\n=> 2, 6, 1, 0, 5\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"utf8bytelength\"\nThe builtin function \\fButf8bytelength\\fR outputs the number of bytes used to encode a string in UTF\\-8\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'utf8bytelength\\'\n   \"\\eu03bc\"\n=> 2\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"keys, keys_unsorted\"\nThe builtin function \\fBkeys\\fR, when given an object, returns its keys in an array\\.\n.\n.P\nThe keys are sorted \"alphabetically\", by unicode codepoint order\\. This is not an order that makes particular sense in any particular language, but you can count on it being the same for any two objects with the same set of keys, regardless of locale settings\\.\n.\n.P\nWhen \\fBkeys\\fR is given an array, it returns the valid indices for that array: the integers from 0 to length\\-1\\.\n.\n.P\nThe \\fBkeys_unsorted\\fR function is just like \\fBkeys\\fR, but if the input is an object then the keys will not be sorted, instead the keys will roughly be in insertion order\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'keys\\'\n   {\"abc\": 1, \"abcd\": 2, \"Foo\": 3}\n=> [\"Foo\", \"abc\", \"abcd\"]\n\njq \\'keys\\'\n   [42,3,35]\n=> [0,1,2]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"has(key)\"\nThe builtin function \\fBhas\\fR returns whether the input object has the given key, or the input array has an element at the given index\\.\n.\n.P\n\\fBhas($key)\\fR has the same effect as checking whether \\fB$key\\fR is a member of the array returned by \\fBkeys\\fR, although \\fBhas\\fR will be faster\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'map(has(\"foo\"))\\'\n   [{\"foo\": 42}, {}]\n=> [true, false]\n\njq \\'map(has(2))\\'\n   [[0,1], [\"a\",\"b\",\"c\"]]\n=> [false, true]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"in\"\nThe builtin function \\fBin\\fR returns whether or not the input key is in the given object, or the input index corresponds to an element in the given array\\. It is, essentially, an inversed version of \\fBhas\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.[] | in({\"foo\": 42})\\'\n   [\"foo\", \"bar\"]\n=> true, false\n\njq \\'map(in([0,1]))\\'\n   [2, 0]\n=> [false, true]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"map(f), map_values(f)\"\nFor any filter \\fBf\\fR, \\fBmap(f)\\fR and \\fBmap_values(f)\\fR apply \\fBf\\fR to each of the values in the input array or object, that is, to the values of \\fB\\.[]\\fR\\.\n.\n.P\nIn the absence of errors, \\fBmap(f)\\fR always outputs an array whereas \\fBmap_values(f)\\fR outputs an array if given an array, or an object if given an object\\.\n.\n.P\nWhen the input to \\fBmap_values(f)\\fR is an object, the output object has the same keys as the input object except for those keys whose values when piped to \\fBf\\fR produce no values at all\\.\n.\n.P\nThe key difference between \\fBmap(f)\\fR and \\fBmap_values(f)\\fR is that the former simply forms an array from all the values of \\fB($x|f)\\fR for each value, \\fB$x\\fR, in the input array or object, but \\fBmap_values(f)\\fR only uses \\fBfirst($x|f)\\fR\\.\n.\n.P\nSpecifically, for object inputs, \\fBmap_values(f)\\fR constructs the output object by examining in turn the value of \\fBfirst(\\.[$k]|f)\\fR for each key, \\fB$k\\fR, of the input\\. If this expression produces no values, then the corresponding key will be dropped; otherwise, the output object will have that value at the key, \\fB$k\\fR\\.\n.\n.P\nHere are some examples to clarify the behavior of \\fBmap\\fR and \\fBmap_values\\fR when applied to arrays\\. These examples assume the input is \\fB[1]\\fR in all cases:\n.\n.IP \"\" 4\n.\n.nf\n\nmap(\\.+1)          #=>  [2]\nmap(\\., \\.)         #=>  [1,1]\nmap(empty)        #=>  []\n\nmap_values(\\.+1)   #=>  [2]\nmap_values(\\., \\.)  #=>  [1]\nmap_values(empty) #=>  []\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\n\\fBmap(f)\\fR is equivalent to \\fB[\\.[] | f]\\fR and \\fBmap_values(f)\\fR is equivalent to \\fB\\.[] |= f\\fR\\.\n.\n.P\nIn fact, these are their implementations\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'map(\\.+1)\\'\n   [1,2,3]\n=> [2,3,4]\n\njq \\'map_values(\\.+1)\\'\n   {\"a\": 1, \"b\": 2, \"c\": 3}\n=> {\"a\": 2, \"b\": 3, \"c\": 4}\n\njq \\'map(\\., \\.)\\'\n   [1,2]\n=> [1,1,2,2]\n\njq \\'map_values(\\. // empty)\\'\n   {\"a\": null, \"b\": true, \"c\": false}\n=> {\"b\":true}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"pick(pathexps)\"\nEmit the projection of the input object or array defined by the specified sequence of path expressions, such that if \\fBp\\fR is any one of these specifications, then \\fB(\\. | p)\\fR will evaluate to the same value as \\fB(\\. | pick(pathexps) | p)\\fR\\. For arrays, negative indices and \\fB\\.[m:n]\\fR specifications should not be used\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'pick(\\.a, \\.b\\.c, \\.x)\\'\n   {\"a\": 1, \"b\": {\"c\": 2, \"d\": 3}, \"e\": 4}\n=> {\"a\":1,\"b\":{\"c\":2},\"x\":null}\n\njq \\'pick(\\.[2], \\.[0], \\.[0])\\'\n   [1,2,3,4]\n=> [1,null,3]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"path(path_expression)\"\nOutputs array representations of the given path expression in \\fB\\.\\fR\\. The outputs are arrays of strings (object keys) and/or numbers (array indices)\\.\n.\n.P\nPath expressions are jq expressions like \\fB\\.a\\fR, but also \\fB\\.[]\\fR\\. There are two types of path expressions: ones that can match exactly, and ones that cannot\\. For example, \\fB\\.a\\.b\\.c\\fR is an exact match path expression, while \\fB\\.a[]\\.b\\fR is not\\.\n.\n.P\n\\fBpath(exact_path_expression)\\fR will produce the array representation of the path expression even if it does not exist in \\fB\\.\\fR, if \\fB\\.\\fR is \\fBnull\\fR or an array or an object\\.\n.\n.P\n\\fBpath(pattern)\\fR will produce array representations of the paths matching \\fBpattern\\fR if the paths exist in \\fB\\.\\fR\\.\n.\n.P\nNote that the path expressions are not different from normal expressions\\. The expression \\fBpath(\\.\\.|select(type==\"boolean\"))\\fR outputs all the paths to boolean values in \\fB\\.\\fR, and only those paths\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'path(\\.a[0]\\.b)\\'\n   null\n=> [\"a\",0,\"b\"]\n\njq \\'[path(\\.\\.)]\\'\n   {\"a\":[{\"b\":1}]}\n=> [[],[\"a\"],[\"a\",0],[\"a\",0,\"b\"]]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"del(path_expression)\"\nThe builtin function \\fBdel\\fR removes a key and its corresponding value from an object\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'del(\\.foo)\\'\n   {\"foo\": 42, \"bar\": 9001, \"baz\": 42}\n=> {\"bar\": 9001, \"baz\": 42}\n\njq \\'del(\\.[1, 2])\\'\n   [\"foo\", \"bar\", \"baz\"]\n=> [\"foo\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"getpath(PATHS)\"\nThe builtin function \\fBgetpath\\fR outputs the values in \\fB\\.\\fR found at each path in \\fBPATHS\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'getpath([\"a\",\"b\"])\\'\n   null\n=> null\n\njq \\'[getpath([\"a\",\"b\"], [\"a\",\"c\"])]\\'\n   {\"a\":{\"b\":0, \"c\":1}}\n=> [0, 1]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"setpath(PATHS; VALUE)\"\nThe builtin function \\fBsetpath\\fR sets the \\fBPATHS\\fR in \\fB\\.\\fR to \\fBVALUE\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'setpath([\"a\",\"b\"]; 1)\\'\n   null\n=> {\"a\": {\"b\": 1}}\n\njq \\'setpath([\"a\",\"b\"]; 1)\\'\n   {\"a\":{\"b\":0}}\n=> {\"a\": {\"b\": 1}}\n\njq \\'setpath([0,\"a\"]; 1)\\'\n   null\n=> [{\"a\":1}]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"delpaths(PATHS)\"\nThe builtin function \\fBdelpaths\\fR deletes the \\fBPATHS\\fR in \\fB\\.\\fR\\. \\fBPATHS\\fR must be an array of paths, where each path is an array of strings and numbers\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'delpaths([[\"a\",\"b\"]])\\'\n   {\"a\":{\"b\":1},\"x\":{\"y\":2}}\n=> {\"a\":{},\"x\":{\"y\":2}}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"to_entries, from_entries, with_entries(f)\"\nThese functions convert between an object and an array of key\\-value pairs\\. If \\fBto_entries\\fR is passed an object, then for each \\fBk: v\\fR entry in the input, the output array includes \\fB{\"key\": k, \"value\": v}\\fR\\.\n.\n.P\n\\fBfrom_entries\\fR does the opposite conversion, and \\fBwith_entries(f)\\fR is a shorthand for \\fBto_entries | map(f) | from_entries\\fR, useful for doing some operation to all keys and values of an object\\. \\fBfrom_entries\\fR accepts \\fB\"key\"\\fR, \\fB\"Key\"\\fR, \\fB\"name\"\\fR, \\fB\"Name\"\\fR, \\fB\"value\"\\fR, and \\fB\"Value\"\\fR as keys\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'to_entries\\'\n   {\"a\": 1, \"b\": 2}\n=> [{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]\n\njq \\'from_entries\\'\n   [{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]\n=> {\"a\": 1, \"b\": 2}\n\njq \\'with_entries(\\.key |= \"KEY_\" + \\.)\\'\n   {\"a\": 1, \"b\": 2}\n=> {\"KEY_a\": 1, \"KEY_b\": 2}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"select(boolean_expression)\"\nThe function \\fBselect(f)\\fR produces its input unchanged if \\fBf\\fR returns true for that input, and produces no output otherwise\\.\n.\n.P\nIt\\'s useful for filtering lists: \\fB[1,2,3] | map(select(\\. >= 2))\\fR will give you \\fB[2,3]\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'map(select(\\. >= 2))\\'\n   [1,5,3,0,7]\n=> [5,3,7]\n\njq \\'\\.[] | select(\\.id == \"second\")\\'\n   [{\"id\": \"first\", \"val\": 1}, {\"id\": \"second\", \"val\": 2}]\n=> {\"id\": \"second\", \"val\": 2}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"arrays, objects, iterables, booleans, numbers, normals, finites, strings, nulls, values, scalars\"\nThese built\\-ins select only inputs that are arrays, objects, iterables (arrays or objects), booleans, numbers, normal numbers, finite numbers, strings, null, non\\-null values, and non\\-iterables, respectively\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.[]|numbers\\'\n   [[],{},1,\"foo\",null,true,false]\n=> 1\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"empty\"\n\\fBempty\\fR returns no results\\. None at all\\. Not even \\fBnull\\fR\\.\n.\n.P\nIt\\'s useful on occasion\\. You\\'ll know if you need it :)\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'1, empty, 2\\'\n   null\n=> 1, 2\n\njq \\'[1,2,empty,3]\\'\n   null\n=> [1,2,3]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"error, error(message)\"\nProduces an error with the input value, or with the message given as the argument\\. Errors can be caught with try/catch; see below\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'try error catch \\.\\'\n   \"error message\"\n=> \"error message\"\n\njq \\'try error(\"invalid value: \\e(\\.)\") catch \\.\\'\n   42\n=> \"invalid value: 42\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"halt\"\nStops the jq program with no further outputs\\. jq will exit with exit status \\fB0\\fR\\.\n.\n.SS \"halt_error, halt_error(exit_code)\"\nStops the jq program with no further outputs\\. The input will be printed on \\fBstderr\\fR as raw output (i\\.e\\., strings will not have double quotes) with no decoration, not even a newline\\.\n.\n.P\nThe given \\fBexit_code\\fR (defaulting to \\fB5\\fR) will be jq\\'s exit status\\.\n.\n.P\nFor example, \\fB\"Error: something went wrong\\en\"|halt_error(1)\\fR\\.\n.\n.SS \"$__loc__\"\nProduces an object with a \"file\" key and a \"line\" key, with the filename and line number where \\fB$__loc__\\fR occurs, as values\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'try error(\"\\e($__loc__)\") catch \\.\\'\n   null\n=> \"{\\e\"file\\e\":\\e\"<top\\-level>\\e\",\\e\"line\\e\":1}\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"paths, paths(node_filter)\"\n\\fBpaths\\fR outputs the paths to all the elements in its input (except it does not output the empty list, representing \\. itself)\\.\n.\n.P\n\\fBpaths(f)\\fR outputs the paths to any values for which \\fBf\\fR is \\fBtrue\\fR\\. That is, \\fBpaths(type == \"number\")\\fR outputs the paths to all numeric values\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[paths]\\'\n   [1,[[],{\"a\":2}]]\n=> [[0],[1],[1,0],[1,1],[1,1,\"a\"]]\n\njq \\'[paths(type == \"number\")]\\'\n   [1,[[],{\"a\":2}]]\n=> [[0],[1,1,\"a\"]]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"add, add(generator)\"\nThe filter \\fBadd\\fR takes as input an array, and produces as output the elements of the array added together\\. This might mean summed, concatenated or merged depending on the types of the elements of the input array \\- the rules are the same as those for the \\fB+\\fR operator (described above)\\.\n.\n.P\nIf the input is an empty array, \\fBadd\\fR returns \\fBnull\\fR\\.\n.\n.P\n\\fBadd(generator)\\fR operates on the given generator rather than the input\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'add\\'\n   [\"a\",\"b\",\"c\"]\n=> \"abc\"\n\njq \\'add\\'\n   [1, 2, 3]\n=> 6\n\njq \\'add\\'\n   []\n=> null\n\njq \\'add(\\.[]\\.a)\\'\n   [{\"a\":3}, {\"a\":5}, {\"b\":6}]\n=> 8\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"any, any(condition), any(generator; condition)\"\nThe filter \\fBany\\fR takes as input an array of boolean values, and produces \\fBtrue\\fR as output if any of the elements of the array are \\fBtrue\\fR\\.\n.\n.P\nIf the input is an empty array, \\fBany\\fR returns \\fBfalse\\fR\\.\n.\n.P\nThe \\fBany(condition)\\fR form applies the given condition to the elements of the input array\\.\n.\n.P\nThe \\fBany(generator; condition)\\fR form applies the given condition to all the outputs of the given generator\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'any\\'\n   [true, false]\n=> true\n\njq \\'any\\'\n   [false, false]\n=> false\n\njq \\'any\\'\n   []\n=> false\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"all, all(condition), all(generator; condition)\"\nThe filter \\fBall\\fR takes as input an array of boolean values, and produces \\fBtrue\\fR as output if all of the elements of the array are \\fBtrue\\fR\\.\n.\n.P\nThe \\fBall(condition)\\fR form applies the given condition to the elements of the input array\\.\n.\n.P\nThe \\fBall(generator; condition)\\fR form applies the given condition to all the outputs of the given generator\\.\n.\n.P\nIf the input is an empty array, \\fBall\\fR returns \\fBtrue\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'all\\'\n   [true, false]\n=> false\n\njq \\'all\\'\n   [true, true]\n=> true\n\njq \\'all\\'\n   []\n=> true\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"flatten, flatten(depth)\"\nThe filter \\fBflatten\\fR takes as input an array of nested arrays, and produces a flat array in which all arrays inside the original array have been recursively replaced by their values\\. You can pass an argument to it to specify how many levels of nesting to flatten\\.\n.\n.P\n\\fBflatten(2)\\fR is like \\fBflatten\\fR, but going only up to two levels deep\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'flatten\\'\n   [1, [2], [[3]]]\n=> [1, 2, 3]\n\njq \\'flatten(1)\\'\n   [1, [2], [[3]]]\n=> [1, 2, [3]]\n\njq \\'flatten\\'\n   [[]]\n=> []\n\njq \\'flatten\\'\n   [{\"foo\": \"bar\"}, [{\"foo\": \"baz\"}]]\n=> [{\"foo\": \"bar\"}, {\"foo\": \"baz\"}]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"range(upto), range(from; upto), range(from; upto; by)\"\nThe \\fBrange\\fR function produces a range of numbers\\. \\fBrange(4; 10)\\fR produces 6 numbers, from 4 (inclusive) to 10 (exclusive)\\. The numbers are produced as separate outputs\\. Use \\fB[range(4; 10)]\\fR to get a range as an array\\.\n.\n.P\nThe one argument form generates numbers from 0 to the given number, with an increment of 1\\.\n.\n.P\nThe two argument form generates numbers from \\fBfrom\\fR to \\fBupto\\fR with an increment of 1\\.\n.\n.P\nThe three argument form generates numbers \\fBfrom\\fR to \\fBupto\\fR with an increment of \\fBby\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'range(2; 4)\\'\n   null\n=> 2, 3\n\njq \\'[range(2; 4)]\\'\n   null\n=> [2,3]\n\njq \\'[range(4)]\\'\n   null\n=> [0,1,2,3]\n\njq \\'[range(0; 10; 3)]\\'\n   null\n=> [0,3,6,9]\n\njq \\'[range(0; 10; \\-1)]\\'\n   null\n=> []\n\njq \\'[range(0; \\-5; \\-1)]\\'\n   null\n=> [0,\\-1,\\-2,\\-3,\\-4]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"floor\"\nThe \\fBfloor\\fR function returns the floor of its numeric input\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'floor\\'\n   3\\.14159\n=> 3\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"sqrt\"\nThe \\fBsqrt\\fR function returns the square root of its numeric input\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'sqrt\\'\n   9\n=> 3\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"tonumber\"\nThe \\fBtonumber\\fR function parses its input as a number\\. It will convert correctly\\-formatted strings to their numeric equivalent, leave numbers alone, and give an error on all other input\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.[] | tonumber\\'\n   [1, \"1\"]\n=> 1, 1\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"toboolean\"\nThe \\fBtoboolean\\fR function parses its input as a boolean\\. It will convert correctly\\-formatted strings to their boolean equivalent, leave booleans alone, and give an error on all other input\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.[] | toboolean\\'\n   [\"true\", \"false\", true, false]\n=> true, false, true, false\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"tostring\"\nThe \\fBtostring\\fR function prints its input as a string\\. Strings are left unchanged, and all other values are JSON\\-encoded\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.[] | tostring\\'\n   [1, \"1\", [1]]\n=> \"1\", \"1\", \"[1]\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"type\"\nThe \\fBtype\\fR function returns the type of its argument as a string, which is one of null, boolean, number, string, array or object\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'map(type)\\'\n   [0, false, [], {}, null, \"hello\"]\n=> [\"number\", \"boolean\", \"array\", \"object\", \"null\", \"string\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"infinite, nan, isinfinite, isnan, isfinite, isnormal\"\nSome arithmetic operations can yield infinities and \"not a number\" (NaN) values\\. The \\fBisinfinite\\fR builtin returns \\fBtrue\\fR if its input is infinite\\. The \\fBisnan\\fR builtin returns \\fBtrue\\fR if its input is a NaN\\. The \\fBinfinite\\fR builtin returns a positive infinite value\\. The \\fBnan\\fR builtin returns a NaN\\. The \\fBisnormal\\fR builtin returns true if its input is a normal number\\.\n.\n.P\nNote that division by zero raises an error\\.\n.\n.P\nCurrently most arithmetic operations operating on infinities, NaNs, and sub\\-normals do not raise errors\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.[] | (infinite * \\.) < 0\\'\n   [\\-1, 1]\n=> true, false\n\njq \\'infinite, nan | type\\'\n   null\n=> \"number\", \"number\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"sort, sort_by(path_expression)\"\nThe \\fBsort\\fR functions sorts its input, which must be an array\\. Values are sorted in the following order:\n.\n.IP \"\\(bu\" 4\n\\fBnull\\fR\n.\n.IP \"\\(bu\" 4\n\\fBfalse\\fR\n.\n.IP \"\\(bu\" 4\n\\fBtrue\\fR\n.\n.IP \"\\(bu\" 4\nnumbers\n.\n.IP \"\\(bu\" 4\nstrings, in alphabetical order (by unicode codepoint value)\n.\n.IP \"\\(bu\" 4\narrays, in lexical order\n.\n.IP \"\\(bu\" 4\nobjects\n.\n.IP \"\" 0\n.\n.P\nThe ordering for objects is a little complex: first they\\'re compared by comparing their sets of keys (as arrays in sorted order), and if their keys are equal then the values are compared key by key\\.\n.\n.P\n\\fBsort_by\\fR may be used to sort by a particular field of an object, or by applying any jq filter\\. \\fBsort_by(f)\\fR compares two elements by comparing the result of \\fBf\\fR on each element\\. When \\fBf\\fR produces multiple values, it firstly compares the first values, and the second values if the first values are equal, and so on\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'sort\\'\n   [8,3,null,6]\n=> [null,3,6,8]\n\njq \\'sort_by(\\.foo)\\'\n   [{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":10}, {\"foo\":2, \"bar\":1}]\n=> [{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":4, \"bar\":10}]\n\njq \\'sort_by(\\.foo, \\.bar)\\'\n   [{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}]\n=> [{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":4, \"bar\":10}]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"group_by(path_expression)\"\n\\fBgroup_by(\\.foo)\\fR takes as input an array, groups the elements having the same \\fB\\.foo\\fR field into separate arrays, and produces all of these arrays as elements of a larger array, sorted by the value of the \\fB\\.foo\\fR field\\.\n.\n.P\nAny jq expression, not just a field access, may be used in place of \\fB\\.foo\\fR\\. The sorting order is the same as described in the \\fBsort\\fR function above\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'group_by(\\.foo)\\'\n   [{\"foo\":1, \"bar\":10}, {\"foo\":3, \"bar\":100}, {\"foo\":1, \"bar\":1}]\n=> [[{\"foo\":1, \"bar\":10}, {\"foo\":1, \"bar\":1}], [{\"foo\":3, \"bar\":100}]]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"min, max, min_by(path_exp), max_by(path_exp)\"\nFind the minimum or maximum element of the input array\\.\n.\n.P\nThe \\fBmin_by(path_exp)\\fR and \\fBmax_by(path_exp)\\fR functions allow you to specify a particular field or property to examine, e\\.g\\. \\fBmin_by(\\.foo)\\fR finds the object with the smallest \\fBfoo\\fR field\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'min\\'\n   [5,4,2,7]\n=> 2\n\njq \\'max_by(\\.foo)\\'\n   [{\"foo\":1, \"bar\":14}, {\"foo\":2, \"bar\":3}]\n=> {\"foo\":2, \"bar\":3}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"unique, unique_by(path_exp)\"\nThe \\fBunique\\fR function takes as input an array and produces an array of the same elements, in sorted order, with duplicates removed\\.\n.\n.P\nThe \\fBunique_by(path_exp)\\fR function will keep only one element for each value obtained by applying the argument\\. Think of it as making an array by taking one element out of every group produced by \\fBgroup\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'unique\\'\n   [1,2,5,3,5,3,1,3]\n=> [1,2,3,5]\n\njq \\'unique_by(\\.foo)\\'\n   [{\"foo\": 1, \"bar\": 2}, {\"foo\": 1, \"bar\": 3}, {\"foo\": 4, \"bar\": 5}]\n=> [{\"foo\": 1, \"bar\": 2}, {\"foo\": 4, \"bar\": 5}]\n\njq \\'unique_by(length)\\'\n   [\"chunky\", \"bacon\", \"kitten\", \"cicada\", \"asparagus\"]\n=> [\"bacon\", \"chunky\", \"asparagus\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"reverse\"\nThis function reverses an array\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'reverse\\'\n   [1,2,3,4]\n=> [4,3,2,1]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"contains(element)\"\nThe filter \\fBcontains(b)\\fR will produce true if b is completely contained within the input\\. A string B is contained in a string A if B is a substring of A\\. An array B is contained in an array A if all elements in B are contained in any element in A\\. An object B is contained in object A if all of the values in B are contained in the value in A with the same key\\. All other types are assumed to be contained in each other if they are equal\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'contains(\"bar\")\\'\n   \"foobar\"\n=> true\n\njq \\'contains([\"baz\", \"bar\"])\\'\n   [\"foobar\", \"foobaz\", \"blarp\"]\n=> true\n\njq \\'contains([\"bazzzzz\", \"bar\"])\\'\n   [\"foobar\", \"foobaz\", \"blarp\"]\n=> false\n\njq \\'contains({foo: 12, bar: [{barp: 12}]})\\'\n   {\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}\n=> true\n\njq \\'contains({foo: 12, bar: [{barp: 15}]})\\'\n   {\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}\n=> false\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"indices(s)\"\nOutputs an array containing the indices in \\fB\\.\\fR where \\fBs\\fR occurs\\. The input may be an array, in which case if \\fBs\\fR is an array then the indices output will be those where all elements in \\fB\\.\\fR match those of \\fBs\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'indices(\", \")\\'\n   \"a,b, cd, efg, hijk\"\n=> [3,7,12]\n\njq \\'indices(1)\\'\n   [0,1,2,1,3,1,4]\n=> [1,3,5]\n\njq \\'indices([1,2])\\'\n   [0,1,2,3,1,4,2,5,1,2,6,7]\n=> [1,8]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"index(s), rindex(s)\"\nOutputs the index of the first (\\fBindex\\fR) or last (\\fBrindex\\fR) occurrence of \\fBs\\fR in the input\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'index(\", \")\\'\n   \"a,b, cd, efg, hijk\"\n=> 3\n\njq \\'index(1)\\'\n   [0,1,2,1,3,1,4]\n=> 1\n\njq \\'index([1,2])\\'\n   [0,1,2,3,1,4,2,5,1,2,6,7]\n=> 1\n\njq \\'rindex(\", \")\\'\n   \"a,b, cd, efg, hijk\"\n=> 12\n\njq \\'rindex(1)\\'\n   [0,1,2,1,3,1,4]\n=> 5\n\njq \\'rindex([1,2])\\'\n   [0,1,2,3,1,4,2,5,1,2,6,7]\n=> 8\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"inside\"\nThe filter \\fBinside(b)\\fR will produce true if the input is completely contained within b\\. It is, essentially, an inversed version of \\fBcontains\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'inside(\"foobar\")\\'\n   \"bar\"\n=> true\n\njq \\'inside([\"foobar\", \"foobaz\", \"blarp\"])\\'\n   [\"baz\", \"bar\"]\n=> true\n\njq \\'inside([\"foobar\", \"foobaz\", \"blarp\"])\\'\n   [\"bazzzzz\", \"bar\"]\n=> false\n\njq \\'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})\\'\n   {\"foo\": 12, \"bar\": [{\"barp\": 12}]}\n=> true\n\njq \\'inside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})\\'\n   {\"foo\": 12, \"bar\": [{\"barp\": 15}]}\n=> false\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"startswith(str)\"\nOutputs \\fBtrue\\fR if \\. starts with the given string argument\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[\\.[]|startswith(\"foo\")]\\'\n   [\"fo\", \"foo\", \"barfoo\", \"foobar\", \"barfoob\"]\n=> [false, true, false, true, false]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"endswith(str)\"\nOutputs \\fBtrue\\fR if \\. ends with the given string argument\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[\\.[]|endswith(\"foo\")]\\'\n   [\"foobar\", \"barfoo\"]\n=> [false, true]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"combinations, combinations(n)\"\nOutputs all combinations of the elements of the arrays in the input array\\. If given an argument \\fBn\\fR, it outputs all combinations of \\fBn\\fR repetitions of the input array\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'combinations\\'\n   [[1,2], [3, 4]]\n=> [1, 3], [1, 4], [2, 3], [2, 4]\n\njq \\'combinations(2)\\'\n   [0, 1]\n=> [0, 0], [0, 1], [1, 0], [1, 1]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"ltrimstr(str)\"\nOutputs its input with the given prefix string removed, if it starts with it\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[\\.[]|ltrimstr(\"foo\")]\\'\n   [\"fo\", \"foo\", \"barfoo\", \"foobar\", \"afoo\"]\n=> [\"fo\",\"\",\"barfoo\",\"bar\",\"afoo\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"rtrimstr(str)\"\nOutputs its input with the given suffix string removed, if it ends with it\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[\\.[]|rtrimstr(\"foo\")]\\'\n   [\"fo\", \"foo\", \"barfoo\", \"foobar\", \"foob\"]\n=> [\"fo\",\"\",\"bar\",\"foobar\",\"foob\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"trimstr(str)\"\nOutputs its input with the given string removed at both ends, if it starts or ends with it\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[\\.[]|trimstr(\"foo\")]\\'\n   [\"fo\", \"foo\", \"barfoo\", \"foobarfoo\", \"foob\"]\n=> [\"fo\",\"\",\"bar\",\"bar\",\"b\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"trim, ltrim, rtrim\"\n\\fBtrim\\fR trims both leading and trailing whitespace\\.\n.\n.P\n\\fBltrim\\fR trims only leading (left side) whitespace\\.\n.\n.P\n\\fBrtrim\\fR trims only trailing (right side) whitespace\\.\n.\n.P\nWhitespace characters are the usual \\fB\" \"\\fR, \\fB\"\\en\"\\fR \\fB\"\\et\"\\fR, \\fB\"\\er\"\\fR and also all characters in the Unicode character database with the whitespace property\\. Note that what considers whitespace might change in the future\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'trim, ltrim, rtrim\\'\n   \" abc \"\n=> \"abc\", \"abc \", \" abc\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"explode\"\nConverts an input string into an array of the string\\'s codepoint numbers\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'explode\\'\n   \"foobar\"\n=> [102,111,111,98,97,114]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"implode\"\nThe inverse of explode\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'implode\\'\n   [65, 66, 67]\n=> \"ABC\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"split(str)\"\nSplits an input string on the separator argument\\.\n.\n.P\n\\fBsplit\\fR can also split on regex matches when called with two arguments (see the regular expressions section below)\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'split(\", \")\\'\n   \"a, b,c,d, e, \"\n=> [\"a\",\"b,c,d\",\"e\",\"\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"join(str)\"\nJoins the array of elements given as input, using the argument as separator\\. It is the inverse of \\fBsplit\\fR: that is, running \\fBsplit(\"foo\") | join(\"foo\")\\fR over any input string returns said input string\\.\n.\n.P\nNumbers and booleans in the input are converted to strings\\. Null values are treated as empty strings\\. Arrays and objects in the input are not supported\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'join(\", \")\\'\n   [\"a\",\"b,c,d\",\"e\"]\n=> \"a, b,c,d, e\"\n\njq \\'join(\" \")\\'\n   [\"a\",1,2\\.3,true,null,false]\n=> \"a 1 2\\.3 true  false\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"ascii_downcase, ascii_upcase\"\nEmit a copy of the input string with its alphabetic characters (a\\-z and A\\-Z) converted to the specified case\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'ascii_upcase\\'\n   \"useful but not for é\"\n=> \"USEFUL BUT NOT FOR é\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"while(cond; update)\"\nThe \\fBwhile(cond; update)\\fR function allows you to repeatedly apply an update to \\fB\\.\\fR until \\fBcond\\fR is false\\.\n.\n.P\nNote that \\fBwhile(cond; update)\\fR is internally defined as a recursive jq function\\. Recursive calls within \\fBwhile\\fR will not consume additional memory if \\fBupdate\\fR produces at most one output for each input\\. See advanced topics below\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[while(\\.<100; \\.*2)]\\'\n   1\n=> [1,2,4,8,16,32,64]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"repeat(exp)\"\nThe \\fBrepeat(exp)\\fR function allows you to repeatedly apply expression \\fBexp\\fR to \\fB\\.\\fR until an error is raised\\.\n.\n.P\nNote that \\fBrepeat(exp)\\fR is internally defined as a recursive jq function\\. Recursive calls within \\fBrepeat\\fR will not consume additional memory if \\fBexp\\fR produces at most one output for each input\\. See advanced topics below\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[repeat(\\.*2, error)?]\\'\n   1\n=> [2]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"until(cond; next)\"\nThe \\fBuntil(cond; next)\\fR function allows you to repeatedly apply the expression \\fBnext\\fR, initially to \\fB\\.\\fR then to its own output, until \\fBcond\\fR is true\\. For example, this can be used to implement a factorial function (see below)\\.\n.\n.P\nNote that \\fBuntil(cond; next)\\fR is internally defined as a recursive jq function\\. Recursive calls within \\fBuntil()\\fR will not consume additional memory if \\fBnext\\fR produces at most one output for each input\\. See advanced topics below\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[\\.,1]|until(\\.[0] < 1; [\\.[0] \\- 1, \\.[1] * \\.[0]])|\\.[1]\\'\n   4\n=> 24\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"recurse(f), recurse, recurse(f; condition)\"\nThe \\fBrecurse(f)\\fR function allows you to search through a recursive structure, and extract interesting data from all levels\\. Suppose your input represents a filesystem:\n.\n.IP \"\" 4\n.\n.nf\n\n{\"name\": \"/\", \"children\": [\n  {\"name\": \"/bin\", \"children\": [\n    {\"name\": \"/bin/ls\", \"children\": []},\n    {\"name\": \"/bin/sh\", \"children\": []}]},\n  {\"name\": \"/home\", \"children\": [\n    {\"name\": \"/home/stephen\", \"children\": [\n      {\"name\": \"/home/stephen/jq\", \"children\": []}]}]}]}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nNow suppose you want to extract all of the filenames present\\. You need to retrieve \\fB\\.name\\fR, \\fB\\.children[]\\.name\\fR, \\fB\\.children[]\\.children[]\\.name\\fR, and so on\\. You can do this with:\n.\n.IP \"\" 4\n.\n.nf\n\nrecurse(\\.children[]) | \\.name\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nWhen called without an argument, \\fBrecurse\\fR is equivalent to \\fBrecurse(\\.[]?)\\fR\\.\n.\n.P\n\\fBrecurse(f)\\fR is identical to \\fBrecurse(f; true)\\fR and can be used without concerns about recursion depth\\.\n.\n.P\n\\fBrecurse(f; condition)\\fR is a generator which begins by emitting \\. and then emits in turn \\.|f, \\.|f|f, \\.|f|f|f, \\.\\.\\. so long as the computed value satisfies the condition\\. For example, to generate all the integers, at least in principle, one could write \\fBrecurse(\\.+1; true)\\fR\\.\n.\n.P\nThe recursive calls in \\fBrecurse\\fR will not consume additional memory whenever \\fBf\\fR produces at most a single output for each input\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'recurse(\\.foo[])\\'\n   {\"foo\":[{\"foo\": []}, {\"foo\":[{\"foo\":[]}]}]}\n=> {\"foo\":[{\"foo\":[]},{\"foo\":[{\"foo\":[]}]}]}, {\"foo\":[]}, {\"foo\":[{\"foo\":[]}]}, {\"foo\":[]}\n\njq \\'recurse\\'\n   {\"a\":0,\"b\":[1]}\n=> {\"a\":0,\"b\":[1]}, 0, [1], 1\n\njq \\'recurse(\\. * \\.; \\. < 20)\\'\n   2\n=> 2, 4, 16\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"walk(f)\"\nThe \\fBwalk(f)\\fR function applies f recursively to every component of the input entity\\. When an array is encountered, f is first applied to its elements and then to the array itself; when an object is encountered, f is first applied to all the values and then to the object\\. In practice, f will usually test the type of its input, as illustrated in the following examples\\. The first example highlights the usefulness of processing the elements of an array of arrays before processing the array itself\\. The second example shows how all the keys of all the objects within the input can be considered for alteration\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'walk(if type == \"array\" then sort else \\. end)\\'\n   [[4, 1, 7], [8, 5, 2], [3, 6, 9]]\n=> [[1,4,7],[2,5,8],[3,6,9]]\n\njq \\'walk( if type == \"object\" then with_entries( \\.key |= sub( \"^_+\"; \"\") ) else \\. end )\\'\n   [ { \"_a\": { \"__b\": 2 } } ]\n=> [{\"a\":{\"b\":2}}]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"have_literal_numbers\"\nThis builtin returns true if jq\\'s build configuration includes support for preservation of input number literals\\.\n.\n.SS \"have_decnum\"\nThis builtin returns true if jq was built with \"decnum\", which is the current literal number preserving numeric backend implementation for jq\\.\n.\n.SS \"$JQ_BUILD_CONFIGURATION\"\nThis builtin binding shows the jq executable\\'s build configuration\\. Its value has no particular format, but it can be expected to be at least the \\fB\\./configure\\fR command\\-line arguments, and may be enriched in the future to include the version strings for the build tooling used\\.\n.\n.P\nNote that this can be overridden in the command\\-line with \\fB\\-\\-arg\\fR and related options\\.\n.\n.SS \"$ENV, env\"\n\\fB$ENV\\fR is an object representing the environment variables as set when the jq program started\\.\n.\n.P\n\\fBenv\\fR outputs an object representing jq\\'s current environment\\.\n.\n.P\nAt the moment there is no builtin for setting environment variables\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'$ENV\\.PAGER\\'\n   null\n=> \"less\"\n\njq \\'env\\.PAGER\\'\n   null\n=> \"less\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"transpose\"\nTranspose a possibly jagged matrix (an array of arrays)\\. Rows are padded with nulls so the result is always rectangular\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'transpose\\'\n   [[1], [2,3]]\n=> [[1,2],[null,3]]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"bsearch(x)\"\n\\fBbsearch(x)\\fR conducts a binary search for x in the input array\\. If the input is sorted and contains x, then \\fBbsearch(x)\\fR will return its index in the array; otherwise, if the array is sorted, it will return (\\-1 \\- ix) where ix is an insertion point such that the array would still be sorted after the insertion of x at ix\\. If the array is not sorted, \\fBbsearch(x)\\fR will return an integer that is probably of no interest\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'bsearch(0)\\'\n   [0,1]\n=> 0\n\njq \\'bsearch(0)\\'\n   [1,2,3]\n=> \\-1\n\njq \\'bsearch(4) as $ix | if $ix < 0 then \\.[\\-(1+$ix)] = 4 else \\. end\\'\n   [1,2,3]\n=> [1,2,3,4]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"String interpolation: \\e(exp)\"\nInside a string, you can put an expression inside parens after a backslash\\. Whatever the expression returns will be interpolated into the string\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\"The input was \\e(\\.), which is one less than \\e(\\.+1)\"\\'\n   42\n=> \"The input was 42, which is one less than 43\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Convert to/from JSON\"\nThe \\fBtojson\\fR and \\fBfromjson\\fR builtins dump values as JSON texts or parse JSON texts into values, respectively\\. The \\fBtojson\\fR builtin differs from \\fBtostring\\fR in that \\fBtostring\\fR returns strings unmodified, while \\fBtojson\\fR encodes strings as JSON strings\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[\\.[]|tostring]\\'\n   [1, \"foo\", [\"foo\"]]\n=> [\"1\",\"foo\",\"[\\e\"foo\\e\"]\"]\n\njq \\'[\\.[]|tojson]\\'\n   [1, \"foo\", [\"foo\"]]\n=> [\"1\",\"\\e\"foo\\e\"\",\"[\\e\"foo\\e\"]\"]\n\njq \\'[\\.[]|tojson|fromjson]\\'\n   [1, \"foo\", [\"foo\"]]\n=> [1,\"foo\",[\"foo\"]]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Format strings and escaping\"\nThe \\fB@foo\\fR syntax is used to format and escape strings, which is useful for building URLs, documents in a language like HTML or XML, and so forth\\. \\fB@foo\\fR can be used as a filter on its own, the possible escapings are:\n.\n.TP\n\\fB@text\\fR:\n.\n.IP\nCalls \\fBtostring\\fR, see that function for details\\.\n.\n.TP\n\\fB@json\\fR:\n.\n.IP\nSerializes the input as JSON\\.\n.\n.TP\n\\fB@html\\fR:\n.\n.IP\nApplies HTML/XML escaping, by mapping the characters \\fB<>&\\'\"\\fR to their entity equivalents \\fB&lt;\\fR, \\fB&gt;\\fR, \\fB&amp;\\fR, \\fB&apos;\\fR, \\fB&quot;\\fR\\.\n.\n.TP\n\\fB@uri\\fR:\n.\n.IP\nApplies percent\\-encoding, by mapping all reserved URI characters to a \\fB%XX\\fR sequence\\.\n.\n.TP\n\\fB@urid\\fR:\n.\n.IP\nThe inverse of \\fB@uri\\fR, applies percent\\-decoding, by mapping all \\fB%XX\\fR sequences to their corresponding URI characters\\.\n.\n.TP\n\\fB@csv\\fR:\n.\n.IP\nThe input must be an array, and it is rendered as CSV with double quotes for strings, and quotes escaped by repetition\\.\n.\n.TP\n\\fB@tsv\\fR:\n.\n.IP\nThe input must be an array, and it is rendered as TSV (tab\\-separated values)\\. Each input array will be printed as a single line\\. Fields are separated by a single tab (ascii \\fB0x09\\fR)\\. Input characters line\\-feed (ascii \\fB0x0a\\fR), carriage\\-return (ascii \\fB0x0d\\fR), tab (ascii \\fB0x09\\fR) and backslash (ascii \\fB0x5c\\fR) will be output as escape sequences \\fB\\en\\fR, \\fB\\er\\fR, \\fB\\et\\fR, \\fB\\e\\e\\fR respectively\\.\n.\n.TP\n\\fB@sh\\fR:\n.\n.IP\nThe input is escaped suitable for use in a command\\-line for a POSIX shell\\. If the input is an array, the output will be a series of space\\-separated strings\\.\n.\n.TP\n\\fB@base64\\fR:\n.\n.IP\nThe input is converted to base64 as specified by RFC 4648\\.\n.\n.TP\n\\fB@base64d\\fR:\n.\n.IP\nThe inverse of \\fB@base64\\fR, input is decoded as specified by RFC 4648\\. Note\\e: If the decoded string is not UTF\\-8, the results are undefined\\.\n.\n.P\nThis syntax can be combined with string interpolation in a useful way\\. You can follow a \\fB@foo\\fR token with a string literal\\. The contents of the string literal will \\fInot\\fR be escaped\\. However, all interpolations made inside that string literal will be escaped\\. For instance,\n.\n.IP \"\" 4\n.\n.nf\n\n@uri \"https://www\\.google\\.com/search?q=\\e(\\.search)\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nwill produce the following output for the input \\fB{\"search\":\"what is jq?\"}\\fR:\n.\n.IP \"\" 4\n.\n.nf\n\n\"https://www\\.google\\.com/search?q=what%20is%20jq%3F\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nNote that the slashes, question mark, etc\\. in the URL are not escaped, as they were part of the string literal\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'@html\\'\n   \"This works if x < y\"\n=> \"This works if x &lt; y\"\n\njq \\'@sh \"echo \\e(\\.)\"\\'\n   \"O\\'Hara\\'s Ale\"\n=> \"echo \\'O\\'\\e\\e\\'\\'Hara\\'\\e\\e\\'\\'s Ale\\'\"\n\njq \\'@base64\\'\n   \"This is a message\"\n=> \"VGhpcyBpcyBhIG1lc3NhZ2U=\"\n\njq \\'@base64d\\'\n   \"VGhpcyBpcyBhIG1lc3NhZ2U=\"\n=> \"This is a message\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Dates\"\njq provides some basic date handling functionality, with some high\\-level and low\\-level builtins\\. In all cases these builtins deal exclusively with time in UTC\\.\n.\n.P\nThe \\fBfromdateiso8601\\fR builtin parses datetimes in the ISO 8601 format to a number of seconds since the Unix epoch (1970\\-01\\-01T00:00:00Z)\\. The \\fBtodateiso8601\\fR builtin does the inverse\\.\n.\n.P\nThe \\fBfromdate\\fR builtin parses datetime strings\\. Currently \\fBfromdate\\fR only supports ISO 8601 datetime strings, but in the future it will attempt to parse datetime strings in more formats\\.\n.\n.P\nThe \\fBtodate\\fR builtin is an alias for \\fBtodateiso8601\\fR\\.\n.\n.P\nThe \\fBnow\\fR builtin outputs the current time, in seconds since the Unix epoch\\.\n.\n.P\nLow\\-level jq interfaces to the C\\-library time functions are also provided: \\fBstrptime\\fR, \\fBstrftime\\fR, \\fBstrflocaltime\\fR, \\fBmktime\\fR, \\fBgmtime\\fR, and \\fBlocaltime\\fR\\. Refer to your host operating system\\'s documentation for the format strings used by \\fBstrptime\\fR and \\fBstrftime\\fR\\. Note: these are not necessarily stable interfaces in jq, particularly as to their localization functionality\\.\n.\n.P\nThe \\fBgmtime\\fR builtin consumes a number of seconds since the Unix epoch and outputs a \"broken down time\" representation of Greenwich Mean Time as an array of numbers representing (in this order): the year, the month (zero\\-based), the day of the month (one\\-based), the hour of the day, the minute of the hour, the second of the minute, the day of the week, and the day of the year \\-\\- all one\\-based unless otherwise stated\\. The day of the week number may be wrong on some systems for dates before March 1st 1900, or after December 31 2099\\.\n.\n.P\nThe \\fBlocaltime\\fR builtin works like the \\fBgmtime\\fR builtin, but using the local timezone setting\\.\n.\n.P\nThe \\fBmktime\\fR builtin consumes \"broken down time\" representations of time output by \\fBgmtime\\fR and \\fBstrptime\\fR\\.\n.\n.P\nThe \\fBstrptime(fmt)\\fR builtin parses input strings matching the \\fBfmt\\fR argument\\. The output is in the \"broken down time\" representation consumed by \\fBmktime\\fR and output by \\fBgmtime\\fR\\.\n.\n.P\nThe \\fBstrftime(fmt)\\fR builtin formats a time (GMT) with the given format\\. The \\fBstrflocaltime\\fR does the same, but using the local timezone setting\\.\n.\n.P\nThe format strings for \\fBstrptime\\fR and \\fBstrftime\\fR are described in typical C library documentation\\. The format string for ISO 8601 datetime is \\fB\"%Y\\-%m\\-%dT%H:%M:%SZ\"\\fR\\.\n.\n.P\njq may not support some or all of this date functionality on some systems\\. In particular, the \\fB%u\\fR and \\fB%j\\fR specifiers for \\fBstrptime(fmt)\\fR are not supported on macOS\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'fromdate\\'\n   \"2015\\-03\\-05T23:51:47Z\"\n=> 1425599507\n\njq \\'strptime(\"%Y\\-%m\\-%dT%H:%M:%SZ\")\\'\n   \"2015\\-03\\-05T23:51:47Z\"\n=> [2015,2,5,23,51,47,4,63]\n\njq \\'strptime(\"%Y\\-%m\\-%dT%H:%M:%SZ\")|mktime\\'\n   \"2015\\-03\\-05T23:51:47Z\"\n=> 1425599507\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"SQL\\-Style Operators\"\njq provides a few SQL\\-style operators\\.\n.\n.TP\n\\fBINDEX(stream; index_expression)\\fR:\n.\n.IP\nThis builtin produces an object whose keys are computed by the given index expression applied to each value from the given stream\\.\n.\n.TP\n\\fBJOIN($idx; stream; idx_expr; join_expr)\\fR:\n.\n.IP\nThis builtin joins the values from the given stream to the given index\\. The index\\'s keys are computed by applying the given index expression to each value from the given stream\\. An array of the value in the stream and the corresponding value from the index is fed to the given join expression to produce each result\\.\n.\n.TP\n\\fBJOIN($idx; stream; idx_expr)\\fR:\n.\n.IP\nSame as \\fBJOIN($idx; stream; idx_expr; \\.)\\fR\\.\n.\n.TP\n\\fBJOIN($idx; idx_expr)\\fR:\n.\n.IP\nThis builtin joins the input \\fB\\.\\fR to the given index, applying the given index expression to \\fB\\.\\fR to compute the index key\\. The join operation is as described above\\.\n.\n.TP\n\\fBIN(s)\\fR:\n.\n.IP\nThis builtin outputs \\fBtrue\\fR if \\fB\\.\\fR appears in the given stream, otherwise it outputs \\fBfalse\\fR\\.\n.\n.TP\n\\fBIN(source; s)\\fR:\n.\n.IP\nThis builtin outputs \\fBtrue\\fR if any value in the source stream appears in the second stream, otherwise it outputs \\fBfalse\\fR\\.\n.\n.SS \"builtins\"\nReturns a list of all builtin functions in the format \\fBname/arity\\fR\\. Since functions with the same name but different arities are considered separate functions, \\fBall/0\\fR, \\fBall/1\\fR, and \\fBall/2\\fR would all be present in the list\\.\n.\n.SH \"CONDITIONALS AND COMPARISONS\"\n.\n.SS \"==, !=\"\nThe expression \\'a == b\\' will produce \\'true\\' if the results of evaluating a and b are equal (that is, if they represent equivalent JSON values) and \\'false\\' otherwise\\. In particular, strings are never considered equal to numbers\\. In checking for the equality of JSON objects, the ordering of keys is irrelevant\\. If you\\'re coming from JavaScript, please note that jq\\'s \\fB==\\fR is like JavaScript\\'s \\fB===\\fR, the \"strict equality\" operator\\.\n.\n.P\n!= is \"not equal\", and \\'a != b\\' returns the opposite value of \\'a == b\\'\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\. == false\\'\n   null\n=> false\n\njq \\'\\. == {\"b\": {\"d\": (4 + 1e\\-20), \"c\": 3}, \"a\":1}\\'\n   {\"a\":1, \"b\": {\"c\": 3, \"d\": 4}}\n=> true\n\njq \\'\\.[] == 1\\'\n   [1, 1\\.0, \"1\", \"banana\"]\n=> true, true, false, false\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"if\\-then\\-else\\-end\"\n\\fBif A then B else C end\\fR will act the same as \\fBB\\fR if \\fBA\\fR produces a value other than false or null, but act the same as \\fBC\\fR otherwise\\.\n.\n.P\n\\fBif A then B end\\fR is the same as \\fBif A then B else \\.  end\\fR\\. That is, the \\fBelse\\fR branch is optional, and if absent is the same as \\fB\\.\\fR\\. This also applies to \\fBelif\\fR with absent ending \\fBelse\\fR branch\\.\n.\n.P\nChecking for false or null is a simpler notion of \"truthiness\" than is found in JavaScript or Python, but it means that you\\'ll sometimes have to be more explicit about the condition you want\\. You can\\'t test whether, e\\.g\\. a string is empty using \\fBif \\.name then A else B end\\fR; you\\'ll need something like \\fBif \\.name == \"\" then A else B end\\fR instead\\.\n.\n.P\nIf the condition \\fBA\\fR produces multiple results, then \\fBB\\fR is evaluated once for each result that is not false or null, and \\fBC\\fR is evaluated once for each false or null\\.\n.\n.P\nMore cases can be added to an if using \\fBelif A then B\\fR syntax\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'if \\. == 0 then\n  \"zero\"\nelif \\. == 1 then\n  \"one\"\nelse\n  \"many\"\nend\\'\n   2\n=> \"many\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \">, >=, <=, <\"\nThe comparison operators \\fB>\\fR, \\fB>=\\fR, \\fB<=\\fR, \\fB<\\fR return whether their left argument is greater than, greater than or equal to, less than or equal to or less than their right argument (respectively)\\.\n.\n.P\nThe ordering is the same as that described for \\fBsort\\fR, above\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\. < 5\\'\n   2\n=> true\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"and, or, not\"\njq supports the normal Boolean operators \\fBand\\fR, \\fBor\\fR, \\fBnot\\fR\\. They have the same standard of truth as if expressions \\- \\fBfalse\\fR and \\fBnull\\fR are considered \"false values\", and anything else is a \"true value\"\\.\n.\n.P\nIf an operand of one of these operators produces multiple results, the operator itself will produce a result for each input\\.\n.\n.P\n\\fBnot\\fR is in fact a builtin function rather than an operator, so it is called as a filter to which things can be piped rather than with special syntax, as in \\fB\\.foo and \\.bar | not\\fR\\.\n.\n.P\nThese three only produce the values \\fBtrue\\fR and \\fBfalse\\fR, and so are only useful for genuine Boolean operations, rather than the common Perl/Python/Ruby idiom of \"value_that_may_be_null or default\"\\. If you want to use this form of \"or\", picking between two values rather than evaluating a condition, see the \\fB//\\fR operator below\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'42 and \"a string\"\\'\n   null\n=> true\n\njq \\'(true, false) or false\\'\n   null\n=> true, false\n\njq \\'(true, true) and (true, false)\\'\n   null\n=> true, false, true, false\n\njq \\'[true, false | not]\\'\n   null\n=> [false, true]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Alternative operator: //\"\nThe \\fB//\\fR operator produces all the values of its left\\-hand side that are neither \\fBfalse\\fR nor \\fBnull\\fR\\. If the left\\-hand side produces no values other than \\fBfalse\\fR or \\fBnull\\fR, then \\fB//\\fR produces all the values of its right\\-hand side\\.\n.\n.P\nA filter of the form \\fBa // b\\fR produces all the results of \\fBa\\fR that are not \\fBfalse\\fR or \\fBnull\\fR\\. If \\fBa\\fR produces no results, or no results other than \\fBfalse\\fR or \\fBnull\\fR, then \\fBa // b\\fR produces the results of \\fBb\\fR\\.\n.\n.P\nThis is useful for providing defaults: \\fB\\.foo // 1\\fR will evaluate to \\fB1\\fR if there\\'s no \\fB\\.foo\\fR element in the input\\. It\\'s similar to how \\fBor\\fR is sometimes used in Python (jq\\'s \\fBor\\fR operator is reserved for strictly Boolean operations)\\.\n.\n.P\nNote: \\fBsome_generator // defaults_here\\fR is not the same as \\fBsome_generator | \\. // defaults_here\\fR\\. The latter will produce default values for all non\\-\\fBfalse\\fR, non\\-\\fBnull\\fR values of the left\\-hand side, while the former will not\\. Precedence rules can make this confusing\\. For example, in \\fBfalse, 1 // 2\\fR the left\\-hand side of \\fB//\\fR is \\fB1\\fR, not \\fBfalse, 1\\fR \\-\\- \\fBfalse, 1 // 2\\fR parses the same way as \\fBfalse, (1 // 2)\\fR\\. In \\fB(false, null, 1) | \\. // 42\\fR the left\\-hand side of \\fB//\\fR is \\fB\\.\\fR, which always produces just one value, while in \\fB(false, null, 1) // 42\\fR the left\\-hand side is a generator of three values, and since it produces a value other \\fBfalse\\fR and \\fBnull\\fR, the default \\fB42\\fR is not produced\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'empty // 42\\'\n   null\n=> 42\n\njq \\'\\.foo // 42\\'\n   {\"foo\": 19}\n=> 19\n\njq \\'\\.foo // 42\\'\n   {}\n=> 42\n\njq \\'(false, null, 1) // 42\\'\n   null\n=> 1\n\njq \\'(false, null, 1) | \\. // 42\\'\n   null\n=> 42, 42, 1\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"try\\-catch\"\nErrors can be caught by using \\fBtry EXP catch EXP\\fR\\. The first expression is executed, and if it fails then the second is executed with the error message\\. The output of the handler, if any, is output as if it had been the output of the expression to try\\.\n.\n.P\nThe \\fBtry EXP\\fR form uses \\fBempty\\fR as the exception handler\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'try \\.a catch \"\\. is not an object\"\\'\n   true\n=> \"\\. is not an object\"\n\njq \\'[\\.[]|try \\.a]\\'\n   [{}, true, {\"a\":1}]\n=> [null, 1]\n\njq \\'try error(\"some exception\") catch \\.\\'\n   true\n=> \"some exception\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Breaking out of control structures\"\nA convenient use of try/catch is to break out of control structures like \\fBreduce\\fR, \\fBforeach\\fR, \\fBwhile\\fR, and so on\\.\n.\n.P\nFor example:\n.\n.IP \"\" 4\n.\n.nf\n\n# Repeat an expression until it raises \"break\" as an\n# error, then stop repeating without re\\-raising the error\\.\n# But if the error caught is not \"break\" then re\\-raise it\\.\ntry repeat(exp) catch if \\.==\"break\" then empty else error\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\njq has a syntax for named lexical labels to \"break\" or \"go (back) to\":\n.\n.IP \"\" 4\n.\n.nf\n\nlabel $out | \\.\\.\\. break $out \\.\\.\\.\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nThe \\fBbreak $label_name\\fR expression will cause the program to act as though the nearest (to the left) \\fBlabel $label_name\\fR produced \\fBempty\\fR\\.\n.\n.P\nThe relationship between the \\fBbreak\\fR and corresponding \\fBlabel\\fR is lexical: the label has to be \"visible\" from the break\\.\n.\n.P\nTo break out of a \\fBreduce\\fR, for example:\n.\n.IP \"\" 4\n.\n.nf\n\nlabel $out | reduce \\.[] as $item (null; if \\.==false then break $out else \\.\\.\\. end)\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nThe following jq program produces a syntax error:\n.\n.IP \"\" 4\n.\n.nf\n\nbreak $out\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nbecause no label \\fB$out\\fR is visible\\.\n.\n.SS \"Error Suppression / Optional Operator: ?\"\nThe \\fB?\\fR operator, used as \\fBEXP?\\fR, is shorthand for \\fBtry EXP\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[\\.[] | \\.a?]\\'\n   [{}, true, {\"a\":1}]\n=> [null, 1]\n\njq \\'[\\.[] | tonumber?]\\'\n   [\"1\", \"invalid\", \"3\", 4]\n=> [1, 3, 4]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SH \"REGULAR EXPRESSIONS\"\njq uses the Oniguruma regular expression library, as do PHP, TextMate, Sublime Text, etc, so the description here will focus on jq specifics\\.\n\n.\n.P\nOniguruma supports several flavors of regular expression, so it is important to know that jq uses the \"Perl NG\" (Perl with named groups) flavor\\.\n\n.\n.P\nThe jq regex filters are defined so that they can be used using one of these patterns:\n.\n.IP \"\" 4\n.\n.nf\n\nSTRING | FILTER(REGEX)\nSTRING | FILTER(REGEX; FLAGS)\nSTRING | FILTER([REGEX])\nSTRING | FILTER([REGEX, FLAGS])\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nwhere:\n.\n.IP \"\\(bu\" 4\nSTRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;\n.\n.IP \"\\(bu\" 4\nREGEX, after string interpolation, should be a valid regular expression;\n.\n.IP \"\\(bu\" 4\nFILTER is one of \\fBtest\\fR, \\fBmatch\\fR, or \\fBcapture\\fR, as described below\\.\n.\n.IP \"\" 0\n.\n.P\nSince REGEX must evaluate to a JSON string, some characters that are needed to form a regular expression must be escaped\\. For example, the regular expression \\fB\\es\\fR signifying a whitespace character would be written as \\fB\"\\e\\es\"\\fR\\.\n.\n.P\nFLAGS is a string consisting of one of more of the supported flags:\n.\n.IP \"\\(bu\" 4\n\\fBg\\fR \\- Global search (find all matches, not just the first)\n.\n.IP \"\\(bu\" 4\n\\fBi\\fR \\- Case insensitive search\n.\n.IP \"\\(bu\" 4\n\\fBm\\fR \\- Multi line mode (\\fB\\.\\fR will match newlines)\n.\n.IP \"\\(bu\" 4\n\\fBn\\fR \\- Ignore empty matches\n.\n.IP \"\\(bu\" 4\n\\fBp\\fR \\- Both s and m modes are enabled\n.\n.IP \"\\(bu\" 4\n\\fBs\\fR \\- Single line mode (\\fB^\\fR \\-> \\fB\\eA\\fR, \\fB$\\fR \\-> \\fB\\eZ\\fR)\n.\n.IP \"\\(bu\" 4\n\\fBl\\fR \\- Find longest possible matches\n.\n.IP \"\\(bu\" 4\n\\fBx\\fR \\- Extended regex format (ignore whitespace and comments)\n.\n.IP \"\" 0\n.\n.P\nTo match a whitespace with the \\fBx\\fR flag, use \\fB\\es\\fR, e\\.g\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\-n \\'\"a b\" | test(\"a\\e\\esb\"; \"x\")\\'\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nNote that certain flags may also be specified within REGEX, e\\.g\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\-n \\'(\"test\", \"TEst\", \"teST\", \"TEST\") | test(\"(?i)te(?\\-i)st\")\\'\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nevaluates to: \\fBtrue\\fR, \\fBtrue\\fR, \\fBfalse\\fR, \\fBfalse\\fR\\.\n.\n.SS \"test(val), test(regex; flags)\"\nLike \\fBmatch\\fR, but does not return match objects, only \\fBtrue\\fR or \\fBfalse\\fR for whether or not the regex matches the input\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'test(\"foo\")\\'\n   \"foo\"\n=> true\n\njq \\'\\.[] | test(\"a b c # spaces are ignored\"; \"ix\")\\'\n   [\"xabcd\", \"ABC\"]\n=> true, true\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"match(val), match(regex; flags)\"\n\\fBmatch\\fR outputs an object for each match it finds\\. Matches have the following fields:\n.\n.IP \"\\(bu\" 4\n\\fBoffset\\fR \\- offset in UTF\\-8 codepoints from the beginning of the input\n.\n.IP \"\\(bu\" 4\n\\fBlength\\fR \\- length in UTF\\-8 codepoints of the match\n.\n.IP \"\\(bu\" 4\n\\fBstring\\fR \\- the string that it matched\n.\n.IP \"\\(bu\" 4\n\\fBcaptures\\fR \\- an array of objects representing capturing groups\\.\n.\n.IP \"\" 0\n.\n.P\nCapturing group objects have the following fields:\n.\n.IP \"\\(bu\" 4\n\\fBoffset\\fR \\- offset in UTF\\-8 codepoints from the beginning of the input\n.\n.IP \"\\(bu\" 4\n\\fBlength\\fR \\- length in UTF\\-8 codepoints of this capturing group\n.\n.IP \"\\(bu\" 4\n\\fBstring\\fR \\- the string that was captured\n.\n.IP \"\\(bu\" 4\n\\fBname\\fR \\- the name of the capturing group (or \\fBnull\\fR if it was unnamed)\n.\n.IP \"\" 0\n.\n.P\nCapturing groups that did not match anything return an offset of \\-1\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'match(\"(abc)+\"; \"g\")\\'\n   \"abc abc\"\n=> {\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"name\": null}]}, {\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"name\": null}]}\n\njq \\'match(\"foo\")\\'\n   \"foo bar foo\"\n=> {\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}\n\njq \\'match([\"foo\", \"ig\"])\\'\n   \"foo bar FOO\"\n=> {\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}, {\"offset\": 8, \"length\": 3, \"string\": \"FOO\", \"captures\": []}\n\njq \\'match(\"foo (?<bar123>bar)? foo\"; \"ig\")\\'\n   \"foo bar foo foo  foo\"\n=> {\"offset\": 0, \"length\": 11, \"string\": \"foo bar foo\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"bar\", \"name\": \"bar123\"}]}, {\"offset\": 12, \"length\": 8, \"string\": \"foo  foo\", \"captures\": [{\"offset\": \\-1, \"length\": 0, \"string\": null, \"name\": \"bar123\"}]}\n\njq \\'[ match(\"\\.\"; \"g\")] | length\\'\n   \"abc\"\n=> 3\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"capture(val), capture(regex; flags)\"\nCollects the named captures in a JSON object, with the name of each capture as the key, and the matched string as the corresponding value\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'capture(\"(?<a>[a\\-z]+)\\-(?<n>[0\\-9]+)\")\\'\n   \"xyzzy\\-14\"\n=> { \"a\": \"xyzzy\", \"n\": \"14\" }\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"scan(regex), scan(regex; flags)\"\nEmit a stream of the non\\-overlapping substrings of the input that match the regex in accordance with the flags, if any have been specified\\. If there is no match, the stream is empty\\. To capture all the matches for each input string, use the idiom \\fB[ expr ]\\fR, e\\.g\\. \\fB[ scan(regex) ]\\fR\\. If the regex contains capturing groups, the filter emits a stream of arrays, each of which contains the captured strings\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'scan(\"c\")\\'\n   \"abcdefabc\"\n=> \"c\", \"c\"\n\njq \\'scan(\"(a+)(b+)\")\\'\n   \"abaabbaaabbb\"\n=> [\"a\",\"b\"], [\"aa\",\"bb\"], [\"aaa\",\"bbb\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"split(regex; flags)\"\nSplits an input string on each regex match\\.\n.\n.P\nFor backwards compatibility, when called with a single argument, \\fBsplit\\fR splits on a string, not a regex\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'split(\", *\"; null)\\'\n   \"ab,cd, ef\"\n=> [\"ab\",\"cd\",\"ef\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"splits(regex), splits(regex; flags)\"\nThese provide the same results as their \\fBsplit\\fR counterparts, but as a stream instead of an array\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'splits(\", *\")\\'\n   \"ab,cd,   ef, gh\"\n=> \"ab\", \"cd\", \"ef\", \"gh\"\n\njq \\'splits(\",? *\"; \"n\")\\'\n   \"ab,cd ef,  gh\"\n=> \"ab\", \"cd\", \"ef\", \"gh\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"sub(regex; tostring), sub(regex; tostring; flags)\"\nEmit the string obtained by replacing the first match of regex in the input string with \\fBtostring\\fR, after interpolation\\. \\fBtostring\\fR should be a jq string or a stream of such strings, each of which may contain references to named captures\\. The named captures are, in effect, presented as a JSON object (as constructed by \\fBcapture\\fR) to \\fBtostring\\fR, so a reference to a captured variable named \"x\" would take the form: \\fB\"\\e(\\.x)\"\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'sub(\"[^a\\-z]*(?<x>[a\\-z]+)\"; \"Z\\e(\\.x)\"; \"g\")\\'\n   \"123abc456def\"\n=> \"ZabcZdef\"\n\njq \\'[sub(\"(?<a>\\.)\"; \"\\e(\\.a|ascii_upcase)\", \"\\e(\\.a|ascii_downcase)\")]\\'\n   \"aB\"\n=> [\"AB\",\"aB\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"gsub(regex; tostring), gsub(regex; tostring; flags)\"\n\\fBgsub\\fR is like \\fBsub\\fR but all the non\\-overlapping occurrences of the regex are replaced by \\fBtostring\\fR, after interpolation\\. If the second argument is a stream of jq strings, then \\fBgsub\\fR will produce a corresponding stream of JSON strings\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'gsub(\"(?<x>\\.)[^a]*\"; \"+\\e(\\.x)\\-\")\\'\n   \"Abcabc\"\n=> \"+A\\-+a\\-\"\n\njq \\'[gsub(\"p\"; \"a\", \"b\")]\\'\n   \"p\"\n=> [\"a\",\"b\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SH \"ADVANCED FEATURES\"\nVariables are an absolute necessity in most programming languages, but they\\'re relegated to an \"advanced feature\" in jq\\.\n.\n.P\nIn most languages, variables are the only means of passing around data\\. If you calculate a value, and you want to use it more than once, you\\'ll need to store it in a variable\\. To pass a value to another part of the program, you\\'ll need that part of the program to define a variable (as a function parameter, object member, or whatever) in which to place the data\\.\n.\n.P\nIt is also possible to define functions in jq, although this is is a feature whose biggest use is defining jq\\'s standard library (many jq functions such as \\fBmap\\fR and \\fBselect\\fR are in fact written in jq)\\.\n.\n.P\njq has reduction operators, which are very powerful but a bit tricky\\. Again, these are mostly used internally, to define some useful bits of jq\\'s standard library\\.\n.\n.P\nIt may not be obvious at first, but jq is all about generators (yes, as often found in other languages)\\. Some utilities are provided to help deal with generators\\.\n.\n.P\nSome minimal I/O support (besides reading JSON from standard input, and writing JSON to standard output) is available\\.\n.\n.P\nFinally, there is a module/library system\\.\n.\n.SS \"Variable / Symbolic Binding Operator: \\.\\.\\. as $identifier | \\.\\.\\.\"\nIn jq, all filters have an input and an output, so manual plumbing is not necessary to pass a value from one part of a program to the next\\. Many expressions, for instance \\fBa + b\\fR, pass their input to two distinct subexpressions (here \\fBa\\fR and \\fBb\\fR are both passed the same input), so variables aren\\'t usually necessary in order to use a value twice\\.\n.\n.P\nFor instance, calculating the average value of an array of numbers requires a few variables in most languages \\- at least one to hold the array, perhaps one for each element or for a loop counter\\. In jq, it\\'s simply \\fBadd / length\\fR \\- the \\fBadd\\fR expression is given the array and produces its sum, and the \\fBlength\\fR expression is given the array and produces its length\\.\n.\n.P\nSo, there\\'s generally a cleaner way to solve most problems in jq than defining variables\\. Still, sometimes they do make things easier, so jq lets you define variables using \\fBexpression as $variable\\fR\\. All variable names start with \\fB$\\fR\\. Here\\'s a slightly uglier version of the array\\-averaging example:\n.\n.IP \"\" 4\n.\n.nf\n\nlength as $array_length | add / $array_length\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nWe\\'ll need a more complicated problem to find a situation where using variables actually makes our lives easier\\.\n.\n.P\nSuppose we have an array of blog posts, with \"author\" and \"title\" fields, and another object which is used to map author usernames to real names\\. Our input looks like:\n.\n.IP \"\" 4\n.\n.nf\n\n{\"posts\": [{\"title\": \"First post\", \"author\": \"anon\"},\n           {\"title\": \"A well\\-written article\", \"author\": \"person1\"}],\n \"realnames\": {\"anon\": \"Anonymous Coward\",\n               \"person1\": \"Person McPherson\"}}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nWe want to produce the posts with the author field containing a real name, as in:\n.\n.IP \"\" 4\n.\n.nf\n\n{\"title\": \"First post\", \"author\": \"Anonymous Coward\"}\n{\"title\": \"A well\\-written article\", \"author\": \"Person McPherson\"}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nWe use a variable, \\fB$names\\fR, to store the realnames object, so that we can refer to it later when looking up author usernames:\n.\n.IP \"\" 4\n.\n.nf\n\n\\&.realnames as $names | \\.posts[] | {title, author: $names[\\.author]}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nThe expression \\fBexp as $x | \\.\\.\\.\\fR means: for each value of expression \\fBexp\\fR, run the rest of the pipeline with the entire original input, and with \\fB$x\\fR set to that value\\. Thus \\fBas\\fR functions as something of a foreach loop\\.\n.\n.P\nJust as \\fB{foo}\\fR is a handy way of writing \\fB{foo: \\.foo}\\fR, so \\fB{$foo}\\fR is a handy way of writing \\fB{foo: $foo}\\fR\\.\n.\n.P\nMultiple variables may be declared using a single \\fBas\\fR expression by providing a pattern that matches the structure of the input (this is known as \"destructuring\"):\n.\n.IP \"\" 4\n.\n.nf\n\n\\&. as {realnames: $names, posts: [$first, $second]} | \\.\\.\\.\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nThe variable declarations in array patterns (e\\.g\\., \\fB\\. as [$first, $second]\\fR) bind to the elements of the array in from the element at index zero on up, in order\\. When there is no value at the index for an array pattern element, \\fBnull\\fR is bound to that variable\\.\n.\n.P\nVariables are scoped over the rest of the expression that defines them, so\n.\n.IP \"\" 4\n.\n.nf\n\n\\&.realnames as $names | (\\.posts[] | {title, author: $names[\\.author]})\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nwill work, but\n.\n.IP \"\" 4\n.\n.nf\n\n(\\.realnames as $names | \\.posts[]) | {title, author: $names[\\.author]}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nwon\\'t\\.\n.\n.P\nFor programming language theorists, it\\'s more accurate to say that jq variables are lexically\\-scoped bindings\\. In particular there\\'s no way to change the value of a binding; one can only setup a new binding with the same name, but which will not be visible where the old one was\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.bar as $x | \\.foo | \\. + $x\\'\n   {\"foo\":10, \"bar\":200}\n=> 210\n\njq \\'\\. as $i|[(\\.*2|\\. as $i| $i), $i]\\'\n   5\n=> [10,5]\n\njq \\'\\. as [$a, $b, {c: $c}] | $a + $b + $c\\'\n   [2, 3, {\"c\": 4, \"d\": 5}]\n=> 9\n\njq \\'\\.[] as [$a, $b] | {a: $a, b: $b}\\'\n   [[0], [0, 1], [2, 1, 0]]\n=> {\"a\":0,\"b\":null}, {\"a\":0,\"b\":1}, {\"a\":2,\"b\":1}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Destructuring Alternative Operator: ?//\"\nThe destructuring alternative operator provides a concise mechanism for destructuring an input that can take one of several forms\\.\n.\n.P\nSuppose we have an API that returns a list of resources and events associated with them, and we want to get the user_id and timestamp of the first event for each resource\\. The API (having been clumsily converted from XML) will only wrap the events in an array if the resource has multiple events:\n.\n.IP \"\" 4\n.\n.nf\n\n{\"resources\": [{\"id\": 1, \"kind\": \"widget\", \"events\": {\"action\": \"create\", \"user_id\": 1, \"ts\": 13}},\n               {\"id\": 2, \"kind\": \"widget\", \"events\": [{\"action\": \"create\", \"user_id\": 1, \"ts\": 14}, {\"action\": \"destroy\", \"user_id\": 1, \"ts\": 15}]}]}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nWe can use the destructuring alternative operator to handle this structural change simply:\n.\n.IP \"\" 4\n.\n.nf\n\n\\&.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nOr, if we aren\\'t sure if the input is an array of values or an object:\n.\n.IP \"\" 4\n.\n.nf\n\n\\&.[] as [$id, $kind, $user_id, $ts] ?// {$id, $kind, $user_id, $ts} | \\.\\.\\.\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nEach alternative need not define all of the same variables, but all named variables will be available to the subsequent expression\\. Variables not matched in the alternative that succeeded will be \\fBnull\\fR:\n.\n.IP \"\" 4\n.\n.nf\n\n\\&.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$first_user_id, $first_ts}]} | {$user_id, $first_user_id, $kind, $id, $ts, $first_ts}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nAdditionally, if the subsequent expression returns an error, the alternative operator will attempt to try the next binding\\. Errors that occur during the final alternative are passed through\\.\n.\n.IP \"\" 4\n.\n.nf\n\n[[3]] | \\.[] as [$a] ?// [$b] | if $a != null then error(\"err: \\e($a)\") else {$a,$b} end\n\njq \\'\\.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}\\'\n   [{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]\n=> {\"a\":1,\"b\":2,\"d\":3,\"e\":4}, {\"a\":1,\"b\":2,\"d\":3,\"e\":4}\n\njq \\'\\.[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}\\'\n   [{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]\n=> {\"a\":1,\"b\":2,\"d\":3,\"e\":null}, {\"a\":1,\"b\":2,\"d\":null,\"e\":4}\n\njq \\'\\.[] as [$a] ?// [$b] | if $a != null then error(\"err: \\e($a)\") else {$a,$b} end\\'\n   [[3]]\n=> {\"a\":null,\"b\":3}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Defining Functions\"\nYou can give a filter a name using \"def\" syntax:\n.\n.IP \"\" 4\n.\n.nf\n\ndef increment: \\. + 1;\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nFrom then on, \\fBincrement\\fR is usable as a filter just like a builtin function (in fact, this is how many of the builtins are defined)\\. A function may take arguments:\n.\n.IP \"\" 4\n.\n.nf\n\ndef map(f): [\\.[] | f];\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nArguments are passed as \\fIfilters\\fR (functions with no arguments), \\fInot\\fR as values\\. The same argument may be referenced multiple times with different inputs (here \\fBf\\fR is run for each element of the input array)\\. Arguments to a function work more like callbacks than like value arguments\\. This is important to understand\\. Consider:\n.\n.IP \"\" 4\n.\n.nf\n\ndef foo(f): f|f;\n5|foo(\\.*2)\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nThe result will be 20 because \\fBf\\fR is \\fB\\.*2\\fR, and during the first invocation of \\fBf\\fR \\fB\\.\\fR will be 5, and the second time it will be 10 (5 * 2), so the result will be 20\\. Function arguments are filters, and filters expect an input when invoked\\.\n.\n.P\nIf you want the value\\-argument behaviour for defining simple functions, you can just use a variable:\n.\n.IP \"\" 4\n.\n.nf\n\ndef addvalue(f): f as $f | map(\\. + $f);\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nOr use the short\\-hand:\n.\n.IP \"\" 4\n.\n.nf\n\ndef addvalue($f): \\.\\.\\.;\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nWith either definition, \\fBaddvalue(\\.foo)\\fR will add the current input\\'s \\fB\\.foo\\fR field to each element of the array\\. Do note that calling \\fBaddvalue(\\.[])\\fR will cause the \\fBmap(\\. + $f)\\fR part to be evaluated once per value in the value of \\fB\\.\\fR at the call site\\.\n.\n.P\nMultiple definitions using the same function name are allowed\\. Each re\\-definition replaces the previous one for the same number of function arguments, but only for references from functions (or main program) subsequent to the re\\-definition\\. See also the section below on scoping\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'def addvalue(f): \\. + [f]; map(addvalue(\\.[0]))\\'\n   [[1,2],[10,20]]\n=> [[1,2,1], [10,20,10]]\n\njq \\'def addvalue(f): f as $x | map(\\. + $x); addvalue(\\.[0])\\'\n   [[1,2],[10,20]]\n=> [[1,2,1,2], [10,20,1,2]]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Scoping\"\nThere are two types of symbols in jq: value bindings (a\\.k\\.a\\., \"variables\"), and functions\\. Both are scoped lexically, with expressions being able to refer only to symbols that have been defined \"to the left\" of them\\. The only exception to this rule is that functions can refer to themselves so as to be able to create recursive functions\\.\n.\n.P\nFor example, in the following expression there is a binding which is visible \"to the right\" of it, \\fB\\.\\.\\. | \\.*3 as $times_three | [\\. + $times_three] | \\.\\.\\.\\fR, but not \"to the left\"\\. Consider this expression now, \\fB\\.\\.\\. | (\\.*3 as $times_three | [\\. + $times_three]) | \\.\\.\\.\\fR: here the binding \\fB$times_three\\fR is \\fInot\\fR visible past the closing parenthesis\\.\n.\n.SS \"isempty(exp)\"\nReturns true if \\fBexp\\fR produces no outputs, false otherwise\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'isempty(empty)\\'\n   null\n=> true\n\njq \\'isempty(\\.[])\\'\n   []\n=> true\n\njq \\'isempty(\\.[])\\'\n   [1,2,3]\n=> false\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"limit(n; expr)\"\nThe \\fBlimit\\fR function extracts up to \\fBn\\fR outputs from \\fBexpr\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[limit(3; \\.[])]\\'\n   [0,1,2,3,4,5,6,7,8,9]\n=> [0,1,2]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"skip(n; expr)\"\nThe \\fBskip\\fR function skips the first \\fBn\\fR outputs from \\fBexpr\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[skip(3; \\.[])]\\'\n   [0,1,2,3,4,5,6,7,8,9]\n=> [3,4,5,6,7,8,9]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"first(expr), last(expr), nth(n; expr)\"\nThe \\fBfirst(expr)\\fR and \\fBlast(expr)\\fR functions extract the first and last values from \\fBexpr\\fR, respectively\\.\n.\n.P\nThe \\fBnth(n; expr)\\fR function extracts the nth value output by \\fBexpr\\fR\\. Note that \\fBnth(n; expr)\\fR doesn\\'t support negative values of \\fBn\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[first(range(\\.)), last(range(\\.)), nth(5; range(\\.))]\\'\n   10\n=> [0,9,5]\n\njq \\'[first(empty), last(empty), nth(5; empty)]\\'\n   null\n=> []\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"first, last, nth(n)\"\nThe \\fBfirst\\fR and \\fBlast\\fR functions extract the first and last values from any array at \\fB\\.\\fR\\.\n.\n.P\nThe \\fBnth(n)\\fR function extracts the nth value of any array at \\fB\\.\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'[range(\\.)]|[first, last, nth(5)]\\'\n   10\n=> [0,9,5]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"reduce\"\nThe \\fBreduce\\fR syntax allows you to combine all of the results of an expression by accumulating them into a single answer\\. The form is \\fBreduce EXP as $var (INIT; UPDATE)\\fR\\. As an example, we\\'ll pass \\fB[1,2,3]\\fR to this expression:\n.\n.IP \"\" 4\n.\n.nf\n\nreduce \\.[] as $item (0; \\. + $item)\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nFor each result that \\fB\\.[]\\fR produces, \\fB\\. + $item\\fR is run to accumulate a running total, starting from 0 as the input value\\. In this example, \\fB\\.[]\\fR produces the results \\fB1\\fR, \\fB2\\fR, and \\fB3\\fR, so the effect is similar to running something like this:\n.\n.IP \"\" 4\n.\n.nf\n\n0 | 1 as $item | \\. + $item |\n    2 as $item | \\. + $item |\n    3 as $item | \\. + $item\n\njq \\'reduce \\.[] as $item (0; \\. + $item)\\'\n   [1,2,3,4,5]\n=> 15\n\njq \\'reduce \\.[] as [$i,$j] (0; \\. + $i * $j)\\'\n   [[1,2],[3,4],[5,6]]\n=> 44\n\njq \\'reduce \\.[] as {$x,$y} (null; \\.x += $x | \\.y += [$y])\\'\n   [{\"x\":\"a\",\"y\":1},{\"x\":\"b\",\"y\":2},{\"x\":\"c\",\"y\":3}]\n=> {\"x\":\"abc\",\"y\":[1,2,3]}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"foreach\"\nThe \\fBforeach\\fR syntax is similar to \\fBreduce\\fR, but intended to allow the construction of \\fBlimit\\fR and reducers that produce intermediate results\\.\n.\n.P\nThe form is \\fBforeach EXP as $var (INIT; UPDATE; EXTRACT)\\fR\\. As an example, we\\'ll pass \\fB[1,2,3]\\fR to this expression:\n.\n.IP \"\" 4\n.\n.nf\n\nforeach \\.[] as $item (0; \\. + $item; [$item, \\. * 2])\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nLike the \\fBreduce\\fR syntax, \\fB\\. + $item\\fR is run for each result that \\fB\\.[]\\fR produces, but \\fB[$item, \\. * 2]\\fR is run for each intermediate values\\. In this example, since the intermediate values are \\fB1\\fR, \\fB3\\fR, and \\fB6\\fR, the \\fBforeach\\fR expression produces \\fB[1,2]\\fR, \\fB[2,6]\\fR, and \\fB[3,12]\\fR\\. So the effect is similar to running something like this:\n.\n.IP \"\" 4\n.\n.nf\n\n0 | 1 as $item | \\. + $item | [$item, \\. * 2],\n    2 as $item | \\. + $item | [$item, \\. * 2],\n    3 as $item | \\. + $item | [$item, \\. * 2]\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nWhen \\fBEXTRACT\\fR is omitted, the identity filter is used\\. That is, it outputs the intermediate values as they are\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'foreach \\.[] as $item (0; \\. + $item)\\'\n   [1,2,3,4,5]\n=> 1, 3, 6, 10, 15\n\njq \\'foreach \\.[] as $item (0; \\. + $item; [$item, \\. * 2])\\'\n   [1,2,3,4,5]\n=> [1,2], [2,6], [3,12], [4,20], [5,30]\n\njq \\'foreach \\.[] as $item (0; \\. + 1; {index: \\., $item})\\'\n   [\"foo\", \"bar\", \"baz\"]\n=> {\"index\":1,\"item\":\"foo\"}, {\"index\":2,\"item\":\"bar\"}, {\"index\":3,\"item\":\"baz\"}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Recursion\"\nAs described above, \\fBrecurse\\fR uses recursion, and any jq function can be recursive\\. The \\fBwhile\\fR builtin is also implemented in terms of recursion\\.\n.\n.P\nTail calls are optimized whenever the expression to the left of the recursive call outputs its last value\\. In practice this means that the expression to the left of the recursive call should not produce more than one output for each input\\.\n.\n.P\nFor example:\n.\n.IP \"\" 4\n.\n.nf\n\ndef recurse(f): def r: \\., (f | select(\\. != null) | r); r;\n\ndef while(cond; update):\n  def _while:\n    if cond then \\., (update | _while) else empty end;\n  _while;\n\ndef repeat(exp):\n  def _repeat:\n    exp, _repeat;\n  _repeat;\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Generators and iterators\"\nSome jq operators and functions are actually generators in that they can produce zero, one, or more values for each input, just as one might expect in other programming languages that have generators\\. For example, \\fB\\.[]\\fR generates all the values in its input (which must be an array or an object), \\fBrange(0; 10)\\fR generates the integers between 0 and 10, and so on\\.\n.\n.P\nEven the comma operator is a generator, generating first the values generated by the expression to the left of the comma, then the values generated by the expression on the right of the comma\\.\n.\n.P\nThe \\fBempty\\fR builtin is the generator that produces zero outputs\\. The \\fBempty\\fR builtin backtracks to the preceding generator expression\\.\n.\n.P\nAll jq functions can be generators just by using builtin generators\\. It is also possible to construct new generators using only recursion and the comma operator\\. If recursive calls are \"in tail position\" then the generator will be efficient\\. In the example below the recursive call by \\fB_range\\fR to itself is in tail position\\. The example shows off three advanced topics: tail recursion, generator construction, and sub\\-functions\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'def range(init; upto; by): def _range: if (by > 0 and \\. < upto) or (by < 0 and \\. > upto) then \\., ((\\.+by)|_range) else empty end; if init == upto then empty elif by == 0 then init else init|_range end; range(0; 10; 3)\\'\n   null\n=> 0, 3, 6, 9\n\njq \\'def while(cond; update): def _while: if cond then \\., (update | _while) else empty end; _while; [while(\\.<100; \\.*2)]\\'\n   1\n=> [1,2,4,8,16,32,64]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SH \"MATH\"\njq currently only has IEEE754 double\\-precision (64\\-bit) floating point number support\\.\n.\n.P\nBesides simple arithmetic operators such as \\fB+\\fR, jq also has most standard math functions from the C math library\\. C math functions that take a single input argument (e\\.g\\., \\fBsin()\\fR) are available as zero\\-argument jq functions\\. C math functions that take two input arguments (e\\.g\\., \\fBpow()\\fR) are available as two\\-argument jq functions that ignore \\fB\\.\\fR\\. C math functions that take three input arguments are available as three\\-argument jq functions that ignore \\fB\\.\\fR\\.\n.\n.P\nAvailability of standard math functions depends on the availability of the corresponding math functions in your operating system and C math library\\. Unavailable math functions will be defined but will raise an error\\.\n.\n.P\nOne\\-input C math functions: \\fBacos\\fR \\fBacosh\\fR \\fBasin\\fR \\fBasinh\\fR \\fBatan\\fR \\fBatanh\\fR \\fBcbrt\\fR \\fBceil\\fR \\fBcos\\fR \\fBcosh\\fR \\fBerf\\fR \\fBerfc\\fR \\fBexp\\fR \\fBexp10\\fR \\fBexp2\\fR \\fBexpm1\\fR \\fBfabs\\fR \\fBfloor\\fR \\fBgamma\\fR \\fBj0\\fR \\fBj1\\fR \\fBlgamma\\fR \\fBlog\\fR \\fBlog10\\fR \\fBlog1p\\fR \\fBlog2\\fR \\fBlogb\\fR \\fBnearbyint\\fR \\fBrint\\fR \\fBround\\fR \\fBsignificand\\fR \\fBsin\\fR \\fBsinh\\fR \\fBsqrt\\fR \\fBtan\\fR \\fBtanh\\fR \\fBtgamma\\fR \\fBtrunc\\fR \\fBy0\\fR \\fBy1\\fR\\.\n.\n.P\nTwo\\-input C math functions: \\fBatan2\\fR \\fBcopysign\\fR \\fBdrem\\fR \\fBfdim\\fR \\fBfmax\\fR \\fBfmin\\fR \\fBfmod\\fR \\fBfrexp\\fR \\fBhypot\\fR \\fBjn\\fR \\fBldexp\\fR \\fBmodf\\fR \\fBnextafter\\fR \\fBnexttoward\\fR \\fBpow\\fR \\fBremainder\\fR \\fBscalb\\fR \\fBscalbln\\fR \\fByn\\fR\\.\n.\n.P\nThree\\-input C math functions: \\fBfma\\fR\\.\n.\n.P\nSee your system\\'s manual for more information on each of these\\.\n.\n.SH \"I/O\"\nAt this time jq has minimal support for I/O, mostly in the form of control over when inputs are read\\. Two builtins functions are provided for this, \\fBinput\\fR and \\fBinputs\\fR, that read from the same sources (e\\.g\\., \\fBstdin\\fR, files named on the command\\-line) as jq itself\\. These two builtins, and jq\\'s own reading actions, can be interleaved with each other\\. They are commonly used in combination with the null input option \\fB\\-n\\fR to prevent one input from being read implicitly\\.\n.\n.P\nTwo builtins provide minimal output capabilities, \\fBdebug\\fR, and \\fBstderr\\fR\\. (Recall that a jq program\\'s output values are always output as JSON texts on \\fBstdout\\fR\\.) The \\fBdebug\\fR builtin can have application\\-specific behavior, such as for executables that use the libjq C API but aren\\'t the jq executable itself\\. The \\fBstderr\\fR builtin outputs its input in raw mode to stderr with no additional decoration, not even a newline\\.\n.\n.P\nMost jq builtins are referentially transparent, and yield constant and repeatable value streams when applied to constant inputs\\. This is not true of I/O builtins\\.\n.\n.SS \"input\"\nOutputs one new input\\.\n.\n.P\nNote that when using \\fBinput\\fR it is generally necessary to invoke jq with the \\fB\\-n\\fR command\\-line option, otherwise the first entity will be lost\\.\n.\n.IP \"\" 4\n.\n.nf\n\necho 1 2 3 4 | jq \\'[\\., input]\\' # [1,2] [3,4]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"inputs\"\nOutputs all remaining inputs, one by one\\.\n.\n.P\nThis is primarily useful for reductions over a program\\'s inputs\\. Note that when using \\fBinputs\\fR it is generally necessary to invoke jq with the \\fB\\-n\\fR command\\-line option, otherwise the first entity will be lost\\.\n.\n.IP \"\" 4\n.\n.nf\n\necho 1 2 3 | jq \\-n \\'reduce inputs as $i (0; \\. + $i)\\' # 6\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"debug, debug(msgs)\"\nThese two filters are like \\fB\\.\\fR but have as a side\\-effect the production of one or more messages on stderr\\.\n.\n.P\nThe message produced by the \\fBdebug\\fR filter has the form\n.\n.IP \"\" 4\n.\n.nf\n\n[\"DEBUG:\",<input\\-value>]\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nwhere \\fB<input\\-value>\\fR is a compact rendition of the input value\\. This format may change in the future\\.\n.\n.P\nThe \\fBdebug(msgs)\\fR filter is defined as \\fB(msgs | debug | empty), \\.\\fR thus allowing great flexibility in the content of the message, while also allowing multi\\-line debugging statements to be created\\.\n.\n.P\nFor example, the expression:\n.\n.IP \"\" 4\n.\n.nf\n\n1 as $x | 2 | debug(\"Entering function foo with $x == \\e($x)\", \\.) | (\\.+1)\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nwould produce the value 3 but with the following two lines being written to stderr:\n.\n.IP \"\" 4\n.\n.nf\n\n[\"DEBUG:\",\"Entering function foo with $x == 1\"]\n[\"DEBUG:\",2]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"stderr\"\nPrints its input in raw and compact mode to stderr with no additional decoration, not even a newline\\.\n.\n.SS \"input_filename\"\nReturns the name of the file whose input is currently being filtered\\. Note that this will not work well unless jq is running in a UTF\\-8 locale\\.\n.\n.SS \"input_line_number\"\nReturns the line number of the input currently being filtered\\.\n.\n.SH \"STREAMING\"\nWith the \\fB\\-\\-stream\\fR option jq can parse input texts in a streaming fashion, allowing jq programs to start processing large JSON texts immediately rather than after the parse completes\\. If you have a single JSON text that is 1GB in size, streaming it will allow you to process it much more quickly\\.\n.\n.P\nHowever, streaming isn\\'t easy to deal with as the jq program will have \\fB[<path>, <leaf\\-value>]\\fR (and a few other forms) as inputs\\.\n.\n.P\nSeveral builtins are provided to make handling streams easier\\.\n.\n.P\nThe examples below use the streamed form of \\fB[\"a\",[\"b\"]]\\fR, which is \\fB[[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]]\\fR\\.\n.\n.P\nStreaming forms include \\fB[<path>, <leaf\\-value>]\\fR (to indicate any scalar value, empty array, or empty object), and \\fB[<path>]\\fR (to indicate the end of an array or object)\\. Future versions of jq run with \\fB\\-\\-stream\\fR and \\fB\\-\\-seq\\fR may output additional forms such as \\fB[\"error message\"]\\fR when an input text fails to parse\\.\n.\n.SS \"truncate_stream(stream_expression)\"\nConsumes a number as input and truncates the corresponding number of path elements from the left of the outputs of the given streaming expression\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'truncate_stream([[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]])\\'\n   1\n=> [[0],\"b\"], [[0]]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"fromstream(stream_expression)\"\nOutputs values corresponding to the stream expression\\'s outputs\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'fromstream(1|truncate_stream([[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]]))\\'\n   null\n=> [\"b\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"tostream\"\nThe \\fBtostream\\fR builtin outputs the streamed form of its input\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\. as $dot|fromstream($dot|tostream)|\\.==$dot\\'\n   [0,[1,{\"a\":1},{\"b\":2}]]\n=> true\n.\n.fi\n.\n.IP \"\" 0\n.\n.SH \"ASSIGNMENT\"\nAssignment works a little differently in jq than in most programming languages\\. jq doesn\\'t distinguish between references to and copies of something \\- two objects or arrays are either equal or not equal, without any further notion of being \"the same object\" or \"not the same object\"\\.\n.\n.P\nIf an object has two fields which are arrays, \\fB\\.foo\\fR and \\fB\\.bar\\fR, and you append something to \\fB\\.foo\\fR, then \\fB\\.bar\\fR will not get bigger, even if you\\'ve previously set \\fB\\.bar = \\.foo\\fR\\. If you\\'re used to programming in languages like Python, Java, Ruby, JavaScript, etc\\. then you can think of it as though jq does a full deep copy of every object before it does the assignment (for performance it doesn\\'t actually do that, but that\\'s the general idea)\\.\n.\n.P\nThis means that it\\'s impossible to build circular values in jq (such as an array whose first element is itself)\\. This is quite intentional, and ensures that anything a jq program can produce can be represented in JSON\\.\n.\n.P\nAll the assignment operators in jq have path expressions on the left\\-hand side (LHS)\\. The right\\-hand side (RHS) provides values to set to the paths named by the LHS path expressions\\.\n.\n.P\nValues in jq are always immutable\\. Internally, assignment works by using a reduction to compute new, replacement values for \\fB\\.\\fR that have had all the desired assignments applied to \\fB\\.\\fR, then outputting the modified value\\. This might be made clear by this example: \\fB{a:{b:{c:1}}} | (\\.a\\.b|=3), \\.\\fR\\. This will output \\fB{\"a\":{\"b\":3}}\\fR and \\fB{\"a\":{\"b\":{\"c\":1}}}\\fR because the last sub\\-expression, \\fB\\.\\fR, sees the original value, not the modified value\\.\n.\n.P\nMost users will want to use modification assignment operators, such as \\fB|=\\fR or \\fB+=\\fR, rather than \\fB=\\fR\\.\n.\n.P\nNote that the LHS of assignment operators refers to a value in \\fB\\.\\fR\\. Thus \\fB$var\\.foo = 1\\fR won\\'t work as expected (\\fB$var\\.foo\\fR is not a valid or useful path expression in \\fB\\.\\fR); use \\fB$var | \\.foo = 1\\fR instead\\.\n.\n.P\nNote too that \\fB\\.a,\\.b=0\\fR does not set \\fB\\.a\\fR and \\fB\\.b\\fR, but \\fB(\\.a,\\.b)=0\\fR sets both\\.\n.\n.SS \"Update\\-assignment: |=\"\nThis is the \"update\" operator \\fB|=\\fR\\. It takes a filter on the right\\-hand side and works out the new value for the property of \\fB\\.\\fR being assigned to by running the old value through this expression\\. For instance, \\fB(\\.foo, \\.bar) |= \\.+1\\fR will build an object with the \\fBfoo\\fR field set to the input\\'s \\fBfoo\\fR plus 1, and the \\fBbar\\fR field set to the input\\'s \\fBbar\\fR plus 1\\.\n.\n.P\nThe left\\-hand side can be any general path expression; see \\fBpath()\\fR\\.\n.\n.P\nNote that the left\\-hand side of \\fB|=\\fR refers to a value in \\fB\\.\\fR\\. Thus \\fB$var\\.foo |= \\. + 1\\fR won\\'t work as expected (\\fB$var\\.foo\\fR is not a valid or useful path expression in \\fB\\.\\fR); use \\fB$var | \\.foo |= \\. + 1\\fR instead\\.\n.\n.P\nIf the right\\-hand side outputs no values (i\\.e\\., \\fBempty\\fR), then the left\\-hand side path will be deleted, as with \\fBdel(path)\\fR\\.\n.\n.P\nIf the right\\-hand side outputs multiple values, only the first one will be used (COMPATIBILITY NOTE: in jq 1\\.5 and earlier releases, it used to be that only the last one was used)\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'(\\.\\.|select(type==\"boolean\")) |= if \\. then 1 else 0 end\\'\n   [true,false,[5,true,[true,[false]],false]]\n=> [1,0,[5,1,[1,[0]],0]]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Arithmetic update\\-assignment: +=, \\-=, *=, /=, %=, //=\"\njq has a few operators of the form \\fBa op= b\\fR, which are all equivalent to \\fBa |= \\. op b\\fR\\. So, \\fB+= 1\\fR can be used to increment values, being the same as \\fB|= \\. + 1\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.foo += 1\\'\n   {\"foo\": 42}\n=> {\"foo\": 43}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Plain assignment: =\"\nThis is the plain assignment operator\\. Unlike the others, the input to the right\\-hand side (RHS) is the same as the input to the left\\-hand side (LHS) rather than the value at the LHS path, and all values output by the RHS will be used (as shown below)\\.\n.\n.P\nIf the RHS of \\fB=\\fR produces multiple values, then for each such value jq will set the paths on the left\\-hand side to the value and then it will output the modified \\fB\\.\\fR\\. For example, \\fB(\\.a,\\.b) = range(2)\\fR outputs \\fB{\"a\":0,\"b\":0}\\fR, then \\fB{\"a\":1,\"b\":1}\\fR\\. The \"update\" assignment forms (see above) do not do this\\.\n.\n.P\nThis example should show the difference between \\fB=\\fR and \\fB|=\\fR:\n.\n.P\nProvide input \\fB{\"a\": {\"b\": 10}, \"b\": 20}\\fR to the programs\n.\n.IP \"\" 4\n.\n.nf\n\n\\&.a = \\.b\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nand\n.\n.IP \"\" 4\n.\n.nf\n\n\\&.a |= \\.b\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nThe former will set the \\fBa\\fR field of the input to the \\fBb\\fR field of the input, and produce the output \\fB{\"a\": 20, \"b\": 20}\\fR\\. The latter will set the \\fBa\\fR field of the input to the \\fBa\\fR field\\'s \\fBb\\fR field, producing \\fB{\"a\": 10, \"b\": 20}\\fR\\.\n.\n.IP \"\" 4\n.\n.nf\n\njq \\'\\.a = \\.b\\'\n   {\"a\": {\"b\": 10}, \"b\": 20}\n=> {\"a\":20,\"b\":20}\n\njq \\'\\.a |= \\.b\\'\n   {\"a\": {\"b\": 10}, \"b\": 20}\n=> {\"a\":10,\"b\":20}\n\njq \\'(\\.a, \\.b) = range(3)\\'\n   null\n=> {\"a\":0,\"b\":0}, {\"a\":1,\"b\":1}, {\"a\":2,\"b\":2}\n\njq \\'(\\.a, \\.b) |= range(3)\\'\n   null\n=> {\"a\":0,\"b\":0}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SS \"Complex assignments\"\nLots more things are allowed on the left\\-hand side of a jq assignment than in most languages\\. We\\'ve already seen simple field accesses on the left hand side, and it\\'s no surprise that array accesses work just as well:\n.\n.IP \"\" 4\n.\n.nf\n\n\\&.posts[0]\\.title = \"JQ Manual\"\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nWhat may come as a surprise is that the expression on the left may produce multiple results, referring to different points in the input document:\n.\n.IP \"\" 4\n.\n.nf\n\n\\&.posts[]\\.comments |= \\. + [\"this is great\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nThat example appends the string \"this is great\" to the \"comments\" array of each post in the input (where the input is an object with a field \"posts\" which is an array of posts)\\.\n.\n.P\nWhen jq encounters an assignment like \\'a = b\\', it records the \"path\" taken to select a part of the input document while executing a\\. This path is then used to find which part of the input to change while executing the assignment\\. Any filter may be used on the left\\-hand side of an equals \\- whichever paths it selects from the input will be where the assignment is performed\\.\n.\n.P\nThis is a very powerful operation\\. Suppose we wanted to add a comment to blog posts, using the same \"blog\" input above\\. This time, we only want to comment on the posts written by \"stedolan\"\\. We can find those posts using the \"select\" function described earlier:\n.\n.IP \"\" 4\n.\n.nf\n\n\\&.posts[] | select(\\.author == \"stedolan\")\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nThe paths provided by this operation point to each of the posts that \"stedolan\" wrote, and we can comment on each of them in the same way that we did before:\n.\n.IP \"\" 4\n.\n.nf\n\n(\\.posts[] | select(\\.author == \"stedolan\") | \\.comments) |=\n    \\. + [\"terrible\\.\"]\n.\n.fi\n.\n.IP \"\" 0\n.\n.SH \"COMMENTS\"\nYou can write comments in your jq filters using \\fB#\\fR\\.\n.\n.P\nA \\fB#\\fR character (not part of a string) starts a comment\\. All characters from \\fB#\\fR to the end of the line are ignored\\.\n.\n.P\nIf the end of the line is preceded by an odd number of backslash characters, the following line is also considered part of the comment and is ignored\\.\n.\n.P\nFor example, the following code outputs \\fB[1,3,4,7]\\fR\n.\n.IP \"\" 4\n.\n.nf\n\n[\n  1,\n  # foo \\e\n  2,\n  # bar \\e\\e\n  3,\n  4, # baz \\e\\e\\e\n  5, \\e\n  6,\n  7\n  # comment \\e\n    comment \\e\n    comment\n]\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nBackslash continuing the comment on the next line can be useful when writing the \"shebang\" for a jq script:\n.\n.IP \"\" 4\n.\n.nf\n\n#!/bin/sh \\-\\-\n# total \\- Output the sum of the given arguments (or stdin)\n# usage: total [numbers\\.\\.\\.]\n# \\e\nexec jq \\-\\-args \\-MRnf \\-\\- \"$0\" \"$@\"\n\n$ARGS\\.positional |\nreduce (\n  if \\. == []\n    then inputs\n    else \\.[]\n  end |\n  \\. as $dot |\n  try tonumber catch false |\n  if not or isnan then\n    @json \"total: Invalid number \\e($dot)\\.\\en\" | halt_error(1)\n  end\n) as $n (0; \\. + $n)\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nThe \\fBexec\\fR line is considered a comment by jq, so it is ignored\\. But it is not ignored by \\fBsh\\fR, since in \\fBsh\\fR a backslash at the end of the line does not continue the comment\\. With this trick, when the script is invoked as \\fBtotal 1 2\\fR, \\fB/bin/sh \\-\\- /path/to/total 1 2\\fR will be run, and \\fBsh\\fR will then run \\fBexec jq \\-\\-args \\-MRnf \\-\\- /path/to/total 1 2\\fR replacing itself with a \\fBjq\\fR interpreter invoked with the specified options (\\fB\\-M\\fR, \\fB\\-R\\fR, \\fB\\-n\\fR, \\fB\\-\\-args\\fR), that evaluates the current file (\\fB$0\\fR), with the arguments (\\fB$@\\fR) that were passed to \\fBsh\\fR\\.\n.\n.SH \"MODULES\"\njq has a library/module system\\. Modules are files whose names end in \\fB\\.jq\\fR\\.\n.\n.P\nModules imported by a program are searched for in a default search path (see below)\\. The \\fBimport\\fR and \\fBinclude\\fR directives allow the importer to alter this path\\.\n.\n.P\nPaths in the search path are subject to various substitutions\\.\n.\n.P\nFor paths starting with \\fB~/\\fR, the user\\'s home directory is substituted for \\fB~\\fR\\.\n.\n.P\nFor paths starting with \\fB$ORIGIN/\\fR, the directory where the jq executable is located is substituted for \\fB$ORIGIN\\fR\\.\n.\n.P\nFor paths starting with \\fB\\./\\fR or paths that are \\fB\\.\\fR, the path of the including file is substituted for \\fB\\.\\fR\\. For top\\-level programs given on the command\\-line, the current directory is used\\.\n.\n.P\nImport directives can optionally specify a search path to which the default is appended\\.\n.\n.P\nThe default search path is the search path given to the \\fB\\-L\\fR command\\-line option, else \\fB[\"~/\\.jq\", \"$ORIGIN/\\.\\./lib/jq\", \"$ORIGIN/\\.\\./lib\"]\\fR\\.\n.\n.P\nNull and empty string path elements terminate search path processing\\.\n.\n.P\nA dependency with relative path \\fBfoo/bar\\fR would be searched for in \\fBfoo/bar\\.jq\\fR and \\fBfoo/bar/bar\\.jq\\fR in the given search path\\. This is intended to allow modules to be placed in a directory along with, for example, version control files, README files, and so on, but also to allow for single\\-file modules\\.\n.\n.P\nConsecutive components with the same name are not allowed to avoid ambiguities (e\\.g\\., \\fBfoo/foo\\fR)\\.\n.\n.P\nFor example, with \\fB\\-L$HOME/\\.jq\\fR a module \\fBfoo\\fR can be found in \\fB$HOME/\\.jq/foo\\.jq\\fR and \\fB$HOME/\\.jq/foo/foo\\.jq\\fR\\.\n.\n.P\nIf \\fB\\.jq\\fR exists in the user\\'s home directory, and is a file (not a directory), it is automatically sourced into the main program\\.\n.\n.SS \"import RelativePathString as NAME [<metadata>];\"\nImports a module found at the given path relative to a directory in a search path\\. A \\fB\\.jq\\fR suffix will be added to the relative path string\\. The module\\'s symbols are prefixed with \\fBNAME::\\fR\\.\n.\n.P\nThe optional metadata must be a constant jq expression\\. It should be an object with keys like \\fBhomepage\\fR and so on\\. At this time jq only uses the \\fBsearch\\fR key/value of the metadata\\. The metadata is also made available to users via the \\fBmodulemeta\\fR builtin\\.\n.\n.P\nThe \\fBsearch\\fR key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top\\-level search path\\.\n.\n.SS \"include RelativePathString [<metadata>];\"\nImports a module found at the given path relative to a directory in a search path as if it were included in place\\. A \\fB\\.jq\\fR suffix will be added to the relative path string\\. The module\\'s symbols are imported into the caller\\'s namespace as if the module\\'s content had been included directly\\.\n.\n.P\nThe optional metadata must be a constant jq expression\\. It should be an object with keys like \\fBhomepage\\fR and so on\\. At this time jq only uses the \\fBsearch\\fR key/value of the metadata\\. The metadata is also made available to users via the \\fBmodulemeta\\fR builtin\\.\n.\n.SS \"import RelativePathString as $NAME [<metadata>];\"\nImports a JSON file found at the given path relative to a directory in a search path\\. A \\fB\\.json\\fR suffix will be added to the relative path string\\. The file\\'s data will be available as \\fB$NAME::NAME\\fR\\.\n.\n.P\nThe optional metadata must be a constant jq expression\\. It should be an object with keys like \\fBhomepage\\fR and so on\\. At this time jq only uses the \\fBsearch\\fR key/value of the metadata\\. The metadata is also made available to users via the \\fBmodulemeta\\fR builtin\\.\n.\n.P\nThe \\fBsearch\\fR key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top\\-level search path\\.\n.\n.SS \"module <metadata>;\"\nThis directive is entirely optional\\. It\\'s not required for proper operation\\. It serves only the purpose of providing metadata that can be read with the \\fBmodulemeta\\fR builtin\\.\n.\n.P\nThe metadata must be a constant jq expression\\. It should be an object with keys like \\fBhomepage\\fR\\. At this time jq doesn\\'t use this metadata, but it is made available to users via the \\fBmodulemeta\\fR builtin\\.\n.\n.SS \"modulemeta\"\nTakes a module name as input and outputs the module\\'s metadata as an object, with the module\\'s imports (including metadata) as an array value for the \\fBdeps\\fR key and the module\\'s defined functions as an array value for the \\fBdefs\\fR key\\.\n.\n.P\nPrograms can use this to query a module\\'s metadata, which they could then use to, for example, search for, download, and install missing dependencies\\.\n.\n.SH \"COLORS\"\nTo configure alternative colors just set the \\fBJQ_COLORS\\fR environment variable to colon\\-delimited list of partial terminal escape sequences like \\fB\"1;31\"\\fR, in this order:\n.\n.IP \"\\(bu\" 4\ncolor for \\fBnull\\fR\n.\n.IP \"\\(bu\" 4\ncolor for \\fBfalse\\fR\n.\n.IP \"\\(bu\" 4\ncolor for \\fBtrue\\fR\n.\n.IP \"\\(bu\" 4\ncolor for numbers\n.\n.IP \"\\(bu\" 4\ncolor for strings\n.\n.IP \"\\(bu\" 4\ncolor for arrays\n.\n.IP \"\\(bu\" 4\ncolor for objects\n.\n.IP \"\\(bu\" 4\ncolor for object keys\n.\n.IP \"\" 0\n.\n.P\nThe default color scheme is the same as setting \\fBJQ_COLORS=\"0;90:0;39:0;39:0;39:0;32:1;39:1;39:1;34\"\\fR\\.\n.\n.P\nThis is not a manual for VT100/ANSI escapes\\. However, each of these color specifications should consist of two numbers separated by a semi\\-colon, where the first number is one of these:\n.\n.IP \"\\(bu\" 4\n1 (bright)\n.\n.IP \"\\(bu\" 4\n2 (dim)\n.\n.IP \"\\(bu\" 4\n4 (underscore)\n.\n.IP \"\\(bu\" 4\n5 (blink)\n.\n.IP \"\\(bu\" 4\n7 (reverse)\n.\n.IP \"\\(bu\" 4\n8 (hidden)\n.\n.IP \"\" 0\n.\n.P\nand the second is one of these:\n.\n.IP \"\\(bu\" 4\n30 (black)\n.\n.IP \"\\(bu\" 4\n31 (red)\n.\n.IP \"\\(bu\" 4\n32 (green)\n.\n.IP \"\\(bu\" 4\n33 (yellow)\n.\n.IP \"\\(bu\" 4\n34 (blue)\n.\n.IP \"\\(bu\" 4\n35 (magenta)\n.\n.IP \"\\(bu\" 4\n36 (cyan)\n.\n.IP \"\\(bu\" 4\n37 (white)\n.\n.IP \"\" 0\n.\n.SH \"BUGS\"\nPresumably\\. Report them or discuss them at:\n.\n.IP \"\" 4\n.\n.nf\n\nhttps://github\\.com/jqlang/jq/issues\n.\n.fi\n.\n.IP \"\" 0\n.\n.SH \"AUTHOR\"\nStephen Dolan \\fB<mu@netsoc\\.tcd\\.ie>\\fR\n"
  },
  {
    "path": "jq.spec",
    "content": "# This is spec file maintained by developers of JQ, not by a OS distro.\n# Your OS of choice will likely ignore this RPM spec file.\nSummary: Command-line JSON processor\nName: jq\nVersion: %{myver}\nRelease: %{myrel}%{?dist}\nSource0: jq-%{myver}.tar.gz\nURL: https://jqlang.org\nLicense: MIT AND ICU AND CC-BY-3.0\nAutoReqProv: no\n#BuildPrereq: autoconf, libtool, automake, flex, bison, python\n\nGroup: Applications/System\n# Requires:\n\n# Disables debug packages and stripping of binaries:\n%global _enable_debug_package 0\n%global debug_package %{nil}\n%global __os_install_post %{nil}\n\n# Crank up the compression\n%define _binary_payload w7.lzdio\n\n%description\njq is a command-line JSON processor\n\n%prep\n%setup\n\n%build\necho \"Building in: \\\"$(pwd)\\\"\"\n%if \"%{devbuild}\" == \"yes\"\n./configure --prefix=%{_prefix} --enable-devel\n%else\n./configure --prefix=%{_prefix}\n%endif\nmake\n\n%install\necho \"Installing to: \\\"%{buildroot}\\\"\"\nmake install DESTDIR=%{buildroot}\n\n%clean\nrm -rf %{buildroot}\n\n%files\n%defattr(-,root,root)\n%{_bindir}/jq\n%if \"%{devbuild}\" == \"yes\"\n%{_libexecdir}/%{name}/jq_test\n%{_libexecdir}/%{name}/testdata\n%endif\n%{_datadir}/doc/%{name}/AUTHORS\n%{_datadir}/doc/%{name}/COPYING\n%{_datadir}/doc/%{name}/README.md\n%{_datadir}/man/man1/jq.1\n%{_includedir}/jq.h\n%{_includedir}/jv.h\n%{_prefix}/lib/libjq.a\n%{_prefix}/lib/libjq.la\n%{_prefix}/lib/libjq.so\n%{_prefix}/lib/libjq.so.1\n%{_prefix}/lib/libjq.so.1.0.4\n\n%changelog\n\n%pre\n\n%post\n"
  },
  {
    "path": "libjq.pc.in",
    "content": "prefix=@prefix@\nexec_prefix=@exec_prefix@\nlibdir=@libdir@\nincludedir=@includedir@\n\nName: libjq\nURL: https://jqlang.org/\nDescription: Library to process JSON using a query language\nVersion: @VERSION@\nLibs: -L${libdir} -ljq\nCflags: -I${includedir}\n"
  },
  {
    "path": "m4/ax_compare_version.m4",
    "content": "# ===========================================================================\n#    http://www.gnu.org/software/autoconf-archive/ax_compare_version.html\n# ===========================================================================\n#\n# SYNOPSIS\n#\n#   AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])\n#\n# DESCRIPTION\n#\n#   This macro compares two version strings. Due to the various number of\n#   minor-version numbers that can exist, and the fact that string\n#   comparisons are not compatible with numeric comparisons, this is not\n#   necessarily trivial to do in a autoconf script. This macro makes doing\n#   these comparisons easy.\n#\n#   The six basic comparisons are available, as well as checking equality\n#   limited to a certain number of minor-version levels.\n#\n#   The operator OP determines what type of comparison to do, and can be one\n#   of:\n#\n#    eq  - equal (test A == B)\n#    ne  - not equal (test A != B)\n#    le  - less than or equal (test A <= B)\n#    ge  - greater than or equal (test A >= B)\n#    lt  - less than (test A < B)\n#    gt  - greater than (test A > B)\n#\n#   Additionally, the eq and ne operator can have a number after it to limit\n#   the test to that number of minor versions.\n#\n#    eq0 - equal up to the length of the shorter version\n#    ne0 - not equal up to the length of the shorter version\n#    eqN - equal up to N sub-version levels\n#    neN - not equal up to N sub-version levels\n#\n#   When the condition is true, shell commands ACTION-IF-TRUE are run,\n#   otherwise shell commands ACTION-IF-FALSE are run. The environment\n#   variable 'ax_compare_version' is always set to either 'true' or 'false'\n#   as well.\n#\n#   Examples:\n#\n#     AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])\n#     AX_COMPARE_VERSION([3.15],[lt],[3.15.8])\n#\n#   would both be true.\n#\n#     AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])\n#     AX_COMPARE_VERSION([3.15],[gt],[3.15.8])\n#\n#   would both be false.\n#\n#     AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])\n#\n#   would be true because it is only comparing two minor versions.\n#\n#     AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])\n#\n#   would be true because it is only comparing the lesser number of minor\n#   versions of the two values.\n#\n#   Note: The characters that separate the version numbers do not matter. An\n#   empty string is the same as version 0. OP is evaluated by autoconf, not\n#   configure, so must be a string, not a variable.\n#\n#   The author would like to acknowledge Guido Draheim whose advice about\n#   the m4_case and m4_ifvaln functions make this macro only include the\n#   portions necessary to perform the specific comparison specified by the\n#   OP argument in the final configure script.\n#\n# LICENSE\n#\n#   Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu>\n#\n#   Copying and distribution of this file, with or without modification, are\n#   permitted in any medium without royalty provided the copyright notice\n#   and this notice are preserved. This file is offered as-is, without any\n#   warranty.\n\n#serial 11\n\ndnl #########################################################################\nAC_DEFUN([AX_COMPARE_VERSION], [\n  AC_REQUIRE([AC_PROG_AWK])\n\n  # Used to indicate true or false condition\n  ax_compare_version=false\n\n  # Convert the two version strings to be compared into a format that\n  # allows a simple string comparison.  The end result is that a version\n  # string of the form 1.12.5-r617 will be converted to the form\n  # 0001001200050617.  In other words, each number is zero padded to four\n  # digits, and non digits are removed.\n  AS_VAR_PUSHDEF([A],[ax_compare_version_A])\n  A=`echo \"$1\" | sed -e 's/\\([[0-9]]*\\)/Z\\1Z/g' \\\n                     -e 's/Z\\([[0-9]]\\)Z/Z0\\1Z/g' \\\n                     -e 's/Z\\([[0-9]][[0-9]]\\)Z/Z0\\1Z/g' \\\n                     -e 's/Z\\([[0-9]][[0-9]][[0-9]]\\)Z/Z0\\1Z/g' \\\n                     -e 's/[[^0-9]]//g'`\n\n  AS_VAR_PUSHDEF([B],[ax_compare_version_B])\n  B=`echo \"$3\" | sed -e 's/\\([[0-9]]*\\)/Z\\1Z/g' \\\n                     -e 's/Z\\([[0-9]]\\)Z/Z0\\1Z/g' \\\n                     -e 's/Z\\([[0-9]][[0-9]]\\)Z/Z0\\1Z/g' \\\n                     -e 's/Z\\([[0-9]][[0-9]][[0-9]]\\)Z/Z0\\1Z/g' \\\n                     -e 's/[[^0-9]]//g'`\n\n  dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary\n  dnl # then the first line is used to determine if the condition is true.\n  dnl # The sed right after the echo is to remove any indented white space.\n  m4_case(m4_tolower($2),\n  [lt],[\n    ax_compare_version=`echo \"x$A\nx$B\" | sed 's/^ *//' | sort -r | sed \"s/x${A}/false/;s/x${B}/true/;1q\"`\n  ],\n  [gt],[\n    ax_compare_version=`echo \"x$A\nx$B\" | sed 's/^ *//' | sort | sed \"s/x${A}/false/;s/x${B}/true/;1q\"`\n  ],\n  [le],[\n    ax_compare_version=`echo \"x$A\nx$B\" | sed 's/^ *//' | sort | sed \"s/x${A}/true/;s/x${B}/false/;1q\"`\n  ],\n  [ge],[\n    ax_compare_version=`echo \"x$A\nx$B\" | sed 's/^ *//' | sort -r | sed \"s/x${A}/true/;s/x${B}/false/;1q\"`\n  ],[\n    dnl Split the operator from the subversion count if present.\n    m4_bmatch(m4_substr($2,2),\n    [0],[\n      # A count of zero means use the length of the shorter version.\n      # Determine the number of characters in A and B.\n      ax_compare_version_len_A=`echo \"$A\" | $AWK '{print(length)}'`\n      ax_compare_version_len_B=`echo \"$B\" | $AWK '{print(length)}'`\n\n      # Set A to no more than B's length and B to no more than A's length.\n      A=`echo \"$A\" | sed \"s/\\(.\\{$ax_compare_version_len_B\\}\\).*/\\1/\"`\n      B=`echo \"$B\" | sed \"s/\\(.\\{$ax_compare_version_len_A\\}\\).*/\\1/\"`\n    ],\n    [[0-9]+],[\n      # A count greater than zero means use only that many subversions\n      A=`echo \"$A\" | sed \"s/\\(\\([[0-9]]\\{4\\}\\)\\{m4_substr($2,2)\\}\\).*/\\1/\"`\n      B=`echo \"$B\" | sed \"s/\\(\\([[0-9]]\\{4\\}\\)\\{m4_substr($2,2)\\}\\).*/\\1/\"`\n    ],\n    [.+],[\n      AC_WARNING(\n        [illegal OP numeric parameter: $2])\n    ],[])\n\n    # Pad zeros at end of numbers to make same length.\n    ax_compare_version_tmp_A=\"$A`echo $B | sed 's/./0/g'`\"\n    B=\"$B`echo $A | sed 's/./0/g'`\"\n    A=\"$ax_compare_version_tmp_A\"\n\n    # Check for equality or inequality as necessary.\n    m4_case(m4_tolower(m4_substr($2,0,2)),\n    [eq],[\n      test \"x$A\" = \"x$B\" && ax_compare_version=true\n    ],\n    [ne],[\n      test \"x$A\" != \"x$B\" && ax_compare_version=true\n    ],[\n      AC_WARNING([illegal OP parameter: $2])\n    ])\n  ])\n\n  AS_VAR_POPDEF([A])dnl\n  AS_VAR_POPDEF([B])dnl\n\n  dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.\n  if test \"$ax_compare_version\" = \"true\" ; then\n    m4_ifvaln([$4],[$4],[:])dnl\n    m4_ifvaln([$5],[else $5])dnl\n  fi\n]) dnl AX_COMPARE_VERSION\n"
  },
  {
    "path": "m4/ax_prog_bison_version.m4",
    "content": "# ===========================================================================\n#   Modified from\n#   http://www.gnu.org/software/autoconf-archive/ax_prog_perl_version.html\n# ===========================================================================\n#\n# SYNOPSIS\n#\n#   AX_PROG_BISON_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE])\n#\n# DESCRIPTION\n#\n#   Makes sure that bison supports the version indicated. If true the shell\n#   commands in ACTION-IF-TRUE are executed. If not the shell commands in\n#   ACTION-IF-FALSE are run. Note if $PERL is not set the macro will fail.\n#\n#   Example:\n#\n#     AC_PROG_YACC\n#     AX_PROG_BISON_VERSION([3.0.0],[ ... ],[ ... ])\n#\n#   This will check to make sure that the bison you have supports at least\n#   version 3.0.0.\n#\n#   NOTE: This macro uses the $YACC variable to perform the check.\n#   AX_WITH_YACC can be used to set that variable prior to running this\n#   macro. The $BISON_VERSION variable will be set with the detected\n#   version.\n#\n# LICENSE\n#\n#   Copyright (c) 2009 Francesco Salvestrini <salvestrini@users.sourceforge.net>\n#\n#   Copying and distribution of this file, with or without modification, are\n#   permitted in any medium without royalty provided the copyright notice\n#   and this notice are preserved. This file is offered as-is, without any\n#   warranty.\n\n#serial 12\n\nAC_DEFUN([AX_PROG_BISON_VERSION],[\n    AC_REQUIRE([AC_PROG_SED])\n    AC_REQUIRE([AC_PROG_GREP])\n\n    AS_IF([test -n \"$YACC\"],[\n        ax_bison_version=\"$1\"\n\n        AC_MSG_CHECKING([for bison version])\n        changequote(<<,>>)\n        bison_version=`$YACC --version 2>&1 \\\n          | $GREP bison \\\n          | $SED -e 's/^[^0-9]*//' -e 's/[^0-9]*$//'`\n        changequote([,])\n        AC_MSG_RESULT($bison_version)\n\n\tAC_SUBST([BISON_VERSION],[$bison_version])\n\n        AX_COMPARE_VERSION([$ax_bison_version],[le],[$bison_version],[\n\t    :\n            $2\n        ],[\n\t    :\n            $3\n        ])\n    ],[\n        AC_MSG_WARN([could not find bison])\n        $3\n    ])\n])\n"
  },
  {
    "path": "m4/ax_pthread.m4",
    "content": "# ===========================================================================\n#        https://www.gnu.org/software/autoconf-archive/ax_pthread.html\n# ===========================================================================\n#\n# SYNOPSIS\n#\n#   AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])\n#\n# DESCRIPTION\n#\n#   This macro figures out how to build C programs using POSIX threads. It\n#   sets the PTHREAD_LIBS output variable to the threads library and linker\n#   flags, and the PTHREAD_CFLAGS output variable to any special C compiler\n#   flags that are needed. (The user can also force certain compiler\n#   flags/libs to be tested by setting these environment variables.)\n#\n#   Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is\n#   needed for multi-threaded programs (defaults to the value of CC\n#   respectively CXX otherwise). (This is necessary on e.g. AIX to use the\n#   special cc_r/CC_r compiler alias.)\n#\n#   NOTE: You are assumed to not only compile your program with these flags,\n#   but also to link with them as well. For example, you might link with\n#   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS\n#   $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS\n#\n#   If you are only building threaded programs, you may wish to use these\n#   variables in your default LIBS, CFLAGS, and CC:\n#\n#     LIBS=\"$PTHREAD_LIBS $LIBS\"\n#     CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n#     CXXFLAGS=\"$CXXFLAGS $PTHREAD_CFLAGS\"\n#     CC=\"$PTHREAD_CC\"\n#     CXX=\"$PTHREAD_CXX\"\n#\n#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant\n#   has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to\n#   that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).\n#\n#   Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the\n#   PTHREAD_PRIO_INHERIT symbol is defined when compiling with\n#   PTHREAD_CFLAGS.\n#\n#   ACTION-IF-FOUND is a list of shell commands to run if a threads library\n#   is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it\n#   is not found. If ACTION-IF-FOUND is not specified, the default action\n#   will define HAVE_PTHREAD.\n#\n#   Please let the authors know if this macro fails on any platform, or if\n#   you have any other suggestions or comments. This macro was based on work\n#   by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help\n#   from M. Frigo), as well as ac_pthread and hb_pthread macros posted by\n#   Alejandro Forero Cuervo to the autoconf macro repository. We are also\n#   grateful for the helpful feedback of numerous users.\n#\n#   Updated for Autoconf 2.68 by Daniel Richard G.\n#\n# LICENSE\n#\n#   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>\n#   Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>\n#   Copyright (c) 2019 Marc Stevens <marc.stevens@cwi.nl>\n#\n#   This program is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by the\n#   Free Software Foundation, either version 3 of the License, or (at your\n#   option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General\n#   Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License along\n#   with this program. If not, see <https://www.gnu.org/licenses/>.\n#\n#   As a special exception, the respective Autoconf Macro's copyright owner\n#   gives unlimited permission to copy, distribute and modify the configure\n#   scripts that are the output of Autoconf when processing the Macro. You\n#   need not follow the terms of the GNU General Public License when using\n#   or distributing such scripts, even though portions of the text of the\n#   Macro appear in them. The GNU General Public License (GPL) does govern\n#   all other use of the material that constitutes the Autoconf Macro.\n#\n#   This special exception to the GPL applies to versions of the Autoconf\n#   Macro released by the Autoconf Archive. When you make and distribute a\n#   modified version of the Autoconf Macro, you may extend this special\n#   exception to the GPL to apply to your modified version as well.\n\n#serial 31\n\nAU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])\nAC_DEFUN([AX_PTHREAD], [\nAC_REQUIRE([AC_CANONICAL_HOST])\nAC_REQUIRE([AC_PROG_CC])\nAC_REQUIRE([AC_PROG_SED])\nAC_LANG_PUSH([C])\nax_pthread_ok=no\n\n# We used to check for pthread.h first, but this fails if pthread.h\n# requires special compiler flags (e.g. on Tru64 or Sequent).\n# It gets checked for in the link test anyway.\n\n# First of all, check if the user has set any of the PTHREAD_LIBS,\n# etcetera environment variables, and if threads linking works using\n# them:\nif test \"x$PTHREAD_CFLAGS$PTHREAD_LIBS\" != \"x\"; then\n        ax_pthread_save_CC=\"$CC\"\n        ax_pthread_save_CFLAGS=\"$CFLAGS\"\n        ax_pthread_save_LIBS=\"$LIBS\"\n        AS_IF([test \"x$PTHREAD_CC\" != \"x\"], [CC=\"$PTHREAD_CC\"])\n        AS_IF([test \"x$PTHREAD_CXX\" != \"x\"], [CXX=\"$PTHREAD_CXX\"])\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])\n        AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])\n        AC_MSG_RESULT([$ax_pthread_ok])\n        if test \"x$ax_pthread_ok\" = \"xno\"; then\n                PTHREAD_LIBS=\"\"\n                PTHREAD_CFLAGS=\"\"\n        fi\n        CC=\"$ax_pthread_save_CC\"\n        CFLAGS=\"$ax_pthread_save_CFLAGS\"\n        LIBS=\"$ax_pthread_save_LIBS\"\nfi\n\n# We must check for the threads library under a number of different\n# names; the ordering is very important because some systems\n# (e.g. DEC) have both -lpthread and -lpthreads, where one of the\n# libraries is broken (non-POSIX).\n\n# Create a list of thread flags to try. Items with a \",\" contain both\n# C compiler flags (before \",\") and linker flags (after \",\"). Other items\n# starting with a \"-\" are C compiler flags, and remaining items are\n# library names, except for \"none\" which indicates that we try without\n# any flags at all, and \"pthread-config\" which is a program returning\n# the flags for the Pth emulation library.\n\nax_pthread_flags=\"pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config\"\n\n# The ordering *is* (sometimes) important.  Some notes on the\n# individual items follow:\n\n# pthreads: AIX (must check this before -lpthread)\n# none: in case threads are in libc; should be tried before -Kthread and\n#       other compiler flags to prevent continual compiler warnings\n# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)\n# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64\n#           (Note: HP C rejects this with \"bad form for `-t' option\")\n# -pthreads: Solaris/gcc (Note: HP C also rejects)\n# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it\n#      doesn't hurt to check since this sometimes defines pthreads and\n#      -D_REENTRANT too), HP C (must be checked before -lpthread, which\n#      is present but should not be used directly; and before -mthreads,\n#      because the compiler interprets this as \"-mt\" + \"-hreads\")\n# -mthreads: Mingw32/gcc, Lynx/gcc\n# pthread: Linux, etcetera\n# --thread-safe: KAI C++\n# pthread-config: use pthread-config program (for GNU Pth library)\n\ncase $host_os in\n\n        freebsd*)\n\n        # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)\n        # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)\n\n        ax_pthread_flags=\"-kthread lthread $ax_pthread_flags\"\n        ;;\n\n        hpux*)\n\n        # From the cc(1) man page: \"[-mt] Sets various -D flags to enable\n        # multi-threading and also sets -lpthread.\"\n\n        ax_pthread_flags=\"-mt -pthread pthread $ax_pthread_flags\"\n        ;;\n\n        openedition*)\n\n        # IBM z/OS requires a feature-test macro to be defined in order to\n        # enable POSIX threads at all, so give the user a hint if this is\n        # not set. (We don't define these ourselves, as they can affect\n        # other portions of the system API in unpredictable ways.)\n\n        AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],\n            [\n#            if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)\n             AX_PTHREAD_ZOS_MISSING\n#            endif\n            ],\n            [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])\n        ;;\n\n        solaris*)\n\n        # On Solaris (at least, for some versions), libc contains stubbed\n        # (non-functional) versions of the pthreads routines, so link-based\n        # tests will erroneously succeed. (N.B.: The stubs are missing\n        # pthread_cleanup_push, or rather a function called by this macro,\n        # so we could check for that, but who knows whether they'll stub\n        # that too in a future libc.)  So we'll check first for the\n        # standard Solaris way of linking pthreads (-mt -lpthread).\n\n        ax_pthread_flags=\"-mt,-lpthread pthread $ax_pthread_flags\"\n        ;;\nesac\n\n# Are we compiling with Clang?\n\nAC_CACHE_CHECK([whether $CC is Clang],\n    [ax_cv_PTHREAD_CLANG],\n    [ax_cv_PTHREAD_CLANG=no\n     # Note that Autoconf sets GCC=yes for Clang as well as GCC\n     if test \"x$GCC\" = \"xyes\"; then\n        AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],\n            [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */\n#            if defined(__clang__) && defined(__llvm__)\n             AX_PTHREAD_CC_IS_CLANG\n#            endif\n            ],\n            [ax_cv_PTHREAD_CLANG=yes])\n     fi\n    ])\nax_pthread_clang=\"$ax_cv_PTHREAD_CLANG\"\n\n\n# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)\n\n# Note that for GCC and Clang -pthread generally implies -lpthread,\n# except when -nostdlib is passed.\n# This is problematic using libtool to build C++ shared libraries with pthread:\n# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460\n# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333\n# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555\n# To solve this, first try -pthread together with -lpthread for GCC\n\nAS_IF([test \"x$GCC\" = \"xyes\"],\n      [ax_pthread_flags=\"-pthread,-lpthread -pthread -pthreads $ax_pthread_flags\"])\n\n# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first\n\nAS_IF([test \"x$ax_pthread_clang\" = \"xyes\"],\n      [ax_pthread_flags=\"-pthread,-lpthread -pthread\"])\n\n\n# The presence of a feature test macro requesting re-entrant function\n# definitions is, on some systems, a strong hint that pthreads support is\n# correctly enabled\n\ncase $host_os in\n        darwin* | hpux* | linux* | osf* | solaris*)\n        ax_pthread_check_macro=\"_REENTRANT\"\n        ;;\n\n        aix*)\n        ax_pthread_check_macro=\"_THREAD_SAFE\"\n        ;;\n\n        *)\n        ax_pthread_check_macro=\"--\"\n        ;;\nesac\nAS_IF([test \"x$ax_pthread_check_macro\" = \"x--\"],\n      [ax_pthread_check_cond=0],\n      [ax_pthread_check_cond=\"!defined($ax_pthread_check_macro)\"])\n\n\nif test \"x$ax_pthread_ok\" = \"xno\"; then\nfor ax_pthread_try_flag in $ax_pthread_flags; do\n\n        case $ax_pthread_try_flag in\n                none)\n                AC_MSG_CHECKING([whether pthreads work without any flags])\n                ;;\n\n                *,*)\n                PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed \"s/^\\(.*\\),\\(.*\\)$/\\1/\"`\n                PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed \"s/^\\(.*\\),\\(.*\\)$/\\2/\"`\n                AC_MSG_CHECKING([whether pthreads work with \"$PTHREAD_CFLAGS\" and \"$PTHREAD_LIBS\"])\n                ;;\n\n                -*)\n                AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])\n                PTHREAD_CFLAGS=\"$ax_pthread_try_flag\"\n                ;;\n\n                pthread-config)\n                AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])\n                AS_IF([test \"x$ax_pthread_config\" = \"xno\"], [continue])\n                PTHREAD_CFLAGS=\"`pthread-config --cflags`\"\n                PTHREAD_LIBS=\"`pthread-config --ldflags` `pthread-config --libs`\"\n                ;;\n\n                *)\n                AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])\n                PTHREAD_LIBS=\"-l$ax_pthread_try_flag\"\n                ;;\n        esac\n\n        ax_pthread_save_CFLAGS=\"$CFLAGS\"\n        ax_pthread_save_LIBS=\"$LIBS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n\n        # Check for various functions.  We must include pthread.h,\n        # since some functions may be macros.  (On the Sequent, we\n        # need a special flag -Kthread to make this header compile.)\n        # We check for pthread_join because it is in -lpthread on IRIX\n        # while pthread_create is in libc.  We check for pthread_attr_init\n        # due to DEC craziness with -lpthreads.  We check for\n        # pthread_cleanup_push because it is one of the few pthread\n        # functions on Solaris that doesn't have a non-functional libc stub.\n        # We try pthread_create on general principles.\n\n        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>\n#                       if $ax_pthread_check_cond\n#                        error \"$ax_pthread_check_macro must be defined\"\n#                       endif\n                        static void *some_global = NULL;\n                        static void routine(void *a)\n                          {\n                             /* To avoid any unused-parameter or\n                                unused-but-set-parameter warning.  */\n                             some_global = a;\n                          }\n                        static void *start_routine(void *a) { return a; }],\n                       [pthread_t th; pthread_attr_t attr;\n                        pthread_create(&th, 0, start_routine, 0);\n                        pthread_join(th, 0);\n                        pthread_attr_init(&attr);\n                        pthread_cleanup_push(routine, 0);\n                        pthread_cleanup_pop(0) /* ; */])],\n            [ax_pthread_ok=yes],\n            [])\n\n        CFLAGS=\"$ax_pthread_save_CFLAGS\"\n        LIBS=\"$ax_pthread_save_LIBS\"\n\n        AC_MSG_RESULT([$ax_pthread_ok])\n        AS_IF([test \"x$ax_pthread_ok\" = \"xyes\"], [break])\n\n        PTHREAD_LIBS=\"\"\n        PTHREAD_CFLAGS=\"\"\ndone\nfi\n\n\n# Clang needs special handling, because older versions handle the -pthread\n# option in a rather... idiosyncratic way\n\nif test \"x$ax_pthread_clang\" = \"xyes\"; then\n\n        # Clang takes -pthread; it has never supported any other flag\n\n        # (Note 1: This will need to be revisited if a system that Clang\n        # supports has POSIX threads in a separate library.  This tends not\n        # to be the way of modern systems, but it's conceivable.)\n\n        # (Note 2: On some systems, notably Darwin, -pthread is not needed\n        # to get POSIX threads support; the API is always present and\n        # active.  We could reasonably leave PTHREAD_CFLAGS empty.  But\n        # -pthread does define _REENTRANT, and while the Darwin headers\n        # ignore this macro, third-party headers might not.)\n\n        # However, older versions of Clang make a point of warning the user\n        # that, in an invocation where only linking and no compilation is\n        # taking place, the -pthread option has no effect (\"argument unused\n        # during compilation\").  They expect -pthread to be passed in only\n        # when source code is being compiled.\n        #\n        # Problem is, this is at odds with the way Automake and most other\n        # C build frameworks function, which is that the same flags used in\n        # compilation (CFLAGS) are also used in linking.  Many systems\n        # supported by AX_PTHREAD require exactly this for POSIX threads\n        # support, and in fact it is often not straightforward to specify a\n        # flag that is used only in the compilation phase and not in\n        # linking.  Such a scenario is extremely rare in practice.\n        #\n        # Even though use of the -pthread flag in linking would only print\n        # a warning, this can be a nuisance for well-run software projects\n        # that build with -Werror.  So if the active version of Clang has\n        # this misfeature, we search for an option to squash it.\n\n        AC_CACHE_CHECK([whether Clang needs flag to prevent \"argument unused\" warning when linking with -pthread],\n            [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],\n            [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown\n             # Create an alternate version of $ac_link that compiles and\n             # links in two steps (.c -> .o, .o -> exe) instead of one\n             # (.c -> exe), because the warning occurs only in the second\n             # step\n             ax_pthread_save_ac_link=\"$ac_link\"\n             ax_pthread_sed='s/conftest\\.\\$ac_ext/conftest.$ac_objext/g'\n             ax_pthread_link_step=`AS_ECHO([\"$ac_link\"]) | sed \"$ax_pthread_sed\"`\n             ax_pthread_2step_ac_link=\"($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)\"\n             ax_pthread_save_CFLAGS=\"$CFLAGS\"\n             for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do\n                AS_IF([test \"x$ax_pthread_try\" = \"xunknown\"], [break])\n                CFLAGS=\"-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS\"\n                ac_link=\"$ax_pthread_save_ac_link\"\n                AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],\n                    [ac_link=\"$ax_pthread_2step_ac_link\"\n                     AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],\n                         [break])\n                    ])\n             done\n             ac_link=\"$ax_pthread_save_ac_link\"\n             CFLAGS=\"$ax_pthread_save_CFLAGS\"\n             AS_IF([test \"x$ax_pthread_try\" = \"x\"], [ax_pthread_try=no])\n             ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=\"$ax_pthread_try\"\n            ])\n\n        case \"$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG\" in\n                no | unknown) ;;\n                *) PTHREAD_CFLAGS=\"$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS\" ;;\n        esac\n\nfi # $ax_pthread_clang = yes\n\n\n\n# Various other checks:\nif test \"x$ax_pthread_ok\" = \"xyes\"; then\n        ax_pthread_save_CFLAGS=\"$CFLAGS\"\n        ax_pthread_save_LIBS=\"$LIBS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n\n        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.\n        AC_CACHE_CHECK([for joinable pthread attribute],\n            [ax_cv_PTHREAD_JOINABLE_ATTR],\n            [ax_cv_PTHREAD_JOINABLE_ATTR=unknown\n             for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do\n                 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],\n                                                 [int attr = $ax_pthread_attr; return attr /* ; */])],\n                                [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],\n                                [])\n             done\n            ])\n        AS_IF([test \"x$ax_cv_PTHREAD_JOINABLE_ATTR\" != \"xunknown\" && \\\n               test \"x$ax_cv_PTHREAD_JOINABLE_ATTR\" != \"xPTHREAD_CREATE_JOINABLE\" && \\\n               test \"x$ax_pthread_joinable_attr_defined\" != \"xyes\"],\n              [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],\n                                  [$ax_cv_PTHREAD_JOINABLE_ATTR],\n                                  [Define to necessary symbol if this constant\n                                   uses a non-standard name on your system.])\n               ax_pthread_joinable_attr_defined=yes\n              ])\n\n        AC_CACHE_CHECK([whether more special flags are required for pthreads],\n            [ax_cv_PTHREAD_SPECIAL_FLAGS],\n            [ax_cv_PTHREAD_SPECIAL_FLAGS=no\n             case $host_os in\n             solaris*)\n             ax_cv_PTHREAD_SPECIAL_FLAGS=\"-D_POSIX_PTHREAD_SEMANTICS\"\n             ;;\n             esac\n            ])\n        AS_IF([test \"x$ax_cv_PTHREAD_SPECIAL_FLAGS\" != \"xno\" && \\\n               test \"x$ax_pthread_special_flags_added\" != \"xyes\"],\n              [PTHREAD_CFLAGS=\"$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS\"\n               ax_pthread_special_flags_added=yes])\n\n        AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],\n            [ax_cv_PTHREAD_PRIO_INHERIT],\n            [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],\n                                             [[int i = PTHREAD_PRIO_INHERIT;\n                                               return i;]])],\n                            [ax_cv_PTHREAD_PRIO_INHERIT=yes],\n                            [ax_cv_PTHREAD_PRIO_INHERIT=no])\n            ])\n        AS_IF([test \"x$ax_cv_PTHREAD_PRIO_INHERIT\" = \"xyes\" && \\\n               test \"x$ax_pthread_prio_inherit_defined\" != \"xyes\"],\n              [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])\n               ax_pthread_prio_inherit_defined=yes\n              ])\n\n        CFLAGS=\"$ax_pthread_save_CFLAGS\"\n        LIBS=\"$ax_pthread_save_LIBS\"\n\n        # More AIX lossage: compile with *_r variant\n        if test \"x$GCC\" != \"xyes\"; then\n            case $host_os in\n                aix*)\n                AS_CASE([\"x/$CC\"],\n                    [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],\n                    [#handle absolute path differently from PATH based program lookup\n                     AS_CASE([\"x$CC\"],\n                         [x/*],\n                         [\n\t\t\t   AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC=\"${CC}_r\"])\n\t\t\t   AS_IF([test \"x${CXX}\" != \"x\"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX=\"${CXX}_r\"])])\n\t\t\t ],\n                         [\n\t\t\t   AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])\n\t\t\t   AS_IF([test \"x${CXX}\" != \"x\"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])])\n\t\t\t ]\n                     )\n                    ])\n                ;;\n            esac\n        fi\nfi\n\ntest -n \"$PTHREAD_CC\" || PTHREAD_CC=\"$CC\"\ntest -n \"$PTHREAD_CXX\" || PTHREAD_CXX=\"$CXX\"\n\nAC_SUBST([PTHREAD_LIBS])\nAC_SUBST([PTHREAD_CFLAGS])\nAC_SUBST([PTHREAD_CC])\nAC_SUBST([PTHREAD_CXX])\n\n# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:\nif test \"x$ax_pthread_ok\" = \"xyes\"; then\n        ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])\n        :\nelse\n        ax_pthread_ok=no\n        $2\nfi\nAC_LANG_POP\n])dnl AX_PTHREAD\n"
  },
  {
    "path": "scripts/crosscompile",
    "content": "#!/bin/sh\n\n# This script is used to cross-compile binaries for\n# platforms other than the current one\n\n# Usage: $0 <platformname> <configure options>\n# <platformname> is arbitrary, it is the name\n# of the directory which will be created to contain\n# the output binaries.\n\n# e.g. $0 win32 --host=i686-w64-mingw32\n\nset -e\ncd `dirname \"$0\"`/../build\n\njobs=-j4\ncase \"X$1\" in\nX-j*) jobs=$1; shift;;\nesac\n\nplat=\"$1\"\n[ -z \"$plat\" ] && exit 1\nshift\n\ncase \"$plat\" in\n*/*) echo \"platform name must not be a path\"; exit 1;;\n*..*) echo \"platform name must not be a path\"; exit 1;;\n*) plat=$PWD/$plat;;\nesac\n\n[ -d \"$plat\" ] || mkdir \"$plat\"\nrm -rf \"$plat/tmp\"\nmkdir \"$plat/tmp\"\ncd \"$plat/tmp\"\n../../../configure \"$@\"\nmake \"$jobs\" DESTDIR=$plat install\nset -x\nfor jq in `find . -type f \\( -name jq -o -name jq.exe \\) -print`; do\n    cp \"$jq\" ..\ndone\ncd ..\nrm -rf tmp\n\n"
  },
  {
    "path": "scripts/gen_utf8_tables.py",
    "content": "#!/usr/bin/python\n\n# This program was used to generate jv_utf8_tables.gen.h\n\nmask = lambda n: (1 << n) - 1\n\n\ndef print_table(type, name, t):\n    print(\"static const %s %s[] =\" % (type, name))\n    for i in range(0,len(t),16):\n        print ((\" {\" if i == 0 else \"  \") +\n               \", \".join(\"0x%02x\"%n for n in t[i:i+16]) +\n               (\",\" if i + 16 < len(t) else \"};\"))\n\n\ndef utf8info(c):\n    if c < 0x80: return 1, mask(7)\n    if 0x80 <= c <= 0xBF: return 255, mask(6)\n    if 0xC0 <= c <= 0xC1: return 0, 0\n    if 0xC2 <= c <= 0xDF: return 2, mask(5)\n    if 0xE0 <= c <= 0xEF: return 3, mask(4)\n    if 0xF0 <= c <= 0xF4: return 4, mask(3)\n    if 0xF4 <= c <= 0xFF: return 0, 0\n\ntable = lambda i: [utf8info(c)[i] for c in range(256)]\n\nprint(\"#define UTF8_CONTINUATION_BYTE ((unsigned char)255)\")\n\nprint_table(\"unsigned char\", \"utf8_coding_length\", table(0))\nprint_table(\"unsigned char\", \"utf8_coding_bits\", table(1))\nprint_table(\"int\", \"utf8_first_codepoint\", [0, 0x0, 0x80, 0x800, 0x10000])\n"
  },
  {
    "path": "scripts/version",
    "content": "#!/bin/sh\nset -eu\n\ncd \"$(dirname \"$0\")/../\"\ntest -e .git || exit 1\n\nif git describe --tags --match 'jq-*' >/dev/null 2>&1; then\n  git describe --tags --match 'jq-*' --dirty | sed 's/^jq-//'\nelse\n  branch=$(git rev-parse --abbrev-ref HEAD)\n  commit=$(git describe --always --dirty)\n  echo \"${branch}-${commit}\"\nfi\n"
  },
  {
    "path": "sig/jq-release-new.key",
    "content": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBGiLapUBEADQOs2nBPkTE+kvvYlBwLo87W1sfMmj6Vf/HCzdCiQs3oye26d2\n3rLHvgpr3Tyst3bp1VpZGATV97PxjZMOkxHfIkW+T1VubiWN6c1veBP6T0BycfLN\nl2PbY+7FWY6pJPcKSrxMGyHqJYLs196JrGWyVJt2xHg6V8V8bEeVTXVyJsz175+a\nzGPbXMeM6F6v3vwMBHD0EzgS2hE4NFbiqprgo11vOV1+/WOQ3GkyonEDyWchocNY\nTZ9pIxUPnuBJKvf2vmOyYh6nr6PbN2aNA4JPCWGa3CwpWcsW0tTjLW5fIfWj5idH\njzDEdrG4tDUxxUVAElFun85T6p1JNzSwuMRkKbnkfvH6maNAhlp+XCXko7mo5jsh\nms9eysg9jnarvwwilh84q6ZHyf3qn/U9eEstiSCGuJ4OvqlYxY81rLEmNpL+FZ9r\nIzwMVY1O2WOnRuqpVjZiI4dy4TUcAdaVKCsI3GrDBH/hJJUjg/JybM6nEURy4w95\nO7g2LEn2DL4XjYhOXTbjaEdJaxCSYBX8CfZTlkzmPG1ea4IeXjXBmlMavMQGix5b\na3XAPUYB+IQALneQ00ME1KphJn0uCkH5a2GzPyW0uyliJye4F+g2KIo1gQgIIItt\nnptxby/AwrAd955DkAYXYWza5WwsRZ/bmHNmAgIFJfIclo89glQ/Za/z2QARAQAB\ntDdqcSBSZWxlYXNlIFNpZ25pbmcgS2V5IDxuby1zZW5kLWVtYWlsQGpxbGFuZy5n\naXRodWIuaW8+iQJRBBMBCAA7FiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLapUC\nGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQsNpg+0VLrxjPjRAAgvHv\nAR4FPiOOSIFOEIvrbq++5Q9IeCuS/gVBb54l28nqXYtXwYs9wZEenA2A3dg5Q7eK\n2x0pD6QACNeQSIoDk3Ve0qgi1mNKJd+bzgfY4028aLF4ayG5Bsmcf0mNkBl3visU\npNcc20icPdzfnSRa6Fqz4CQDs7LX1nhjtBnSa0oT4gy8l924/TsPDU7tr31+DlNx\nVeKS/6Guwz209bcDKhLrVv7p+XaCjHUAq0obUVPPrIr2zaI7b3M7zAypHGByLA/g\nVfTeZiiY5j/o7L731owfDv5lZKRpnjsd8KmMu4SNvKOxu8CU2OetFvjiP/PxT7gP\nSgZyEakrn9titv77xhbHumZ5xTTphLYPfPDmzS94pJxU7aXBUMUI2wgdWrA3HYNf\nrTq9q70Jr2UCKZeCsNiIhtL3i2jBJBDfilxk82NU+/yAUDfLf6qKsMk8eoXIlcEO\nBbSiyXpJSApfA4paKd3O6wSjJy+F+tChWf5hjVKu+jvUhWgQTnUGCcnx500CfE47\nbyaoN6287g+i4eeiSCPdpUR2H8kIT0wIOhKzylc92QfgIzGJ3lMzvkQszuSDEnt8\nhp/rJnBVLR34KHki82pFcn7cpyLux5t7Bcg7oatwC1sUn4eYSRJMLdJabI7HJ0Qn\ng9GbGqeoBEcnT/0K+CONrveDt0JbgAeQbNZOHOa5Ag0EaItqlQEQALruvRDFVmEz\njBmSOJbVqEQTeuQCB6f60zIkA8IcCt87+X45AqqWQUweHAkIxynZksp0uOySCrYb\n3GxI2CpjEqMN87hCI0VhUExD6ZJrtlV0+ZdpZHZUqKxBUjRj3R92IQgcUlhrTjsd\naI+loBxpWk2upUNQeVBhHvJexV/Ccvgl1e1hmzmmEBXJwXAk3Dy7YRceTk4c7dbi\nfIIqCvxCS/4QAyTKVJK1Ilz/DgqTFN9mSq9FT5qwtgYKz2U5/Lq8lEqNEAfvrra3\n94JOvfN9b5PQiKsDQyfUNgAnrKKLnaxB5QSBMHZrTomAntsiH+3tWytYav43OEn9\nTi7jkx7cKn61DxxINSb/5a127xF8zVYy9w8Mxpp+KxiR5QfAh1DkJI89gJE8C7G4\nvzIogrcksFjPRH+4Iz5FI8+CjTnqw3T+qjFGxDhSpb2RBTxZxGHRO8gW3y6s4CUb\n7Ir+7s5+lyjJpcQa6x22rFuf35lBuWMvifG63TmeCw42oL5XtU3oiqHjwIZkQgxY\nB58iN66eYIVlAOv7AVH5a5OHEUDbMem+M5jQJOqGBl/0cXkevtFENSX72eUideHO\nXX7+TBmXz8eqt7NkDz50fKArRL9eQIuobBglSLiE8Edmgh4hzzagPD0rbNEQHiPS\nTYnmUuGVJkHQrz1JRfCyB8KtVeHAygNvABEBAAGJAjYEGAEIACAWIQSTB5qVEe/A\nt9bNv7Ww2mD7RUuvGAUCaItqlQIbDAAKCRCw2mD7RUuvGEI6D/9S5o3qZ+hAJUWM\n8CymSYzv/ysAqnyBHZuYyDMV/xonpTdxX2NVm07dOc8dcWkF07WmML7sCUfHBNwS\nuXl3rBoextcX7gGRtURnsRNqaW7M0q6ZckQiyanVs4+uAAfOYSWJ7uZvRQbEY0oN\nJQJjrgRqcuNwQKkZGT0D7Bd5cnzCBuTYWRrO5oa4BQP5bKJO4BhFOmdVpMSQAiRx\n9U/7sb/C2DKkrWapxRBSAiJ3myfDs0WIvqw8zfqUoqfLKqzpg81ix302Q2UAzFAI\nNq0JrStKDxzyBKsOd0YCp1MfL3Vy9VXZc1drkr6y1Pa6ieqoxFiDlbzkjkct65fW\nHckG+/zms6qqIcEg1KkrYQlI20/S475iv4Q4uHCt8Jm3LkNIcSRyr2EvHBmjp39/\n+L2cEa87g1GNku9ItB1AeUBmyYGYbS+Xpz9+q2Jgaw8iFudWuC57XBK1xwxO2XWa\n3gDIQW+4Jwx4JwX+l0NLO9VxiNrORHWXwwF/DXjQ3mw0+rL9hxu7rozpvNZq2S+a\nr9t7tM3jVErxQ6jlWADj0nkn1mQnxvWyL+TId4Ivj+7ThtGpbZDznMyittx7WZlS\niARYZRdTNrMaxmklbxQ1jCHyU6cds6JE2Ktsvylf6GJd9PID+ANXhVhy84yxiQmj\nr+DHc9qnr7PlZcfurBj94kxeWHLxiA==\n=22V4\n-----END PGP PUBLIC KEY BLOCK-----\n"
  },
  {
    "path": "sig/jq-release-old.key",
    "content": "-----BEGIN PGP PUBLIC KEY BLOCK-----\nComment: jq Release Signing Key 0xAF19040C71523402\n\nmQINBFYayakBEADL6biudAZ3V1//e3gdWMN6lbz+m5o6avu1vnbtCul/MxOF2Ygd\nSeXCn5gV3+F+xdrA3/Mhv9cWXzzDTp0D2U75mHw1n4OcArFvKm/RV5yOlc/wvblp\nWfWd/hCIIZhdHpRWdCko2ByXx9XlBRn46nGyxCFScLcHbicPjq2kIpZ7oad29gs4\nbThj65G5XS48FyqixGHy0o2S0nQXNIyB1XTPm4mwHNAeOMFaYj6nhb6b5vu+RhlK\nsyirTGU7pZYd13FM5y9NZrbxfKnGz5bdKPgb4jRi3YmBTKRzlW4IZl3SGO3kPi9a\nwJR4vP+cf1eEAWulrt9i4DA3/3/lpPpFh5bSo7nKW49PdOjfLWzBLtCsVhJReF97\nsSPVpNmf6RrfBXnPlEBw+aU4wGRbmpA9AGV2rKsvxZbU2AqDS93Pn6S0u4XNNnjH\nTGxe2P9gSEH+xNuEyFcDbt0XP6Te3vSE7oMGIPhXq1FKuXygEQGV2fXa2Dovxi+q\nYTvbtzG5PV5lQqeexoNMUHzgHVWib/NIt7JTkBflJt33re7oayZd5DSE5zy/4n5d\nLH9prYJWqVGgb92Lzlk6uYDp3ztBlFdoRR+6L25iUCPRq5yS7J4Rk3ahask2CsQc\naANz5xkESnS5DcakDoVtbiC1UY8eM+vXui/UF2uYCTLrz+SIIZJHPQ0fdQARAQAB\ntC5qcSBSZWxlYXNlIFNpZ25pbmcgS2V5IDxqcUBzdGVkb2xhbi5naXRodWIuaW8+\niQI4BBMBAgAiBQJWGsmpAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRCv\nGQQMcVI0AoHwD/4s1L10OiimSELwTZ3x+btmKdaFBdlUhjBZd/GDE3P1pV+63D2+\nLhLpZLQ3yOrplUDHGBG02Hx7/lY2YE5rRVNMyR8FqD9aMrOwQE3uERjkwFQ7Q69r\nS6kFLiOxUWDXNQ0wXeZ/Na6uYi6AI/oCYWnDIO3lugDUoXtHanYqK1BvJsBEvWpe\nUB18VcqxBQuOMPD+xNzVDSFn1uYiKKBkv4XJNLHRqdLpwmAVcLDkKTHWEy+223CZ\n4zwahQKw9wPdUlakXP7v+wIxzGXaGk0yJOsYVPykQ4AkoMgvqqxyx23d6hjncR1o\n36muLAiL+qELZ/rxUytduaK1Owr8cNJgPzRAEbeSRdw2hZYyEnHgNPC3atUN0wIk\nkhzP/GHMBYIU90CdiWjGvjJeHv047Ty4S9PEYPZLQx1s8cdIeozEFt/lTqFp+9Si\nf2DWUKHpzQ3wfUudTD4pzSy28XJ760Kq54f1cf2CWqp577xrxRfcKKoyufF8pwqf\nsAno03N6MpxiK0qVwZ/0Qb2BfAI2rpxxc98qhuErlBE8WjPj7M93eaHNMTtCqCIG\nHke6kMjYuwGu8NK/O0SqGqsHoXxxIvlZNda9MCPJo9xl77dphurOq/D/d9rfy/Uk\n5D8ssNUBhM3s6sQl27L1avnSS12UuRdGSQwU33XbAuNG7y0a/zRnX+GqE4kCHAQQ\nAQIABgUCVhrKpwAKCRD5uhQ7lf9tgo26D/0WFFkhmUjSV9K/q8zSSJhuQfzoeM+n\nZ2DfYBfKdawbJH9/Yfg1nIFzih2lnvzk/kx8WbLSDMb0sHn6ZUZ6cVoBvrBxSgah\nbwPF9M8Xf4J/oBYHq8ZYjPHOWnHbEPuoNzPreqOhtSLBtP5dfZlEI6DLR2+WKj22\nEmHfmBFoKZ90N2MQWQLV98DAFfsxS7Bqc9xSCbh405qCIGr/4r4P0BaIdJ2jW/9k\nAHwnsmJnf5lI7dn8BEMYgM3vcG4dyaWNf+eoI3cJnq+Y782KoyFjof4t1bLF2H1C\nvbiJ9xWv4uCeTVlTwiVJFkSUxBgmsyVofcboHF7/06HtVXDpG/ihZEOoqNPKPD4d\n56V2t0hEulUpyqfs0Ic8r+sGWgvDCSqAVrXak2n0ULJ+RkpRB6ekcgOY7HdYKX1H\nUifaytQSxjUBXfo9HAC0Br2fyGh9s5zBcnrIrWHxwQw/RCIIv9CkZB7s6/NFYBKw\nQ27xTpXjHnGoEHNAA2xSyMXw9VoH3qoze/1iraK0zSFGAXpmL57HMBnOrLj7oq+O\ntB/cLd9o4+XFJjXHGAsXoOD5cCADkgMSMcouvPFKySfK0Kz5ScWVSsc5FvG44j/L\nT1WvjBgIrNAeQJ2efPYVmg5f/ALkjgnKy+lkafBk4OwXtWZCTf+9vcOF7FQ2B6N+\n7qQPymxSJxBSEg==\n=AiyG\n-----END PGP PUBLIC KEY BLOCK-----\n"
  },
  {
    "path": "sig/v1.3/jq-linux-x86.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzhJAAoJEK8ZBAxxUjQC8xMQAMgSl+2aYa/c/LuYKDWtVnHO\nG16rAq+oruc/IrEwEKqcwqTvK8M7xlAxUt5aPtAY0kRkvxadFtX8vZy1SEqAFcC5\nsw7J+Oswl+5dJF0Y3j3I0hA6JuOe/+RP4r64pGlwQ0mVIJuTWqinzO9JqTOskeXy\n5vSN50A0vFXzDu661UFr1v8q5+b8WhIrJhuOZtaPap33Gu9bS6fz93VBm4LE3a04\nKjDydbNUoyA5HX4QVTgFON8oeVJevtqV3krnsU/ncOeTB0ThT9yywcq8HCbh7dqo\nEhfyATOmk3RZf3RsSAOG5CZ9cFjof6/SqVG8Cbp14MRVMkKi37mvHkqFER/WRtsv\nUl1OzFfv8Jwv+cItTSB5c80kbbRfrqwf6NgZW9oTxZP3G3I5JjCTYhCaWlzO0wZ1\nQAAJDBAv5GNB4rn9LXGdj2DhcCh00lJY83Bpup4LRc2RuJuJH7IUIkfRW4CAVoRd\np6w5W4jYNdrrTkhfkNxSqi7FtKN23+eD2r0knPvhsWxyUcXrGhFqaImHmzQWIsX5\nAviEK+nQUcuhTKolsN/97NPkRYUT9C4IVNdI8m1+EsAuwGodSvRrUwBIOoVQlYA7\nMFLZZ23Su/8T5NnruP+iXmy0Y3Nf9W+GLHNn3H+9027zAs5Esd2Hy4R6W65BwWuI\nyYHFx8O6bi5ke72ByCUI\n=ru7X\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.3/jq-linux-x86_64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzhxAAoJEK8ZBAxxUjQCb2EP/08Lgfoc0rDv5IirCjXIFWxM\n8C56aVfaF/8gaG75SuN3QUVBuWx3VB60Cgh/msTFrZ/jkWr+tYArNzwNAjI8a9T8\nnE40SJH3kvwVrr9ALSgk9fEvikfZVKwYTc0k4h1hBataE5Z+7Di7VYPUmdLTd/ih\ndcJfDe6zPcYmaW6fl0glP2GLaDuLI3vxAid0MzDS1RU52z+usc/fjXWmaJwPVp76\nSd8/Uz3X6ZiFwpkfhp6XTcqkQhMZd4GS9cjnPAdRp9HFLI7S2UJ4RNj/YQIHrhQL\n5Ko3KdXEWeSvD8wcr8VcZ66NfmyCls0diEU+TUv1I7VmLzVQGx9/4/uVWpfxry9D\n8MLEHEJTTDT5W3hX47g29JRFJzv8PUyugkpXjQrpSoFbe/3vRxZeQNO9rjTx9t3x\nhdkWIjbwTg8SGH0XK+UNfR50A3VlrlPDpW5Ju2Io7/OuKRWN4i6ktFx0akFMmHUV\nD5u/FhEux7kJCNHnF7a7YJ1Ys4OSPUzoH3z35zhyVcW+iiX7KIKHNamWaPBw3iYa\nMwYVKHT6NUQiVQbTZvWJZXGArEnwq/z6jAjRQNKoTjbcVoYJunY/DZcJjnRIux9T\nyYnTa7IbpWZmWZWQfnb8zuSoXnhaSHZItIeUklH4K03xjpEXW7pGPLPznyDoBQeC\n1WVcwpviS/Y24eSmmxaA\n=MlHu\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.3/jq-osx-x86.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzh+AAoJEK8ZBAxxUjQCyb4QALrsqZ/QkI2a/uVPnwAh22B4\nmtbplxOS8swCB4g56tG+JMuria9l1ACmpbc9eTJ/Q9z9LLwq3vBkpy0utAQp/iAQ\nijZbTG7E3S/LtOzZ5MSbkGeyuDWu4YCI7DuxTZH+R43fiA/ShHUHf7rO/vofAjTu\nMZr7TpBRjut5htbkNrUKoYjK97hehvY0S3h1oqMSSuHS4Em9xMvv5bAsEn37+L3g\no5Y5kHQ55Lu3qH1Uk87VMz+gtO4pxN+ZrNNrY2lX/hwnV7p5YDza2H0uOopBrTi4\nX99x9JzdHoSrySRwS1ZDc+XYDgXP7JO9qDmNh18nXJlyCWFzDHajQS+4Hn0O5zM0\nPHWasVC8tmxT0XXZlG1kPuaCkg0BFh1NXNjCUa7Ru9XHfOkaW4TyKGQa3eboyx56\nq7MDvODUd3JSW4xmLJ7NFSYRCPMRiCMorQ8u8afy2OWt2W13M8OIH378dMcFoubW\nGB00i127dhuI95lwNsTV1seKO59bMbAJjP7ITqqDiOafg6AmTric6BJNakSsrc66\nyCzhOfxqwfeRekPSirrf8nv9D7dW45yLEiXn9Irn+KghdL4KCLCB8dyc6OalITVF\nc01SK5xNzPRfFVzTqMdmi/dYpDL0KSMwg3O3DhPQ0LrRZDXKXj6A4KGAthpVLmRr\nIHj2hlGlr4hqLXUU1wE5\n=I3PU\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.3/jq-osx-x86_64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGziCAAoJEK8ZBAxxUjQCkGcQAMpxoK6aHzDIeVjp5kQ4MOFu\ndOE0xjXlPpudUfUORKqfsnPvvxJTvqlDrUhMq6d6S1Eic9ZAbfpmHGbw02tvQ7+4\nhvyy/KbfBUcLZRIwZ1eej/rFUXd2fmxPwoj07SpTOgjKF+8duUzSlxBg+Kes77pj\nZuMO3KUa3isaOp+kufh0+miAqHisEWzQWCfHBrVIwW63L2bf2ZSUvp4JqwfRKfr2\n3hBfoll0M+iaLHr4/wGUIxRL+23afTtvQikyOXzB3rKXf+QmDePZ29isZVg94yi4\n/XiDVmDM/6GpfI7u0fIoDcEgH+LE35HL/CT4zA8IzA/QwB5bCO1bPEA7DfDQq01R\noghTvH5Qu0eu8tjap7EXAmch25nPys4NzPoIRnbu4i4wQUsFqGzmSFKEuU6pwDIm\nlsEBPbHRcGcaui2KidUNi7iQmje819KgRDhRxX65Bye9sKsD/HvMzQRce1RFYQg3\nuqISuhWu8qj67J/ii2zFF+lo5HgHLqzXKcye1kY5KYq2dTIa3khq89Xkf3trsnNL\nIKZ+8P2eiVDjDr3UPIvVCX1JvNTdcQDMUlmoKk8g1qwuTp2PTi+c6FKicZGUMMnv\no/hThK2JwnL/Iv0bJHvBU6aCXSnKLTLIdT02UvUppiN/GTMHsagvE0DRA1B1yFim\n/o/n4edysfzI1Pxe0b3c\n=ZOqW\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.3/jq-win32.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGziHAAoJEK8ZBAxxUjQCG6cP/RNQd9g+Te+fgpFvnFDhAVyW\nEKZ+2B+V64m4GzrRFnGwBMqju4kFf0dZ4craagJ2gLVQ74FhvorMtphjX0MYgxtt\nwXyIqImlBake3GEkjUI6XW8QmlFmPix7+2fG4oEdLHwgE2/ii1DFlhTQgYYwH+Be\nz6wo6Nfl9OxykEHG1hl0A4AiHT1ubWogbjD87yZRO2M1rp2nHJu1TujqkjwWLXtr\n0xVBSgtutfYRBvpPGhtLb4nqzkeW+lFW99A2aUo1KroyBdcrEKTJ4XMRqjYJLkSN\n68e4gZqHmR6M1nA4h81bU26lhrN3LbYiOwBu67N5PnSOQE87zFPK6Dac4QyG7vzt\npR2xht0QwwraxOeIrMrKs9vhUOKm9RDpNcD3z1xa+k6Qej+nP8A2zmMvUz3+C8F9\nITESyjk/28Eku5jEUs5Niz/znGvuU3A2fk/qHs7U0I8tvNWsxj29GCTzgPDoH3Vs\nsJKuSozoSqecBf+2x23PnGjGttL6BK6lo762qeVw6npCi/nqGFbMWpuopgJ2PiNP\nt2RdNzvX7v1V7ZfBOGl5iAeG/XJ18uD+hplCiUePN7Jv/3bpaJ9jlo//kIwddUP2\np89zfLPjeptAIxvkWph4ZL59pj7zsid7rSMd0WIOOqE61PKpl5jBgrdiBgKbcmJe\nAIRZewlOq/0l0cVtK10b\n=3nBK\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.3/jq-win64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGziKAAoJEK8ZBAxxUjQCP14P/jkKiLUgiZkXYVQs+hBJqJD2\nrOsHVGmoxpjnQ8L9gUSxfZ0E80+1iTx/9JNWHs0xEKrvWKmCovfuQd8xfxZ30g5z\nwMa/7QWZtLdfIGkQje79WgA/+xDWSLa0T+dbcMjCwDdYPQyQE5Vf0I7qoNOj2Dcr\nCmkSMO6dtoilv/o2WX1x8Z1K5sqGMl64WyM5yR8sEMRBVuVqWRvELrv9+YMW2UYU\nyXj7tFwulyqZEoUBLlUxZhr7gjah31gBP2qqLeZhq/phdUsi9ckPusW3Un5SMaRf\nxEPo+y83Qrpusm9UDGsm3t90TWva3oMiExjFatFKuKvLbFCZRK0EIqdUOUMlptV6\nkS3xKsvAq+vM53FfwcWx/9gcZQv5XTw7McmWZ9vZmHH24AUjuFFFZLoWxPg73Vek\nHaD5xTsxfYEqGRaJbYoSkSs39fw+tH0ajRoMVcZw2O2c94qAgzR/Qne9t2nQ0ypg\nhOzsIIdIxj9XZShkkVmlK8naf0YH0Wc3Yo3wBxkTy7QKVWtcF+x67wth2XjKHBbh\nlh9Gc3R/CUvRhk9gOSqHYAsy7lEIpFGjuIqYTZcXRO3BCJgjc3hV9jBiIy1iQWGg\nKuh+egThw8U9z3PueP++yVjImze9Y/+78dc/rHAwXkFIysBs6vle/9ILDl5Komvv\n91rFNBLkjvmJoRw4hUpG\n=WNFH\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.3/sha256sum.txt",
    "content": "cf4b0b3e505958843375ac153d84ad6ee40196aa76ee373b0409f858b3cbf925  jq-linux-x86\ndbacac81ebc00a7387e4c5e539a7a475981a1ac6ada20a2f6b1d8f950027751e  jq-linux-x86_64\n4095a48b50b754c8b3199b9c069fa9c3da0e737d8809af3205d1bf69f87cab6e  jq-osx-x86\nbce52800c943ff10d1ffd9c1a7e7aeddbc7bcecd7a2b05c6afb828399dbfa39f  jq-osx-x86_64\nc8e2ffb5b0536a50430ef9b4708a40686e4352db5c01ae90a98ba96660e5bc36  jq-win32.exe\nd041fdfd8b3aa3832eedf2aafad5002f2b47fb59373b71190a01422de825911f  jq-win64.exe\n"
  },
  {
    "path": "sig/v1.4/jq-linux-x86.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzjvAAoJEK8ZBAxxUjQC5KsQAMt1IwBrIn8dvTe44djO3QYk\nH/qaNSRgChJI81GA+B4suTcgh+PUJcHF1EWls7CCfjfp1haocikXpNSuY7mF+43M\nSMdz2ZA4+N542ratUTv7YlG/igIvz6IbDysjowU3QQsCcjthmO6OF/6fd2qRhggB\n3K80AMESOBBi7TkFTLw1G4M8uU6VvN+LWrG6fOcPXoRLlqShGzskDqxpobL1+o6J\nCf56Z+ZVLQ6DPjW2pxK2R88788DjoJ4j53wsBqzgnHMeGzWVzvQ836rYSD4dhpSn\nYopiAesAYLu0hJszHbJrigt/jUGsNekQ+/ihqGXhbtDVjpYLU7At42b2w2AgjNSK\nGFBJmICTQZapz4o/lCCli82PngGmIVqgf6fc7qZq+HHtrcBeNYjMHMPMJroGqanJ\nDhCnLmE1906RpJ3VvCM5Sd9lSQQpSVzmFAh5MMnprxvsAmDbL+Ty//a/cOU4WPAJ\nMgXH2REmeByg8EX6SPhtshxxdIQf0CX4uh2r1aHQFtg/sNPL/EWGcRq+DVbaz/8R\nTJCfu9Ov0GhJlZSMHbkN9cvrjeE5CNM+7Q66JbhOMp7uOo4I9+JyknNJP7L0Nvot\nIcC6qsw8jMINHexW3RSDbX6b2S+0BskojAxp6IYHv0y82aaJ5I3+4UD3A5+Q34iM\ng1kqYu4WnPOZ+cihvGKO\n=8ZEt\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.4/jq-linux-x86_64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzjzAAoJEK8ZBAxxUjQCTVwQAKoTbAddyfciZzgaxSWqc0Yz\nf9njjvPHRtUfa0X5lDQghlpTrDY2CxqU71KknLgxW4VpnErf13KlVoMBvGJwCmU5\nJcO2aE3iQDxpf6GnYa57caSsj2pR5Fi+/5nvxr2ovoCzGea3k61j7G+GV+znccAr\nK3c+03aq7p1LGfsqQSGPGH/nLnrqtcFonNVPxsaBuFpGMpaP4DuI+zhd5bGGo4g4\nk23mWbOee/SEdYgiMNtVnkoQMZmSdae9O8VuTMoTSv8R2aLmDTrrLa/3z8m7rQAe\nrGQkaHhRg/fH6gLgBGJe7enqDgbNCmKp+zxfI6p5RbFvs5oH+M/wV1edG2KFUpI+\nfv79Aj5XTVinNSCewrJLVHkzd328KhAeXzm319wJ0Q2sRbvO/3rhqslkRPCW9Uan\nuxo5dLMYqfzksy2Cwhv+c9r7Xfi7tjKidPLbwdz620eERquXSx7+kZLQyOw/mx6O\nufnZKMDfhxZXt/KkNzraqkYKvZ6eO7r270ao7tdSZLDC+zELMGzIXINkOPXQDA0x\nm3Zz97jmfMQ6JwWU/1jCIOs+CpMueBYw3VyyqKNAUvYIjkw9A6SZFYhwcTc9k0Xh\n0XSGZNjiKxTe1UJdBXG/nwNb6p5rMWwyesbiqvWiCIQ6aBX6SluODZsd4479bcVb\n1fYsg+Lu9V7FiGY7ZlCz\n=oGfI\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.4/jq-osx-x86.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzjzAAoJEK8ZBAxxUjQCmKQQAIei/vszKSXY7gyirM1FmUEO\njPEzjHPJvYOEIw06/I9Jkn8ufsTQYtP+S19C8kGLRcZIonlXZxqQmbYQUv02NqEn\nUDRlCxiQZiGLO6i54vBWi5VhB4VNWgEbrctQ6oR+mV6MXs7RZo+2SGEJT+r4z8om\nHpFGQkfdfwNRbAXkIDHCx259pzL1gy/YrWV/8F0VdAH70dmqidWCQ4Lt+oymUhno\n0f9gBOwIFZJXJRhhGz8unHk9XHdDlrpdvEb5XpuU1Alvt3BKa8vJslbTY48a+nI8\n3XsfQhAXItAhUIWHTq1dnqmJzDvFzkZVEQQ2Zt+e7HsA9TG4StLCaYCIorUp7fbo\nBbxS6I9TUCbp5YBa2EHiq65/jNBlRz8+GB1cjZ3oCTpQQUTd2pFR/fdXXKxvKerr\n5Gxc2CZqaOGW30iLwvtowNt5y34nf33WCTtBAPpY44aD3TkFkHcQq0hnZQI9gpV3\neB5uUoLrr3znLVIs3IX4B2/L0cKP+Dbal7iDQ5nsmEHGBy5P3yOgLbHUg80pG+lX\nb2wQMTCyTrl/lahJY/0n2r31yBgmHHMBNmY0dWLsXwzemh4TlVQ6IiFl1rF1PPQC\nF7bhTHQh1/DrhW94C/uFU83O0LveTb/U0FobAMCMgrd9Ew3C+gwXOKP96DHx6mmY\nldHhiLTbmjLbfiDMaWw4\n=dzyb\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.4/jq-osx-x86_64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzj0AAoJEK8ZBAxxUjQCeTYP/jt8hRyHNKtFfahjW50EcAab\nnSqUr5VXz80BL6vSrvixMoffv1RDFuzEZgFlYZGXErXjK7Rpo3NAE+e7EUH5vbgk\nkJaZjzGfw8Kx0ZCZFlmDmI5U93xYiSeIPPP8jaUEg/Al01CH/Y584bgNjyxi3zC5\nRKO+/HTYd7KR5jAWNzKqV3tGvXJdi+a7Msw65OiJLRoVFX4ps/CGaI8Dh+vbbPi4\nzPjG2DChoMdaRNxjQNcj/FW7M53rXIUHbXAmR1jDOSsTk16V3kX0eX9RSBsgTkjn\nb6/BrXnTMmTJR1osHIznuzuQ0sB84+k5CF1ZBwqYjmIr697qEl7r+bWODCN7NcJ+\nLo8re6lTAJZBqy7IKgPb6lwFg2tqd2P7UCv0Qx6dLUQGzqeUBDv5GDR5DjTQ1LqV\nCpyZbOFkA4UaKbmTp+DOGE5TV2D/hzUAcX/HzEo3RVAKSJIutlcxHpMyIazZbRQr\nRWNU4GiNr0Sbpl00oa6GU7OO/d+j+BFcEKrJ8Ud6zv0M4OCFkP0FW5CKxbl0aql2\ny8cxcrdMmUhMwn/Jv7pX/N4Hqa4Jjzyy719LKRXp9yjtXV/AnEY2aQQqR+I1Q3VN\nDBvw7qLJe2hzQhacwOGDNHc7L5JgOC49wDw7L7MNlBGHPdEGKDMdEc/k+Nn/VnOU\nl2JS9gVb1lP3p1TPKSIG\n=PKfI\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.4/jq-solaris11-32.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzj1AAoJEK8ZBAxxUjQC7PUP/3J4uNx0zpw4SlnB+yBzrKqn\nZk2JahOg8wWRFbMACjMAjTMGmi9vYlLQRjesdi9WdvvlD1iW12Pi9ogA8OzFRkH+\nA6It1g74k63WVtyfNHfLTeh2euQsLUc1UJZ+36FPs7lxZPsJmAL4kB1M6aHy3w/K\naZT+h4iZhFeC3/JFvLhd2j6/RDf+FkAiEbRlSXoNmeBTLnNo82liEinZFUvEsglO\nEIVyPBGp3mtlBE8sf6WGd57IpxV4bl1mXZAap1xPVpK8hrjwXS5t2midd11ENBmK\nUeKcvZpmFb6qLTiep9kaUljB6nOzTYyhg6S9gaJAUDl6Wam7gtBFTIMmndoGiwQO\nNV+Lsj3dVFz+7kO+sZx/acC0PXfnMO2o6zBTva1RpDoHJFLmKTnPDbUFl0rZtMB9\nR+HBlqRR35PWKWC3ggYPzfU5bZOVp8G97WFJlKkf5hMWzKiNoiR4hAM6IZYn1rGB\nS31YKV1yvLIcI4mbhogBlfvXEcgqkQt4cZip16qqpy+X5n1zEA/w6cXcpushbhpf\n8G6b27PysLT/u5wViSPklpN7x/SbS4rVGzLGPvN7hYR3FgaPqADDrkZYZEIpl6Zd\n+Gj1M4YjcSDwInnBeaSA+n41Cg9hbudM5R2cdyZzcViLgebnjyt80H+03TDRi/aT\ndGs6zbsjUQWFGqP+FpgT\n=bERX\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.4/jq-solaris11-64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzj1AAoJEK8ZBAxxUjQCZ9UQAIlJSA4wU8lFakjVI1QfJ8AA\nv0FUY8KPmk2RgSHzeCRZaWuA0FJAOVNmJtW7kKT1Zg4iJ2f8enX+6QTRbWO5pges\n6Ib8CltoSa1yS/RZOecyn4LtmJEkh22mhuOJdPzf7+6UmSGaMhE8yep5wg63i+GA\no9vaQvllmiReR7qOjvI9cFYTdy/4iX+Nf4TBQPSJPBcXtwtH+iq72IzizgPo7fFd\nYoLz3V55DlAWBJsyMhVF4rgWcBcCOcMOwaZ/AsKVcKE7+NiPfFsZw0qqtBKAkYBP\nmKDheZmbX43rDp9Un17w3JbZZ6Uj7nglPpE8SVk9tlJJhznCmFg1ls8vdzkwjkht\nCr8IlnFT8ZS3i7w9CLO8nCLuMYY2UECre/wELY915fwRGY+fP3EinO65/xBWxUdl\nzsq3DchIxKDorD3OiAduZIqC1ZW3XSSsiXzs2+PJwzW5ryvLxGSptVTTr35qVDdo\n0igUW41pdwV1Mnltncah1+NOAWcSQzXx2E4dtPmGjEcTXSsGvt1vqTZtfFL60GKs\nnwONhA+mK/eMOjZ+rtJhHecpqB2moTixToq2RkOWmIhToq9jLWpOnswrUklIj5pC\nyxkdCU/OZDTYYU+AMXlGSQoiXems5typ+/oJsKVGPGHt6XkC+WTIX6Si1N4q7CFN\n8qiYRPH8G2A1QOv5uj6L\n=+6XW\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.4/jq-win32.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzj2AAoJEK8ZBAxxUjQCJygQAJfXI0fZjCgdicjtwN2RbKP4\nnLpao2BLcEkHQFmbCZXKQzy/oAGBR5xupoDbIFShum7ZEYe88Bn5W1LrKa8ELJ1C\n5EQGzEsxRe5jT6YsdAJfjjEIZiDL0U6HtSq2U08iNOIIuSC6sI0FElotMUOKYqKf\noExRULIkDVfYKBQEmbbUEi/gJ0d6kD8AT0ts7VQU0Ad3jCZnDnFGLZvk4XCiL9wY\nOIjqmA/okDHuuD4+lgexiABxgYYtJFDIIunk02LPJ6R/S5Qn7mou+HgqBJo2g16P\nCFwTf+f/MxBNjQOhGJtS297tAJWjjRlkZyUOraYFa0eos8Drc9PpwjJyjgyuMiPt\nlvFa/Lx9kwnotP8cuzZV1GY7SV60NcItIKyeoTK1QNv/Qw6DeXJ8txSGOqo8x+bV\nLJxLRXNHseY6+C0/1WJCIz0PF4wt7tAXmqpA9wRBJWKRaLaLnshhDMDRR18d0Ejw\n/4oggqNc2S1J+lF5ziUyGYyL8HjtX4ngghMhvvWlmH+UDGQlwUA/R8G/u/ESHUXU\nbebc9bHbo9b5TAolkCbmb8/tT+ZFTZ7oAexYgOjsv9auB82ggMTlKnN0SJag7wUy\nowPgSReGONDlFJ3JKWL4HLvJT/UFvqV0dnbHMmlKlebvre9v3B1sV9hl1R5Sl5du\nT0dL3Ha3NTeppVXq+HRr\n=wUMJ\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.4/jq-win64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzj2AAoJEK8ZBAxxUjQCao4QALTCDd7W7SZ8tyVNSmOsILmi\n7OcRdEdw3WNEpIXhYIo/NX1Sddtq1KgzHAgRb1tR3imB4UwVQfxD2olgIgoJTaMj\nP5jnRBIK98ht4iPXFkFmz3zOCBHSH/pXTy0jMjG0uC9czT2OWMlazA+brqaMI6oD\nJtgJEPIK1HfRdv0EfYCToj5LLi6iz4PVukk7i+8dqW/xFt1Lqny2ehggBFaIpG5D\nFAuuDbvnmzHODy7xpzPnRgBttpo6bIsQriVHrw81IWyhQJOKefjdiETB6N84+Lox\nylgvk4Y5JiIrFVSoQGxbo3FlFth0CZlLSE8GuNSekAqYd+TjPIgtBmaHPuQc00sy\nCSw+NuaOkhq3y+rSkJgr5b04KDfvDhce2vF9maXtVPVEQ/r62WXNuCUoBVyift1J\nViA+Ko9RISDlypHQBUj9KaWAUxTe14pKkaVggkrbM5c1+fvmjxr+FAZVSrnz8EOF\nK0J2834mNKNZWTo36NZ033BzoWE40HtSG+iDo6vGXNbAp8pFdRrjSaBO+Lklw6o4\nuMixmPDABielcUIaZiu23vW2qzOhuEIav5d7lu72XI+8ZdHrUymwra3EAs9Mmg7i\n0NPAwMHOPjdliswo8rp2hY7Shd7oMyNqxWj8BaPLCsxl82ofoPAtTcI4HCW2JXt4\nu2hOqXKZ5LihwcfgQHpO\n=By7M\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.4/sha256sum.txt",
    "content": "998c41babeb57b4304e65b4eb73094279b3ab1e63801b6b4bddd487ce009b39d  jq-1.4.tar.gz\n1dee4bd2516f699723f373b2629c9173ce123b92c3a72520d0e25fcd8e3df45c  jq-linux-x86\nb9b63aa4b3cc85df8bdca884effb69d66e9ebd717454a9e212d9423ffe3e955f  jq-linux-x86_64\n6ab184edfa04d6f662a696d8594f19532ed78bc6fd05acf4cf506e789914300f  jq-osx-x86\n335a99a68eb9a1ecacfc947550003f103cfed627d3116c8bcae9ac11dd26d337  jq-osx-x86_64\n2c1382b65a91fa27f2b9373331684de1e4ca577abeb724c3c79f4733af89b854  jq-solaris11-32\nda5e4ab2879022f365b77b9babbcfbc01f30a98b884a31120031e218d676ac71  jq-solaris11-64\ne08ca23dc637e8c0fe1577f592a9367e036f5b3f4c10b189c53943b0c8868866  jq-win32.exe\n1c96fd65fd60763b92a28c7ee1290eeb974bc69b71b963d0e45cbfca1625565e  jq-win64.exe\n"
  },
  {
    "path": "sig/v1.5/jq-linux32-no-oniguruma.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzltAAoJEK8ZBAxxUjQCbHIQAMU3mjBvi24X5CfTkyOmDOb9\nsxxsuTOiH8Zjiy+5NP7a1YLDD/yznLmuu4fm+XzCE8DYdzkq57jSyjr8rqN5poTM\nbk3+9P/Jf0Kae+tpTP8mjvtJ6bVPweV/Zg+m8YwE6/iUHQHi00AyQ6/obfXx7otn\nX9k2IIJATAvR7WJ+5+Uc390MkVNNvuINfuuLWdSPdIbwFf9lvZ2ZmwanrWo6Gzdr\n/TW3MCwZjWjENGQBYNTJwswTdWww5Mo7MrEK/eHEy4DlozJyyzwe5xsWRz+ERKSJ\nCXe3+DTSVoc4DVuFEhU3T+7jU+Fev0FOqLlu0jD64Ma7epk8/gP/gzzV8JmkX1tV\nxwqZAdlPl+wNs1ZQw+9dsTZiRIT/qQBxa4y7bunnjkxaSa2ovTz6EUaioeUk62z2\ne6zXNh92ZfjNKJT8An0Diq8i1P5EDH3dBHX3+2b9Qc15SFXE8vdXLqjIvTzwZ7hw\nfkxF37eMPfc527YKvktVUuXKkx458ossrHaYdcFnVh+etl6T/hQASE8Kp5rgVd/g\n5/P6/JrkrY3JTHM8qVC74YLqQh/w3xaiBzcz+za255EcKwU3qb8G0iPJ6i30yvCC\nl/Hj2IREDHyogPefgq8PYah5RvVXbiWJ/UKz+qm/vinm1DUU23F18Ezakxd0Q726\nOk76sclCtAR8SCEu/3eU\n=fBEA\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5/jq-linux32.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWKaLsAAoJEK8ZBAxxUjQCv7UQAIEPihgkz3swMhxQVsRSd/dy\nd8sQMup6KFP3jAOABLSYyi6MrmCZhejodNd276ydxSgB/6rPClPZC6kSQsrv8fyj\n2CSaQOv1cItzPSObL39xNHAoj8LOkSbb+4jultfbntWU8iuAaBzrKc6jH9VR6zgJ\nYfeQun2LI8AqqBK0nClSwXLXFcjxmzR7KDwX5EPeBQdM1uG0iHO+CsZWKjC+pHPy\nWkNqOubVpo1zFFx6pTFmDNraPOxdLvMVMZ7fuHBbdv95NEi31CE4cmQzIhLd6BbX\n0xrOfT5xsib/uqlyhtUMjcqdrVcex8hptdsxrh5w9cZyhAinmpIEt59yS7Sbcg1m\nCs6EdXJjjRGk5KVlyjuZJYOZxtCmdOYrLZVp7Nv2swIrUebkqWnXUAQk7Jdu8XmV\n2UzkhFvlWaTVb4dJ5s1zb6C9Yv9hqACsjXzM3vstcu2tiGmaH/TGCggqmubn72Ag\nOk+YdhveZxnL8iF2odz7IdpC+kC/vVfCY9ndHv3Sf3i6uLuohuT2x45R3iz8GIMI\nZuexdQGz/69blhw+ZsqVpxodgZIqnCOwIk2nTkrLOw2cJbtlDWh1s/9udW+nMmPJ\nZ2lzSP5A9jJzMCnkb5104LdpyqbGcUO016Tn1OKyLQNssViKlV/kcP/jZ4T0vuPI\nNIP2sEDPJQFBmsBmFR4B\n=f2Mr\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5/jq-linux64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzlxAAoJEK8ZBAxxUjQCFqIQAL2JdiZNp9GZm+SK115N5Twz\nmjI66fKWg+1ckSfiCdYwSzg0u7AFSECy+S8vq9WzSKsvIptGPJokIehnIrwpuw+l\ns7sfDA585XkRxpVoEwAdPalTRqXvmku8Sc4P1519K2DZDvtvWPY3N+tWIRE9jfcW\n04KDTuWB35N8e+Mgg8z9P0NJiDanP6SUHp4r8Pc7KFQ/gOK4HKq9dFa3nsmkAq25\nXJTFYPS6VU5tj/ZyTPNtMh1Nb0vp7+qeXGV+pBMwohmNoBFUyx65olwegD+dSswb\nCfh59P+aWec7V6exJq7EW7ptIaZzp1LeoPfcABDjSOTEeez6ywIcsPnmfIjAh98e\nWovH2iiWH9XvLT6EC7gUcdlMJtvz46OkXilQAo0rK3X3pFX0T2aSqp/afdPtIvpK\nbErpQKt65XNsRprBkBlM1Jo6K7Cwh/SYKlbSJuvYvieORQ9w+0oqmYRCk7MZ7OOG\nNxz3yEvEnzQPaXnSnJ/cK0xb9Yjj72LRV3Ors+ni9HfLm14xN7zBx+g6rudf9hy1\nUFcvrxJSRFP5bZZxorWc6busisRi5E9sRQm/kGlTUUbrJrV1iae7h7s7+OqnY3aG\nH2lF4Gfb1eVsltQZ3DCRNiBiTD+3cmzEayD0ktHRnubOQCc331RoEwSNBsV02rkH\n2ZijCFT/AmHOl/fqmX86\n=b++s\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5/jq-osx-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzlyAAoJEK8ZBAxxUjQCiLMQAKBpyaj6un1mLebzt4JDQmEf\nqzzYK/q5RLS0vGzcYAl/ylBPdbBv6j7oT2JfPA9YfZaUPOd5O6eqk6R8OVrEipNe\nkvfIMnzk5joo+LDomdZvOhv6A0f/Q6eKnlr8k36INQxtbQA/xzUAuQthoo5Xn5ze\nd7lEHcWCpyaRne3dC5W642qG6X1hUN27lfx4MRHfSvFsSS4YIyPQHPiKPkQ9BzyZ\np2XmWLwNSQRaVQU/fG8LbcRFeu7CBIFlQ0IvRfARNvJGFO+Eu6JDNZg+w8b1GL4O\nTd3rEb5tiJ1LEZxe2HDUV/b7/k2BywrRGnMbLFbohtyr2BmFCAzqy6UySNA/DU3H\n5owLGNw0F3tWHg9yqGkTMcMTp0nfIbNKbjQcfSWKO+9gkoNyn+o78ggerRJAAt0U\n0vcoLbfTMBTRfxNHaRB0dd3YxbkHvr3tAY9A1sqkBGB0SJoZ6WkLsso2tBsivq/X\nK9x4pXY15LSKu8opFJ1PY82Ng2FdRlkYs1CDNB5IM52mp5IAgmxGzHCy4S/XRBCq\ni0RSwg5xwCRllqmfRkgHQDFT8lKOLwMnLrzqQVsBneddvT//A13pHAI+vsloHbiB\nPwNgEdbvFVrxMaY8ampzQZ7vw15qOGcmGTJolIEhPdxvP9J9zTcf5nzF4WSJPdMC\nIF2dukcTW+c/C37F5nQu\n=+j1U\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5/jq-win32.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzlyAAoJEK8ZBAxxUjQCopgQAIII75ovkAQmCS2aU5Ph2Yfk\nxLj40CVL7KThOWcfqKYy2Sv4+QV2dIjx14Uni/4w/dVGG0shtw1teUlfotBczR88\niyWvSVavbJLlyHESN7z4M4uApHikncNDlFJm/CuQWSVkGhtWvZZzJdoS/prypfai\n1+sjtiDidNTZEJj5nfkvZ90UKpzNPJD8RGpsN5qvGyVnIYmXWZ1xe4pwKiNaUthJ\n0wUBUcisTruZWCdSkV5cQMvb23sH8Qt+OZYgxJvx0Eq3+fG7Bh1J4YJLluMB1cSQ\nlqpOn7yJ4VptkgYeXoPMhbvN3I1/t+w43fL2P4jo5YTYuyVjxkS+VhEIGOgl7khN\nP0zzc1fdUw857dTP1/gXHTgMq3mWVAoQZnqcZEl1wnM155i+PYuN2kG0N2q4nt3p\noQd58tZD/KmCV+QTegtt/gpavztxqWr6aagI+UynBfVKaOxY6AB+0+1oaQTX6iYK\niqCqbhDi6ak8e7sXflAKrMhlnA4X+XCINdSwnYR96t/JY9tMFDiDapvbfgzdCi/D\n+0v7S8G0cu4pEjQw8rcotoPU2qF9cjMpmi2RsFDHpGsLv5r7avz5jDFxu9yEVMMd\nsp85aDh09bZfBACY4+t9m1AHCZO5LbkLremHv+nHA8ds/wiMmcCmRIgJQKvOA5l+\nC/380YfJeepNvCnoIpr1\n=NVrs\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5/jq-win64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIbBAABAgAGBQJWGzlzAAoJEK8ZBAxxUjQCW1AP9j8jyZcTFFzBAqLbxrn5Ljbj\n6VXIDrutvXqcL1/KiPt2zT0deAqh08yCZh0RIQuq/o86nOXKumcK1E1jIcZPQ0p0\ng3Pik4yvnJo7HCrJzzOXatfb9PokTEmM1Vo7qrJvQ1DPC8PyCS+fd2BLV4km2Uvp\nIMF3Wsa1nfRlcb/6Xmq/QJDhOG8MoIJ6Ldo+nFlCDqvKzGpQmmGo1gj3x32LkTUE\naA8wtZ4RsCSEY959w5NVxhcX6H0iv0yzGtpOPRwaOOmymxuA0w7035P9TDrGExhU\nt3tMiTBWLucJgHPYH8XunBKjVzFDj8TT7gOq18MzuCJxUhPaJZZWAndFxQ8rxgNA\nZUzmOpaX95DuRF9a5SMP8OpAOCOsM0lySCyJGWLoQ0Su55uaThLOVaDqBmXF13IU\nlviJ0DWPzDTPZ1Tn77kwhAWXglcsE6S2pBhkLID76kW2GtXVhatBPls0mE2Oe0AS\np69dW/ynDuXyf0UjpcIH9UPVwsmXPX5LXztAh/2r6raW6VdnvGCjb2dWmPgFJP38\nHuIKPnx6F3MeNSwKHlky3xfe7X4GNiciwTqbd6EEeIHGHMDbKSA91tuhbiBDGulC\nf+lGNWXPZTN+zqbUaDAArLno3vg+vQKhvvkdwfRhFYYqeFJwdKGXo5aEH5g/t/n0\n8sewgmHKqlUa73LzABM=\n=WcIy\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5/sha256sum.txt",
    "content": "c4d2bfec6436341113419debf479d833692cc5cdab7eb0326b5a4d4fbe9f493c  jq-1.5.tar.gz\n77c2e4dd9e92c58a662582a24109330a8a94562c50c52f837f59122a951b4ffd  jq-1.5.zip\n264118228c08abf4db8d9e907b9638914f3eadb5cd50dc1471a84463f7991be0  jq-linux32\nc6b3a7d7d3e7b70c6f51b706a3b90bd01833846c54d32ca32f0027f00226ff6d  jq-linux64\n386e92c982a56fe4851468d7a931dfca29560cee306a0e66c6a1bd4065d3dac5  jq-osx-amd64\n1860c77bc2816b74f91705b84c7fa0dad3a062b355f021aa8c8e427e388e23fc  jq-win32.exe\nebecd840ba47efbf66822868178cc721a151060937f7ac406e3d31bd015bde94  jq-win64.exe\n"
  },
  {
    "path": "sig/v1.5rc1/jq-linux-x86_64-static.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzk2AAoJEK8ZBAxxUjQCJ8cQAJJQoCwUiFf5MHqGHGaSC07L\nbKyvm2OmSzVscld2lb7MsTHRUJ3RR613CpuYsNEG/nVbtaUntzgmtyMWabuGap0I\nQRQb08by5wP5Mve7QCOxfO9o56k/m2MJluMFv2xdJrfbLBlJuffV8rTWCNSNFpaD\nMLTiMnSx0APGxEoN34wOZ7ZDL6yIb+7z3Ip9P8lni4f3B+fJGCwKr9Sr5NztZVGL\nfDwfTBDLHwgpPvXlddg+oEDqVoSodWW9LZYKVo3q0IrT1nI4TdCsc1Fautpz7Y31\nJ2rcZR5qwE9jy+fkm3+vX9Hbg/QlND07ZX21bJh1suE+1ggELrVwh1iCEfBIVEZN\n3tat62QUePL5ymAaElbeX5nIxuNW8U5jP5fjtVu2uEZKRdPz0I1JcGzILi479TCK\n/AcBhoXvdvd6sXjqgNs8ZbNBoklNqwrbLw1ESzwzaGfKytvMIO8rN8E26CO82d0v\n3gob2Bc9KE6+hdobdax/SdXzjdAsyL4fDezRQGk1LvLV3I5rLs6cdR2HRjbH2uFU\nauNQgDLTo1PAYgsTDvDUt61O6K1m2Fx4RZgc6pligHDxlcvPJw+DkSsU+QRD0ODk\n2IYhdakVFOaG+OMcCfcLFJ/3mJnhmFl/VQVdLlrELy5r6NaQo7bkLL1asU9LJLlL\nN5ZHYSx7HvRCAz++hd3r\n=GYEt\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5rc1/jq-win32.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzk5AAoJEK8ZBAxxUjQCJZ8QAIlRnnKW3A6yLpAGSNsQ/Rm1\n34ElcCgwwGsQFaBz7ZjzYPwFNmbrQYi4uJA14Sh0MAWgJiIfjJs+nS2YiC/6etdh\nuCEg4NdYtF6kPlBMQ1MJN1+OLv7ACst3kajezpoCHraEQkcFgF4CSTq2zBVeSltp\nQxVJkMn6CM308cbimWI+wB8z//28Sxer7KyeIbZ9Mjt0YGHYsxIeNhPtDNgVzutd\n4lYGS/YRbRKrVKje/20BCmU7QnyGnWIZDx3A8ofhGbLUnKX80eBuHLWUkruGbyL7\nKMuXPbKAyqtMiGRziqiqkvKRe+aQc+kvJVNUYORnV/nSBFYqqp9WpaZGy0VrXcVS\nszAiIxPFULeAPBiycaLyPrs2sANnbLSaK5OYc/OQl3fQd8K4HycHn7gWzTrsSiJ0\nO2u7YpIZwhnJusZQFbvicU5TEnTnUs68PkBRjI/MJYGna5CrE0dhEjxQ7xfqHds4\ndaBHctNOo/v/Wx6cUOklpdygZK0l0DWdNNgf4u0ID/qrI/r+F2WYTMO9FTxuquID\nAnOcKJAnW/uoDx3eEl/Xf92Be1pvsBSU2gwJZ97UYXT1DKPdsoO8ubUNTjDL2BCL\n7mVQShAasKvCB416kg2v0NqR83v2iLzfERbmyZhhR67WwjSi23r9UXPjgBGsux6h\n0uohePJ5f76elv2W/8rO\n=4Qhb\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5rc1/jq-win64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzk6AAoJEK8ZBAxxUjQC2tMP/jitj5yEkh4PL/apImNJBZSd\nPPRWhOgdBvSV5kycstS3ni/sU2ZcHtf122BLonIJHJN0cL/jVZypJNIZ2gNTA4sn\npi85vNuwhEKYfgMbLnVG03KoMtdjZ/kPSJn8UK+5ShEwm9HgbLbe1Pp7XQJW1nAG\nhdNT6ldqbyZ0j74r0yekN516VdpPPVp1R5rDVxcZMOKNeTbNlX4juEK+BsKvp1gT\n/SWxC6Y048ogMT1YnVySnh6Q1/2/riIhlw2u26Is4MHP9Dc7wxNyegTU6UU4uAXd\nEjg81FpkhRZzF876ZOEfjlDsKLAYIEAYd5ozq/VpCA+rB30Y20tOCPuhilnuWQ53\n9Le9ybgfJOGwloh3vfU3O9fbQKrL6TjA+crK/OmZvjSsyj2ef98vjWdFG8fhUr4f\nHVTnmJcg6R7WIBHxVnxfT9D3hIV0+l8qCWu3TtTlfdGcXqI0NcY7Exee6WbNdmkj\n0nESSddP2nEb1eCEw9IlVliZevJYqwNaSmcN92EWTzJEwj9g7+yK0XWs+ZfDNTUD\n+iQoFY+W/skSfNr5XCyj2wlSElIHUlQtCVZvrnbRz/QmjZfUMTBdKkkVucDGvldy\nYyauXVEIvhFdeY59E2FzoZpdn7LzyzGbg2dA2QwGI7WB39L1QnLMrRPOmBwMJRvc\nJBQycWmsgKzAre48vKpD\n=LnUB\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5rc1/sha256sum.txt",
    "content": "5c33ac16152344893f596d2c9f256b6cee6e925e53718c94d24049b640ea955f  jq-1.5rc1.tar.gz\ndfbb2d073d2df9ee0bec44b60bd81e213b7881b27fc38d7438daee9eded2b75e  jq-linux-x86_64-static\nbc370e22a11c85c525ba1965760faa5273aa3cd0ae69b030de4091fc776538b2  jq-win32.exe\n6fb6f39d847df57b481d36941216c770ccf5f97c36e5373a0c93e63b5506c9f8  jq-win64.exe\n"
  },
  {
    "path": "sig/v1.5rc2/jq-linux-x86.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzlUAAoJEK8ZBAxxUjQC6acQAIREc1GPBwDiL3STKWVEUYC5\nr+Cti+tWisdNGvAapCdGcwcavZ06PM3lMejBpQ5v2WghvsXhFvxDnwyQHKhbjIdG\nUw3btu3ykjabHfqi5L5neQjFJwK//zsan59VSTzRWxjPHpAEoFsEihddKdx8kWzI\nKfPx1sn7ftO5weFcl0MU9ks9kbADJpviAvCk1mxKeNbv5KE9EYiUMjEg0kW6JmBM\nrIJoWc4fUR7rHbnK8fKpEuBzPLRBppFOG+ma7dx/4tCMjZmzmGIzqrCwgRStoS6j\nmr1Ws1f+j4y9ZdCXqubDVpzesIQ5fWc99H3kNuzIHBku4o70OOaGKdqvi5JBSiJf\nE6hD6FrN0ugu92IvRHNG4Vkg1hfNiff97ZX4lEHicFy2Bbpql56yHc136wAlLkvN\n8ns9xIE1APTZI6J/6lHfUDStWgKOlsgf51UuT/sJQeE0N2RscSJ7cxhR2F96RQ+Y\nVb+hMg8QLA99B4OWbohkKR9eePoEjLz9u9kgG/AOJy24m76pjO3az8Xee9I4LFMp\nws78NtQgGi+ZJ6JP4QsEx9ZakpdWGnpDgIskQE+LL7MH0mXR07CpXXEMTnEIBMj9\nll/pFQ7bFJiPSXZZhRQVSiNhL3a6DeLe/Ik9xY/djH4WAMuOpEQsbI3cRxOktp26\nFsUWKNf6I+CrLaXbbrBB\n=lABc\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5rc2/jq-linux-x86_64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzlWAAoJEK8ZBAxxUjQCmrMP/1jfOkKVG7FZgArN0ZYBgJiR\njP5L6/zlMG9SDecNnEVJ+PX7YdiBlnIQ7icV6iveBsSvkVyY1Mp+0ibzIePtNV8I\n0SScmo4Da1gQwxaX8lKIfCTemOSvhxl0xqdOsYHq7nRxnxSmh4MFnDqXLS8ryW02\n/N4NsFaUCjEvyFVfNjRGDwxyR3RhXr643p3vp+JZvZ8wLeZhM+ZXg0VDdXAFFVHJ\nEjIvedxV/IU4brVkqgRDPmAKdaVbLRezGl2uj7PYg1fcNXevUSHEY6bsxp9FSanU\nLWkD/0rElPdsV+B5ST2f3K7vTSjDOBA+6L3AEUR2tViCe/FOJGTMvVrJTG3/r7hh\nSTARqZHX9q/1oEFQAZY1PX3mKCUrXKTBLkTWNWg78jtYXtV8JagQQPV5CcmaqPVA\nu0M5lNKDhgx5Qwy/Ap3FYkKtFHFuDxK6Y+px4J7hGRuH2casB1lYX+4YS4J8h4my\n9dnmly/fpOI5nuONzXweX9zizNcmolqf9RAvWE0umurBj8Qyo5vMeEfiHVU3DSxw\ntIDAnT1bQv6s0mEBvFX2Fx6AJHc8wY4+iyu/fOMpSdMfbJ8lXeXYFH+SzV4uwseq\nc4j9eQ+Ab8SoCUMsFiS7KDAhsiMYk6rKn+aJthl/72GVBbnoLbYJs0frjlAsZmz+\nReXdr1sBmm2qFoJ43w+9\n=UxxZ\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5rc2/jq-osx-x86_64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzlXAAoJEK8ZBAxxUjQC3YwP/23mNNa+XscTIWHKPihfNoNn\nTIgGXP5znWOUmkNarIDl2ir5qi8oq6kBLoz917uz1X/KY3yB1rDoz+apB3Co1Ayh\nS+oRMeHUCE2V5OIBPsJyMHM3cgfdbVx3fNwZitpv4Tw7s9ilRG7SWD/2Ev2GKx/h\nQn4j9JLrxJdvoSS488oyjK7rIXLSDM5R97qFS52Cl4beO0dJTdy8D7QOCF84soHb\nSUgrXZkNuzjs7qQRMJb60mhQeIkuUC55VoOUufoXTwpBZJNNoyqT1eNNlZXE884Z\nkvKJ2q0FYD7jh1Ct9KFr6gfx0HIjxMb2YYtCEilkKSCHG8JUHgCY5cpAMDZrVa5K\nss9Iu+dkor96Qv7nyJ+zhjEscl1rpfvYKJbMLhC+M/lHpZc+5rtZBPFmZv8wedzB\na3/hkyPpxp2YPa32CAZ4UVFE3h+lBLvT/PV5pB8UvYPbDrWzLx/V2aNLP1joZKH0\ny4DECAVMAD2a3dv+xuee7ZJcmL4gK8a6sZbYuOWgnIjjGQ4W951Dz/CoiojqofKO\n9QmcDiEOQQdnjpfuObSX6wNV3583z4GEHIuKLQiM7rtmIvzA2x1RCF/txZoxg9+T\nvwvyz+689ju/mIdUjdCGwPW6qljoMWRPXHJ11mD0CBTQmNEJiMbhE5lt/yH3/big\nmVPHv/DkOEM8pLdpMHlj\n=+eGW\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5rc2/jq-win32.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzlXAAoJEK8ZBAxxUjQCwSQP/3hRFwE5XzTNpBbMFiThq8GP\nxON/4/6H0ql/weVZPRyoVVuToKY+oym5j6IhwBp8eswQKMF0p5FpBjFJFFeXM9RC\niSmYL7NGKSZJMLQHFLM37I/eDbaIOo4OobtzD0CAg8ZN8nlIHajxZ+vsmcuU/L6k\nnC5++MJEBWoUMYUdqII0F+ivlZFwngrnCgeLIVwWt55ojntbBjjs32S2gT8HugPz\n11zAnx5C7KfDTnDNgMPFDPL3T/yVoyasVxidTB4sQrFeR2vns4F3uDugEBAWMb9A\n3WRSzcuYdlrVOzB8WoHS3E0esEeuqtPIz7y3mvrvYsZcpIPpXaagmKALG8zZ7p87\n/s9zpQdFWTe+boI6CdjG1+UKY/QhDAl3zalIQiqFSiBsbk/yhDtNug6oqGO/2fQw\n/xWlj3CmQsSMI9KjlrcIv2k4ugbYtIxVRvEJqqI8Qb47Lmav+F+VNhrwCcFdlMiD\nswD4xfT2Knfkx7OOfDv7fCRE7njBBOTumYu1o7G8HbZokSkAtS5sovrzLWEzXRPz\nlV4Of454G5Quif+MQIw0P55XgFCLLCEpcbt4vOtkCK/GaLuV2+JKoyJMoFEG2mAr\nT2ufop5Re1z0hvNe2VLsMhcUpSUKsFl4h1aM+YYhsOnlGG7uXA0bTAMmU1+n2uKE\nk/rOwLp4Lyh9gw78IB8T\n=A99j\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5rc2/jq-win64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQIcBAABAgAGBQJWGzlYAAoJEK8ZBAxxUjQC6bQP/3WzIL/KgnUmI3ziUJcaKgLx\nEOkMA7Ib5o5w75gg9img3pvYCLZnlf40TiRAhc/gQ+uIw8uLs2wqZFPSNE6G1U6i\nL2AQbcl4e7P4glvsd+PjXKz9lzCFyPtCgEeFA/T4UP07ef3yRpreFmYcW4A/5Saf\nWWn8nKyVL6vLS2vG4zZi6g61Rw9mlWFC6VeVLe+/IHMH3y6WtT71SDw3h0OFH+Ui\nDVSFXeu5Fiu/NEiZUyb2BLK/a817zhQ5xq2/mCoYrKLgLzbKaSuqMe47Qn6Yjkbo\n82F+lDakDS3bsoIcvDkR2w8ABsPwPX+xDk8Z2Usyq2wcCEvSTKoB0AiczYfe6Eod\nuz66AoDZY/v3XXs9F3NWJqLRfRzu+fHcw9fvfzLET6gVkmbc5+Z7fDNXOtJlS2oT\nKKImd1vuEoffjgblera4Dg+v2f7rY7yFCQEsYGLnhyEb1/G4nb/MvQJ49NOB9AXJ\npVvslWnwWJVy0pzo0VqjpldKGg2EAFcJ19+pgUOFFCF2Ax1HsvJhuxiyOKBDbn2q\nN8ivnjv79B62epIdUc/zGLP1In9yoQcDfenYlBI1PJL7nw4JdxFGBS5ajE/SftAD\nFwsuKvIlToO2s0bn+d6famRnxigWOhjr+/Bm/8AP7HAJdD3Jes6AJLsuUANNUfW6\naOU4u35qnEb1KZIrvozH\n=ZZtM\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.5rc2/sha256sum.txt",
    "content": "2fd209ca34d0891499bd32f59ec332b0b3048c449c388d428e5c5e8132a13e81  jq-1.5rc2.tar.gz\nfb7c57cbce7073ec18f669a313e956864dfafc58bb0c1a158881335ad7daeb58  jq-1.5rc2.zip\n7ece904edef3f951ca0c6f68cdb14e782d52aa46624fe2de9cfabfbd98fe5797  jq-linux-x86\ncced974e1f2c50d6203e09c2e3ede44075c4f35601233378deaf7bfedb2b4aa9  jq-linux-x86_64\n25f930463c94414fbff1ba5d76a9547259073e8acb19f709880e913ab58586e1  jq-osx-x86_64\n8bf6bad065dfe5bfaa4c22a9ca80fddf8bdffc06b8fc768040e4fd88fbe5f58a  jq-win32.exe\nf8301b1279ac95e09fa9bfb1b38d411e68590bedcbe70d27ede7a70955d855dd  jq-win64.exe\n"
  },
  {
    "path": "sig/v1.6/jq-linux32.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEET9cB1vqbPS31rJNdrxkEDHFSNAIFAlvbqFAACgkQrxkEDHFS\nNAIQNRAArTVuw4JwSbxKzC4Y+ib1Vaz5d8ntQwmiR1FBJ5hbi5dMhqD81Kl4slU0\n0IDBia7Bnvthk0/H+UZHjUdkCNW8rubg87zJOt8t5XXQmIK81cPgKhxqhPA6JPA8\nRNmBGs5gAxycm8x4X0EMOVTsVqAfq8NYakO6MctRlv4ut3lXfWe+prIMBpFQZr7l\nCqvmBY8xhLF09LLBEB+RTjhDeW7E02cYFJIW9bbcvpECmnX/fJTjGwN6+Blaq4ln\nnJwODDZ61TGC2ZAYcAoqcA8bkU8ms0x7RCpZrRbYG4HJstSYM8RaxUxvtW2zn6Si\n7FpMvrXnDn6MWr3wph96oRTEkKQsRhxoxo7zumaiKkaAGKjyN7fFx9z89QrKoxrO\nCAzGdHjt6YSmXH60ArGUWKGRilyvxieKddXD3fMJ5Sz/u+yHFRNDIuOQt+KZaOfC\nUlvKXQamexkXmK3PEl5ZPxcuK+G/NLFawPlLLHVvdLx6B5o4r94ycfLLYqzDCiby\nv0EDZrgVropUMUkJJMjSmioXoizK9KZ/fl5fj+2miHEZS+s+YwZ5aoPi5IvrFUhi\nsYz3wEKHp3aYzTPhPt3wBU9aaWoTradSCP4pt4eJV/VeVND+vygILdoD6xFWJoc4\nBT2tBrUR6uqdQXaCn3BF0lCfI17fab1elYwBkh291wZeKF7qQ8Y=\n=cTl4\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.6/jq-linux64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEET9cB1vqbPS31rJNdrxkEDHFSNAIFAlvbqF8ACgkQrxkEDHFS\nNAK+UhAAx+mFwf7XRYLznTU4HoDzW3yn/H+amvYpphvtcn/eB0GsZRpZ3+EIkMUe\nVF9Qxidw39tZeLROdX84iaYSu1bTpd6vAdx54rMUZyPVry6m5hqUD78LccPvIDCk\nEyFuRuAAqlRicyNuqtlr9BUBoI7Z2c4YOA3Y4oXlOXtleL3SXKXcGvhcWQ4owZp5\nMN6tT/lNu6sj8l5v0Y4GxtfDg8YOap2s9MdaNNkAgt3O3J98gadAin+vQ34ekKWr\nzsB7QjZaAr8OSGyWCY7BTc7UJbsTIzFzSPvYGeIP2iCBSpR+qcM5/bgrE+Q4l2TA\nt+p6vF1UVo9MkhEhD/2Ru/ovjqRKIVKA0J5YvEzr2jWjSAWpc75y80rovqW/vjE4\nGHBJootozgrUwe/ESTATzdyfFQG8Du8znnQp1Wv3upRPieCKiLiUkRZenOTvBIvW\nrHhgBR73vfhyD92exum4Z97hglwzjWJZRYohyKz+D0tYffH5lG4DV2pToREMqslq\n9Yr3eGREMD/6j/zIsfzKxFeC/Ar+vmZrate9bUPwX7WYdwwbRcmx7zI6hIszFDnc\nRONpuJokLxcgfVC3Q8Tzo5cRsAJ0eiQwO/K3oU/ZSAjJkV17E+cy3KFm/C0BSvXx\nBHxK2D3vqCsbtlfkLurxzjvFKIAQtFO3yfSI5mIMnWfRCgvoHcU=\n=O93f\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.6/jq-osx-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEET9cB1vqbPS31rJNdrxkEDHFSNAIFAlvbqGUACgkQrxkEDHFS\nNAJT0hAAvuHiFUoXoHh6fJ16dY+ZvY4lWqAUap+mAWABuMpWGT0nfjq30eqvCY0e\nVjk46ENJPNjCNQnxMRq3kWMqsaniWLgU/sbXK1Ws7RldhJbxjnL8y/jHtNHQtrKV\n+RhcJ3FhDzLSHOnIsTYYzHFZ1D+qeU+XMafVnnZSCj4SjEMZjzo9VyHJqyu+iG0w\nz2spLd6zFp1+6EtZkdv10NsiB69HhNxKUn0BUE2KOfasLpFZSoMN2OXNx9qatTJ0\nl/+PKzSb8DkRh3uHtowyV7VHrPUQ8/WcyRqwNKMmJaB3WDDwsPJxgQT3sJVpVQaj\n4d768B23NbR3LZbqPgczu50kn/6Q/DJTm7J/TNxKIOfnCsIMsiIhQ+oLe7/8c0ph\nxXhNZqzi06jB0kulmGus/YQY+Nojquzc+mMOysoxYo1iWscxWoK3GrImO3YMACk5\n0zH6pHgLBlWZ/5ScKmvAn8tI/EfSUnsR/QMmFEZsc/80tkZBAJd3HPeamRtLqCon\nT8aSP+xwwzo1BFhtdVddYXlXFWIwtn9VhEYJvXN12eyhW+S+dKyUlJCdCAozkntD\nQxOILIc8RF4F3KvQTo+t91hbjyPGm760/iQgHU20UpRxaIkJylQ6p6rWsV1wEMMr\nQEENmAs0IyawgJGJ1Jr7AKOR1fqEqW2BJxQ9zi9re+dXOvVWMI0=\n=J3nx\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.6/jq-win32.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEET9cB1vqbPS31rJNdrxkEDHFSNAIFAlvbqGgACgkQrxkEDHFS\nNAKFsQ//fWWzw7pWIt2v0vCn3VOAqWv0oB3+YEhqmYNv3UJ5cJBeOndR4C0kT2uH\nMnTIR5WCLw9iSiNkHUX+oiWT3Rw8i8oHkA1Ub8sIin1RksV0TosTQa++9XqdO92q\nHBBLUe1Y9BcIU0MgEKDtLXKwg6wqW6zAl0WI5/fIPT8Du7evhI32s9zVTMH4AahO\nZUM+OXmNCRDVvVp5LS3fZR8E+R3+Mt2ZplGb+aLmoX+hvVTc15GfVtFLGMz2bF1p\nLVG2/qs9XQP9nCaPm/JCB1F04nHTAuUb5BzJtdJUpqBJGN8diQrxLigjyxKsPVNw\n118r4Q/6FELTlMg9+6qOPal++ihjuCNWex5Mqz2+ZnANvtRYVx/5bF+DY848JmqP\nV2k0JF/pRnwaCd9ONzYjkWcCMeoAAvwPygl20NFBUgTHC/xdh/0j+glG0IUW7Wt8\n2cJyG2OpGqR8CHTc0WDwV1SM937B9CuPjYANottrl2mDmdhhykO5gpDSjf7/is4y\n9sWr4MqI62aI8xBVdLmTsF4kzoWfC5go4SAHvXlsBr7bMW90hkcuuY0giB0mWZng\nVQtRtpddKmhstLGoKMWf7TblX4uXA5Ym03LzvwhGl3PlwKh4HvkVYBE7EaSKuJ1g\ns3WxN0vP6mP1nMFF26fC9IapYWIcTXjyJ7Hmo0Okwn543E37cQk=\n=KfqY\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.6/jq-win64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEET9cB1vqbPS31rJNdrxkEDHFSNAIFAlvbqGsACgkQrxkEDHFS\nNAK2Sg/+O0nHwVg185EwKoORwL7TQ9V8VSV04Ska0lKJ0Biu0w0U8k+bkzhY5IZ5\nIdNUZb5lhnPpLosCLlzHlWD3fNkBbpYLgxDrGDS7EujXcp8lI1WrwVNuY2Gbz7c3\n09YAeF2ENnutS4KP0BUfdEVMlEqQIVpGldl5jKgHxlZ8nP80z6IpNL9FnX/qwkZu\n/fyRthz1XAEcDHfzBtSbJCJ58QoGwl4S96TsuLZnnBuNgNk97SIeiDzg7tN1FmF2\nwyg7mPZhIdRaGfgRLCqO7+qFGiYS4esJj4SbLiWDREVKhqqnT5B/vF5SmshsssUm\n6MH+eK0BAGIntTs0fIGtgkiiuZI4bJpkxgfr5P6/F85U2d1YAJSyJubVMJhxx1U3\nvKjUYzj4ub9GieT80FFmNAbuUTOFY3y5ZLDl3WRXD23/FpXTxWvTMNWs/Ypt67iT\nSLcpC1iAETTsaAzLnPxPtwjApFJv/+Wy+CXZl1xAwDHH4vnSddRaSjjl9qsi7yNh\nU4KUAVzpHfgmsK0DY1P4wXbBEuXCVcUBhGIQ7z5/Bw0F943C1+tFz7MckQmbsvay\nO3+D8NeQGNb0wCIt/Ro/xIqSb8yrI4tL3+phnUxiZGxc0z6nTw1O9BdMRX6l5/5O\n84QzUal8MoDWTy0pb1eqUaXp6Cek4c9Lqvc8WPq/csAE2jb/PGM=\n=xykx\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.6/sha256sum.txt",
    "content": "5de8c8e29aaa3fb9cc6b47bb27299f271354ebb72514e3accadc7d38b5bbaa72  jq-1.6.tar.gz\ne33f9219cd8c3851b411215dbac51d7fcca4a2b157964bfcfa56a1d718e2de14  jq-1.6.zip\n319af6123aaccb174f768a1a89fb586d471e891ba217fe518f81ef05af51edd9  jq-linux32\naf986793a515d500ab2d35f8d2aecd656e764504b789b66d7e1a0b727a124c44  jq-linux64\n5c0a0a3ea600f302ee458b30317425dd9632d1ad8882259fcaf4e9b868b2b1ef  jq-osx-amd64\n0012cb4c0eb6eaf97b842e676e423a69a8fea95055d93830551b4a5a54494bd8  jq-win32.exe\na51d36968dcbdeabb3142c6f5cf9b401a65dc3a095f3144bd0c118d5bb192753  jq-win64.exe\n"
  },
  {
    "path": "sig/v1.7/jq-1.7.tar.gz.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr0ACgkQsNpg+0VL\nrxi2/BAAqwq1ZsOqkHK5MtgaL+fV/KtR79fuKFo2IpTC0kd2Bif8DEZedgTg2DNL\nma7UU71kwEbFwOqroKoMNmLAJGrPPteTC8LCdTDYNTcMXMSWDMXmnm+WUtQvV3Vs\nrK5VavN3jxMLzafErfUH8ZWnrzMjZS5ZKPSOV+vgbjCtM+LsiG5ZneZ4D5BdI0o2\neoe/FA/VRoiEXCC5HOlYenMWP/zdGYVpLUQ4Xwr6ckgDw3LWKIjfWIGt8v9uLy1N\n4oPVmvW9fUBXlONV+4wJV8yoomBXzD7RwYhRkdVK4B1SZcfbeqzvfeRXOlc7+n/S\nyteRmxcJbxo9P1JvFuIWXZ9+/2evsAEhoha7yp08M2go9Eum5SFvhuBAEB0kxsA8\n7WY/wwpZxfDwU7o2H8rjPe/ciY+FTAz/K1Th5SuUocEhYdHXqJayOixDCmRVIhHt\nOQq82EHj4UcU4tkHf7bc1graF5XgN75Ld6/uhZeMdFv5VsfxKmMjyaRdQrstQ0Ng\n/wWtLGyTSYRznbruFpvGNvy655g1CMKTGvItfQg5B8rAFFCVny/KnwjeEvSjiKgF\nqaPYGL/TcVPVvw34agXFAx/gNEV/QDUwroYTvxzUz4qvAQ6MnpbD/hiuo6HbRCPv\noCXy5RPrr2lDFoUi6n6YdCmzfP8KJhfbXC6z4DFJlYdeuKsu6MM=\n=9fDS\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-1.7.zip.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr0ACgkQsNpg+0VL\nrxhU5RAAiHPJPvbbkt4cAwDupO8ma+PTbjSiJ1/rToZAybSrLrfRVRvSy6yDmVEV\nzvf1ie1sutfyMP9dWM1PANeXUg5RaQmMVWUWBl8MiXBiCd3g5D6lfFgzo7+GFUU4\n9Foy5kmGWhx70xypuGqUdYkxYDEdGiMvYqb5xEdibT4REbPzjiqo2cOJBhNsG7ZM\nntFzgfvqS2l0jHmtBjratI7La7Du41q0RLkNA1+rWNEE4RnxOY9+be5fBks5VzLa\ncNeIYjzp2Rl8LkLgThrjQlqKp2w67HWUsmeaFuIl6/cJQqPgi/3MbJ3WkxKFqE43\n3dilzy2mmLEoKB1jpkPpewK45pI6OKJfyhAF4L5ebgqyV5M3WQzXLPUTxNcTeFJE\n7NVUtROR21lhHs2QrW6hTbu2XY+UBgxhpW4fbjLUGaTyx+Ll976vPhdOckktT1un\n7atnKOxkc/CcrqXvNSDn2bEJ0GzqsJjcIXiNVr64zx4LIvRASJ8HCK4VfjpF4ijy\nkIxYMb6OZwf8v2L1QAbA2j3Mn8jBvW5qs6HlKcFxQD1PwZGTA37WDtsMDawTonsN\nPV0Na855fKin4lSjn0nStu31Sg71F4K+OnBWUcs1ldAOPFlbwtVHQ4XZeXW+fKHO\nmXOqEIDK3JrhdJen9IHdk8+Srb8t+JJb4aqoTqQRgnAfxmdUyZE=\n=WaNc\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr0ACgkQsNpg+0VL\nrxjhhA/+JzlKXLwKeyLTweYO3SyXSXOhyYmgUSgUfnkKHZNgZ+jqrTR+YsYMlTT6\nitXheljI016OwzdI1JqFDi7Au5OD35ErQxEAWX/zXty04XkyLyuh/QGE5A+6s36p\n4ufKhCQyGBfGYXgHlsxfctFug4KmoQqqV7wNTsj9rZmBlSsFgZ9u1bkhTFIN6TAp\nVwF1U7sgndfFTy1FD00/xnB1OCEVxVo36N5gmRl8qyIPvxN3u1Q+k2gyyvg+Yj7p\n5UoaihwGM46zWriMEFsGYoDiNoSD6bcuprZtK/y2gYXLAhv3MGCJw2ONmCmpQbcW\nju4W1b3clYNzMVd7D1l8CS4+PoKJTgfkWvIEjle30vdICgMQ2wIa0GfSPABXfFYG\nSJJTVEeD5P6AnUfx/d2zzL8POIY25jjzRCx1sTSYkpPdv2zWk/7s2ul5aX2rXALg\nyP7DZAirYGyaEvye+WUFPtF0rT4b4Km/cZ8bdwv4Yn7ANVyik0y6pgjPnHVatS8P\nktQ4hWLlith21vTZ2qPJNiDGHq1EnCQS5XCNMgJvazkBbZVcyBvCGdMyHWJ7SBuV\nSE5PcP4tUIdgM6mMKToDchFFA523K6NUc5AnWhoG0PellqlqrQzw+V9Sx0UWo9BS\nAPPy3P+yamDZjKjkrtLuh+Bkwg/BYrCFrTn7yJpjZFmCPCN2wAM=\n=9OTr\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr4ACgkQsNpg+0VL\nrxhmQg/9GD7+72ljIgOti8muVAK3Wt5ZKWV/I8fmEKQD9d92kYqMGT1e2Zni+tFz\npfiWFQrmF/O88mwM9KCkQQEI9Uk5jQ57lx2gWZiiZgk844QDgKePd+lf9nU9Tikh\nMlY5SnwiM3h8U+4CCJMDQWXp62p98q79+8IXANDIJJdczp8m/QuUuvPL2v044nSQ\nEAmZlMCFW6OV02AgukspwippS1wSCUkg2zf5o4gg5gcKG/xtGIhyB27zRBEBmFFV\npNSPo0W26ONKgladM7V9S1w3iMbPZ1Flng78DR0ZeQOrX4SdoNuAmytKSt+FIFm5\nV7WPkDP31mUpL7v6Q9INW8KSEhhwfQeYXVPWuclsbZ1hfH3AZgk2UtY6tyOi1l9f\nZswkQmILfgZa3CJPiH5ryYhQQJAd/iDY1KwFD165C8DGpLNPeWVWx/8KIvVtJ7uQ\niwOva68bZIhKFjEFb6gbbV1huuY9QIyXyklrwgtkrUGBDhQWSQ+uSs0Zkhmy1+GS\nidk5kGFNCxyaWIOzB7vlepUd4ATXbHdalzT8c4N2yLiOhQYi79kTnzLZUaL3tEEW\nynIcr1Wf3M2xUUVcd43Q1GBlVlD/uilmoRl0e17jYOdq13xX4/M8797wdoOWgxO/\ntDVFjI0Noj2jI7TR2qptvT4Hcz36uKOnnF3H2s1SXdyNGSTKGYk=\n=kcoB\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-armel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr4ACgkQsNpg+0VL\nrxg1jxAAjxjU8b1TImyQZOag4hX/DguRuNGpIHUUsBMDgYzQ6JecoIaomanOkKqn\n1K4qbqkXT2a/QxeyMVPDuOfSqfe9em3h206G6jXIUx4FRkAyUJNGvvYrjKLet7HS\nhZOAyp1GzFIs7syKYcCYx+w0I1WXJTp9CJTkTHYODDCuijl7z1YY/k+YUlysd3rq\nXkLJq6/1miZMTBP1aw4TYO9QcThu0x7HkRb35JmxZFp2C6lTakdIRWvtBjs1ybG5\n0lR3ti15K00B4Y7P6lUabuXyFIE+d5keN4oDYnDe4naLyoZMh2gBZZeU+U3iFqcP\n+BF0N48g9l//voWfUieLEgl5khayvTWVrqPc1Urm5cCGwRYrXMaVFfOkt+0GA4ww\ndwoxljrkS4efEYpgPH7GjcGWe64rhIrGnUGaoKUESjDjGFN5/NC7Srra6LOz9qaL\nbUInJPSTRIzxImpNKYfLRKtFHrIiIxsF29iZrAABtYw9aMdkVWrT/LIFAFm4OrfM\nJU3vYoYtrsufc/dgEYZK8vscZvFvMzwtL9Yikea0rI25GEtjtUvDO8doxLYwlBu9\n4cWDtv2t1lLsdKk+XDaS59/rWKDm6P68c/i0UAPWEESFEBnvJskLP+Jvu52omnmN\n2HOZNJBp6/4ltG8hUCYORjaYpVZfbgc9bEGnnkO0OK504h5dpE0=\n=39s4\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-armhf.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr4ACgkQsNpg+0VL\nrxiIWw/9EZ5FUJTf6B50+ewtwIrrSxUK15DetFVgG7uT1XFoM8IlUJ15cY1Td0KT\ndG9SGW4GFK5L/8rqCHO8iLCOo7+kiVQtiNgs0cthKPn6/UA5S3ihWOZGr8AJksVR\nodbuG2CRcUbJUK5S21RSlNP5DS2RtOZaEeZrea7FAvbMSiPUpHmj6PShY8O2lbV7\nEDkwItVdf21sNTU86NvFVwgAzoRCnMgQKveDZan4V+SiyCtGlEr7l9tJ/8FkYHgA\nK/SJKmIgnGtEUJHdy2Es7OCVWmenKfQ9iNFf8ixD4M3/esXfMbNZX//kLzfe5+xU\nVkcGQvF+L/oJyvUbw1ATovyhoijcE2+DtmRkxKdHMP/7IpxhH/+ENRC7zdIXnFd8\n8OYTn2GEwwmXTLnTZ6DuGeWiB5xZMyoHC5RilPu3QPG8WoPHdNVnA0Wg+YLBuliK\nXgfxJVOPMSOc+9s8BVPw3oaMcsP2lEmUeIOTkdAIcBN3wX997oLvGaApfTzOvDKy\nxDOB/JxvCbnuqZRvsr4rBzzKTpSczKa4lE9r4la4rM483T4fLqci7r362knIdQ6s\nVv4CTsQ8/YTSXW7+I7khwDKPLDwyKuvPGi1BFlOQFFsF+ZanZtQOp5HmwKCZ7REj\nvpJhl9XCZuMG9E9bbXnrlbAEtMurDz9yryoEoZPqGyM/iN8Bpkk=\n=oAR5\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-i386.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr4ACgkQsNpg+0VL\nrxiuzhAAgpI963y51Oi4DGDHv9nu7v575CG0G/QjNowGbu/zGdB7k/ygIsbE6vtI\nJA4lAgXWUjBxBgU0TubXc0JVnjPjIUlIvpgR0UImq4B01WXYitfF897SJChuzPx2\negD3jybvVe9B6JnZ841QXYkqvp2hZwgXKVGedjsen+qHK2mlbAoeHRKA0L5C35eX\ntNlycBvWyUvSjATNsy44G1LLu+ZUMKRXff425RPI/By/8Zn9diipzXCusFl0b5I5\nhOdL3BFcqp4JXtJSyR7Rv1BKnCsutZMwSXXPrTIufXUVbmBv5ziH9Qb2u+pTL1Zz\n23JbG99Eyw3BRGKYbdr+t01OUVMm4IVP5wrE2gzl/elr/YqwdDBcBaA9J2p6AlB+\niWkn1hlWQzgTyJLJkD3BFDzG6EgSBbGamXPJRneZZNQ5Cogdg+wkgNdZRxcn5N05\n63K9CXM6mARMWWUsff2TEfjO6xQnXltU3Py99Uc8xfPVitccL7xQPSO+L6stzi7X\n3wNT6imcAnpJHMj/7GqfRFAjHTmmp21IpevZhOImu7WknZvmKtBMQq+3SlECzyTB\nXuzNGcHp9JHtc8L7Af9lo44v9FupWY5rC3zQnPGPnQgL44xDQjimqAm38G3awPdk\nYYQI9EsV7Ug8pGiPXERVmsy4o8lpdiw9VBzdd3h5YElWdnrzRjw=\n=uTvJ\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-mips.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr4ACgkQsNpg+0VL\nrxgmwRAAkSckwt0TU79XugwnwT6Gr1ctvLvyZGplF2p5VyqJGtvOAutuPHAbm7m/\nNUyKa0G/DjrVecERDJcxMon0Y+lo3E/3Z+7eQWQjHcaxJv9dI6LRhqeIAnAzTrBs\nIAbDoOrIKq0O7B3B97B0WomjgQ7NhXbfru14gKZxNDcIFIsc9SGEi+fm+CI0ZZcL\nGTo18cVZxn12iuXBt9SlIRjoOUTiNEZFC5nbEPbitMfbcAcSOoC1wVumreMo/9IM\nUrEKN3lCNhe2yjDUXlVGzHxWMD0iTw6TJU0XmUYneQhbvn/qHgyqp61TivQEoeUf\nylh69Vt3liZu9nh8xehGUaJRjPr949QeKa/WChE5paMjI8RsC9SpQR8Lcq8lP7H/\nqseMU5rwCVNQYhINkrYmL6P2pmPY1qZOFObte0HBdmJ4YaTqgm0qvAXrw9RnPqNX\nQJDJroQzsoL3z4cGx5DuaL/BMn+iDWDJPjhEPWiRaZycuHkuwlz341VZkJVWxlFS\nCDYbX028T+4dLOKvKzcm8kVTX+IEo/DGgaalhU7ialla3/+1ITJrJqFCtExOtLEg\nkt+x4uARUZm7mkCLDXy5hvyGY3Ai2YcSQ2E0F5mwTVXtwj4L8x4joCcPYlrW+LGz\nsZh0Ohb3HGB4PczyAIyEBy7QhJcEp2+uv9cQXdbylN42zddKeTE=\n=eK6O\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-mips64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr4ACgkQsNpg+0VL\nrxht/xAAjF4ylq0qxdS/A/fV2raQOpVjE5/MxlQewhgqYajLdcyZh9z+wB2yA48k\nNnKY/wvif56WlWITjJLQ22eIb7CyXXLRZSJWBCBywHhmOdAaQURBr5aEO22N1CcC\nPSy5P60bGey2yiua1id7U3k63jBee5Ai6fo57Rtlt+NgHsax1CGefRkZjxp3w26A\ni7AzmxAND8Rmlh36HG8J3lTleAq/XD3p8TsVnllz3+RXzDOpLO6kyuWeXpnRCWJW\nzIqV/xMaHPEA5VhpQs6M7uvo9MhLkBuR8oo+LKeadSzm0AEGsJha0XzD10YkoJP6\na3Z7xhMTT8YZrepiYZpSti2UnmKUJHTkSCPvMqtiRJLuYaO3hITW/hsLVpoK/p8F\noJbE9ki2L+jdc773a942xT28P8lQiEGcG3kKTWsfQhY9ddSjggO2ayaCPuf3f2N5\n4a+awpiaTfZrynywX61ooaWiWeCks1XExH21HvMTNB1LX1dD6L0ueayIVyokglyx\n7yiUGxKau1Z9zDO6cxjifZUv83umOc7x/gikGnLKb+Vhnr5HycIyllcA+cn3g2D2\ncaf+UXMv1mqZf5xZHU75kPnhtiY6VnJFFe6y8VI8p/HYz26hZkLslP7rz9x0llXg\nVZUWB0n2ONB6zPANXO1Eoc/SkuiUB3FIOctA+N+MytV1mcrg2KE=\n=lsxE\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-mips64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr4ACgkQsNpg+0VL\nrxipcRAArhIRURauqvYE2BT0dcmpeF1up0VytyQsmsEMsnRufAtCs00G4ZrtvvbT\nLBhxWgGwMw0trpRwML4IN4gVKsCEINE0Z0t1m6WdywqnjpPEjZs9FfL9HpGZZbT7\nWV54jE7Yd6BbyfzXLfWvRQ4veooEPjKNESq09+4lKz/l+eUU5nryRlKrMOzZneIp\n4t7wYukvQPyWgJbLwvL+jgPePqZwBm/fxWDuUwVWlxSVFwfw2VdAdllRWiNNdGyK\nmqVGMNHBxTBmsXZHqF/JRlhlMjoabB20KDPpqECWIhrRpMlA5K8+M9vc4K7cY/Xb\nCw0mPtQlDyyXk15f+xbiYpFvSotUX1tg5Od7yAozNioPxpLnPeKuJFIAzNbDwzxe\nXkrTd2aC4GhdHavtWZbeNW7MTJi12qbMyyVCL8sme4UvgmpC0rXVQk0y4EskPdKO\ngBwFmFASvSbeFlMO3FJsIQEbE3crndxTLdka8IxJo6Hb1QKUUszxjovUkpUoYT5+\n1OHoDybHD2NHzziutEfvS6mUujkRf2WVQCz1MzPDxi9A2WVvBBb8V+OWbpGYcBBQ\n6l8/ZMjIdBzFDKBjKcM7AH3CO9lvH041Aaxjv/Htnih5toAV6Jc7eE+hNVT54is5\nnek76gPDK/RpBnAxNL/l7Fal57bi9r/kKmgByltsZKITBSJCTLs=\n=NM0L\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-mips64r6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr4ACgkQsNpg+0VL\nrxjCahAArur1py1oRs+EwF1dkfn+fTehMK1tMwun/H2l9b38FgHiR0Vh8K/GfGCZ\nz39WOTM1Wa+T+2UzWGGx/HJZRsKR5EtizryUNF8ZgwMjcyFspGCjNGk7+4Nw3bki\nHccXa73b1BbO2ttCIvvzDGSWiRfaToe6Ohs9ObgJXsHjBQ9ub+4y0UKr3leya2O1\n+yJYZe7FERCCE5dcXSW1X0DXvhf40IHzi2WFKYqiA/ymWht/kyv4cEQsmpv+7ZEW\nWNJXvqmSHIaL4EA9/AZ/a0L/F7uHwBnY6oiJmTOzLoxxzHWC3HMoRF2IkmPek/lF\n2dUiqHEloA1BOADQW9yvSeUW7jR+SrJsKspnp932rHguP59cB2SOV2j3ROeTfwhK\n+Hpy3edLI6He9F+6EjEvuVwYJTDpY9t14j2S4vDgcQIGr++u+dQoMasHvvfdoA0I\n2I1ooVlwmkRQqO+mfHc8N3hMBwjRUpU070504eNcO1JUhlh/VNKTkcCvyXqVyQoR\ntJJsFbRQQCPih8dYSdDbywNqSCCbR3bSyYLmJD97GEYlq3A23NAFI0RK9VLHYIAE\nB5lUEtOqhKOwk635lX/0n4qUY6Jbi0Oh652hq8FXcSUa+ayUHwHslt2f3cR5Y2Bi\nO0QtpKhxB/Lxmnbs5XOLrMQKDdtmQRz0TzBhuu5rK6WvdeDbyNE=\n=MEOn\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-mips64r6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr8ACgkQsNpg+0VL\nrxjOOQ/+MqpkUSs5vAVOziON0kVQC1Ki056+Z/h1TwlIXqLczHSJxKg3BWDxKada\ng96LCGipmAA3CPiHpMGCjBNgfnazYVRYDwCOViF7TQ1/QXM8ye//DK74NYEU8nxR\ngt9DZ3myLWvcjMJ/xZqie6RgBXprBZW2KE5WC1lZ8sbRF7sRQfmIYoWbuNxtIkLb\nPFBbaHXt1uYHORXnws7Df0tO4BUnl30j+nf73ZDEiczINyA9NjwCYuw1HY1xnM8j\nWsmjM1JuXluMGB6fm89bqzEBkSzo+96fxxv4GE0dlu3epwLKcf56E6d5vp8Pa0Zf\ny73nFZX3CgjrJnatmX9cgqQo7DLvd0mxOZLdycVG+qgeHmURpqW6iHfOTw3qi1r1\nkpA+w78ho4LuG470q9lhosCfuyqI/meFeWjnHBIgs4FPdvyJF8fTc/ll/cn3DZFK\nMLKXbiN34KusZ0Mlw8ylXRELSMuC3sBKHskEfBFYevl49AAHjF41mvuzNlDouVID\nHlFN0OizrhDbwfRxJgUFSig8G+5CE7shbYlMjFi5SBLNU+x10XxRA/42j0Bh13e9\nau9MR2u8zXCFEAwgF/nEJBwexqSZwDHjDpTR4DORhsszrt8K7t/BYyMtKz9+HQtC\nrV5aoSfUkyPQE12rAZn/9adyMmDkVE7dFZJb5KY5x2LBx7wuP/Q=\n=A+Z4\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-mipsel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr8ACgkQsNpg+0VL\nrxilxw//XVx7z8DBeI31/3ygqtEpme6v6SfWKWxt65nUPxYVbYm9zLnUrZlwufMH\n1cRqRGTdGQU5q4TWeDwYYIO2dX+qSowTP5PQEKy33IzY1ASB191wOdPdgVT/t4oC\n31Wq54fQAnZB8yDQcPCFEr7YptZRKzBxpU08BPKrYm02sm1OvqVhknzY6fPsh6Ji\nlfwrdae+78b0gIGTHrtYiVo6t1xccBDOZH3FMkZsUKPJlyr4NOM/GEI+3VA54Otv\ngiDtH0/vngNXGhR/gve4JBpY/pR+s+2DVoC9qRuGd7ncuNr9IKbtjpxFZWvAT68d\nKywwU7rxH/az+s/IK0E1un9e+eCREcTtsJc6tZa7usl23TC1P7a2v5t5/iT0ud5O\nCUrPTj1oIazZNCPORC0jVGJ+F++xhCepCYSoOuuPllpUOyd3wdmtknuGrQTvq7uJ\nKR93Eqk2N9G4Tnu0ylSERBDBKEJviIoZSDaXL3z2tk2tCqJbUj/g5+x3oPKN+1kI\n1xSbtV/5uK6JlU8zIJpbcu7AQFIyjkz7NSCGnAa/yT9cZ+xaBx/DeANRJjbkDMC1\nF8vejc4O5f6/FG52GHFohhUJ3mgG8TnJPLPdm7C+yk2nUnUoegvFyVexFPUU0HOU\nyIdjXm4iige048m/Et8VqnH+pbO2wdMYmpQiWMn8pliNXfWNouY=\n=LCnN\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-mipsr6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr8ACgkQsNpg+0VL\nrxgTHQ/9F+fhyRkb35aIPmZcfR+9ULr2GYlOe7fEL+kgrJVJaPeBwDayCxgUiQFt\nWQHWRT1JaPWVzUsgmJc5TQG6X1KtcHHmk+jcrVjAFkikqub+Sl/XVHBjAfpCK9+K\nxuqokXeo9WQfaBUfmncPp4BZpDc8/riArHfKBbwqEK2/u/mAQiN35m6ftpjKZbuk\nwuUvBHScUgVivBSmgFFA081iN8S7QgtaTznkCZAmZC/BXoS+W7dY2qxeNaOGYjf+\n1oDjEld7sotWwgZUKfUMbyWYOkAehtJHGMr+lahXopvjirWiMxE/kqlESzASzUbO\ncxZ/LLXSuY7KoiUd2Rw+KmmvxeBz5XJmSRdHLRF8Zpq34UtFkKqv8aq8iiwHwCk9\nFi5gr9ICI8Ufc54qHh8Z/wCgwv4+51d5Mgi2P43dZ5xNGNAv3nl6iPe43irHjzIz\n3oB7p+5c6CsLRQmrRLTT1J7fWV5SSuLNpm6MpwK1jVezpfmR0uL1NtZzJ5/CzdxK\n4U0YXJ8ModJgQZKRgIhSAJZSeqx0qWNlFywjcSDFkgkzmf8TlWNQge1hhlY8/duB\nwP935QjkWAH+7plY4XpLVm7S7+yRANGK7/Yw4Mc15ZffdBPFJQU0iOkExsvUKUbT\ngYXmNDZ/jfUjCul8h4nx65iSX+m12uybtLTFhIQfIaTXpPctWWY=\n=a4tI\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-mipsr6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr8ACgkQsNpg+0VL\nrxiwWhAAzBVIQxjaiQwEVOZrsgM1aH/nOa76bjAg1yIlGHV/N04wDHGqil/XToct\nBkk9vpO6oKphTQa0PP+5tEyZKKGr/Lac64JJ4V72emJOaYjKYjzMySx77YenkH/U\n8YrqE/VAkU1TXY/2k+yexGYtp72aLKtR/Zzb6LXo2Ry+UqRCjvvJ0ybrozB7F8Ap\nXbyQg8DGptAiQkTi/zCMvDJIkCmEJwN9Wgv+MGkhmSRxQnVxB8Zr0/OEDG8R8HsY\nPssC4T2u7GNEjQz8OUyMcjsCl2VT66aMR0YHcNsLUkqMJkqGUgITLnsBaN0wzeRG\nWABtxBw4yUM1Eq3BIE6dlb/CHZGIu9KCh6I1J6I2GNEjImoRbD+lfwXF2YEGzj+a\nN80ooo84EqRsLuslMuhMb46O/bZIKGxC8CbqucTjuF4tgRUBX9SxH5HI60z+9jUi\ndlV5c+WkftM7/Su9mtdpT6/NHDbz+uy9Rddrlk2BbftWGey88v86+NBcxSHE+wl8\n/6d1RAb6MRppogRtZiuQVceFi7O9h3sdtRkBs03dUtqBi6IAl5JrdrTIq1p1gybo\n7K6g1nXDvnm3FigsX0279/Lzfgg0ZzLD9zBxBDTg+DXo9qiW7fuMiYdFfy9ITANV\n7Cxjd+LPhMw64U1q9vh1MzuG9fv4UvdYWKuk2Fp+4WoHug9rXV4=\n=Ggdn\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-powerpc.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr8ACgkQsNpg+0VL\nrxhpiw//WVObFLj1blZODLF2aq9TF5NE6TtB3ZEQqRJm+E9dnAxM7fwmu2WPEUK9\nyfTsH80bFKK8iaX0VbTbssaD6zQl21p3ZoWCDSXnMbh3LyanbCBDrrw7lCJYUTN2\nZqoRncGIIDz3LAQytgZA2sb1BHTBXD7xWo9xXXkVB3gogCAJ2rn6Ekru+88WD1Lc\nMm8RY9EYjkIiE2v22NQJToTvoQM3h7qK6w9LY4Inc7jgfXEjJomhUGWllvhHdt8V\nFBvSC/GRbP7wWeAT999F8tbSfXfcKfRwxt/7h1pC3lOmj+tERmg3H5MlVsPiT5Bz\nBEbiZooBpUt0cFhKl+SknAOdUMggdktKUp5YvEOxXiNqtifTP3pY5ZpJfeKwbpNP\ng13nBnYXXe0B+R9cGOoA1MDESAmG51KQgxz3VqJhCtvQZZ6Up6aHBKNBciMO3udS\nnWae+/DPNPRWqxMo2yoeMz5b891z7tlRUtcrrkMYAGDiM26BzXtV8NcS6ZBmiOEG\n+PVzKoPma2SZr+yIHrRxvsNC0rTX+dOzxDx+uogT5+1ZziCimwq/2CjoV9nYl59t\nfARgekwf38eD2XJjXRBlpTjIBoRInEukKvgssY0KlMtE+5Eok1PvsvdWvV670t3E\n5zemeLlhciRqDwb+zR/aCCx4moNmYjY4/TZC6yFPmbOPGP6uc5A=\n=toBj\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-ppc64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr8ACgkQsNpg+0VL\nrxik7RAAxSJA91SLUMARACedULw2joxfNb52hpzTVCnhvh/EZ8/kI7eoZKk7MGle\nxrn1usrp6SPyuKOqSFypXARLXesUEYN6S857DHsJpUZV6lvDcSuuJ2J0zXnMNCu+\ncd1vs3VKQ+TaL7ygl8+P+B/5K9bvCDt2GQhwwHWz5eEk2Iqvsm8vnWrPmjc/pJJ5\nckl/ojVXppkrIhDrQ1uJ5Hyc5ZN3uxjS3y+0d9S0xILeUs5funMAUSYnBnKKEvhg\neRncIuOReJnRg1lOUZ5XJw5a5iz8htOkZ33wpW8UIGD70gUqDtu+RS7Rc7mdX6J4\nF1juT4OB7LRK/gjhMPzdHMJcFBp1qUekLLMk6XLEi4ty/qNXiKhSsaIk8VVFCCWx\nImrzt4JtxlbJ9ETJb9M6iIUsaUEkMYFlDGZlSNyj0/2ugmvbe/CZWFyI9OQkDck3\nFxYMmjnmt1HkTsIOjRqEDHf0HDIdzr7B6p+wqNQKMKt/wKjGSKN4yjpwrS5ruPlb\nYkK9M43pbTuTvgEcXL7D7W3rqrz0KMSDcrgh7H6YUHYSkX+juIax8WhmhR5rkUUC\nAS3hO5I8ZqmMdnvYagNBq3dHOxZu113THo8oQ8M34zJ5R3/RB1pVGDdWW6E4kzTQ\nlJLZ3B7Dp3lm/kRGVIL+7sFZ62J9qMfhN6dYUHvyLaP4BHkfPPE=\n=2in3\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-riscv64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr8ACgkQsNpg+0VL\nrxgHFBAAx63JRicBn12SzDlV8Uwx4acJMivTl/79QCfvJauZpCewOs7szIsc8rvS\n9lb0AYzIGis75FdfnSkoEVn9oLrS658j/kdF51fzsIn2F2gKG6JenFBWdX8pre8O\n/TM98uaW0JQQ9TLAaCA/zULkz9JA8W4NnmCUYdi/ULYthXw10I0CDIXOSr3fypDg\nuUa2pS1puIS4m8pkWkPlqG5PFJScBd8G/WQ5BTTA5EnQLS6V2WFu2Pc9IJgbPiQt\ncgZAx9YtFjWngfJgXagk30xp7AKJP+BKrTk/i0RtQPIG2Z0I1wHgOuysPySYBxG8\nlD/2oDDltMDq9b5O8spMa+Y/Qgjkiar4f3WSk8bW0ox1OdQefXPFCQ9LuobEyJ6s\n1SIe0LUfMJ/WwT3FS72g6rfRkd03ItvIExF6I33IR7H6v4LAR3X3F/tAYEsCL/qC\nr6H0L/EZs6Fi1s1xXJMLDtv2PCpEti7dpprYWNZhwmtfY7xtgHnLqNl9A10io88t\nCTsl94WYp8YqpYGNL74XM88jblNUHPDVzVk6Bdz6RzwdYhQgNWD42PlzPUiSuq6y\nJtEulefe5Pxg2LSpUWY+9nG8CkctfF2x/ZKgvP6rwFyLrVNnFkHhMPXgJEOnCEXo\nCiRdeh5B7JfUqwCS8LTkBjgU8Apx+79N6FaN7ef0K31IstFxW2c=\n=XkfG\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux-s390x.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr8ACgkQsNpg+0VL\nrxg2xBAAnGkQwRwRkf5c9yRtiHuhVPLePuzB3nnGWhewqPkGCAnCY/PH7oswBmvp\nxD29/jZZ/F0cXT5Y7gA4iG1YDIAT5IHK21rJTzt2yL/Hu3rytHmUZKRlt6JawKpG\na1EoEy9bxl3/1cv6zXZpOIzRpI58wctgOIcDPe/Y2J3EkJZCBF9Pk+no0zS3MhyG\npScK+NPIEzqIAGWdJ3TKFMKSxGo0A1tN5H37mFL4B3t7jixNRsI7wR65S6gKVp7v\noYTrBO07RqYEbdbREb/t3sh5CK5t4F/9itY0P2WT/AEzpvJnGmCtdLgSQmntggYM\n/UM6KIOMWs+RpCgN605z/jm09xVITaUzKXiZ1nvOPj0rUca+i372mwrMuTonQZA/\nkZCjukyk9d3B3uLgXjq6GwepBwIPdHOl6Aj8cDpD0mOauYvUIkf7fi8BeuF37+Yx\nB093FsjZSASwlVLESXAlLW6O71S17QQvo/WePJP/wrlKPyoAivQnYzUmzypFpny7\nNYTbuG/9CBcfyExksBLqElNHHkB4JcPhxhHL8uJrESSRA9YnaaXTlnGKes66tRky\nyzI9ymgueFwR4LOge4YCDoxwWU+dw34R+F1lz2jmlW5Wqa+pMTgVhC0w5FL++auG\nsyiKTsWUObZv3NjN1xz2viEh4bR1ZnqT63R2vcHLjVYdl18DRI0=\n=m5zz\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux32.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcr8ACgkQsNpg+0VL\nrxiUSw/6A5cxFQlyX0y7LjUSA8RyUuj8aGfPfLfnCvvvt19qtqHLhIouMYGggMcL\n52lCwsW89pBcpF6GIdLAjb7e2VxqiIMfP1vugf85o+99iurJQla/T/RviaAgSpCB\n03IHawFEAwvVXd1E0PpAv03yVenvxmp6Mj6pCaI2lxh8nguV0Zoby+QxFgc8/WY9\ntT12RKEMW8Ap5x+EzQVXgX2cmsKt3g62iv+5D944f1ZlqDQNs498YIojfsAuhi3r\noZd3jX9RL5XAEzNe9e+tpE9cWkRwJ4ES+l099Jvad1dOkHxIlx9P2pCDThot0ddY\n35GQ6jxdrYrXWv9uLAcaw4V/tBDRWFieUnmZKMZG7IYB6aOPRlcSQCYol4Z74Euv\n06W9jwK5qduIZ6qeD0WP+MHNuJ8cZb16S4jIAcuoTfuU8z9DAg7UXU7/kzGBXhlE\nFuDYLKaVN9BCfD77nKKJLiaSufW032Dg2H/tmVcuvHY1LwKuvppqRFnv7OInBNni\nGwvGe/TYRwj1M4oKzDtD9eTbChNcqcuBmnuHVWojsG2RTvQHk4v905LyF6EfYuBW\nMm5BgaIqMF6ZgibCwaDTIYSkQexgmPLXM5UbddZxOO05uhFGUA8oTajAmaSCT2cP\n7mRtOrXnkLWzkXPSCS+ZsoJLDrnYuqE8POTK0m3Q9HxNHexxmww=\n=ysfz\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-linux64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcsAACgkQsNpg+0VL\nrxj83g/8DAa+uDh+Fkj2nTf3jet4o0VX62Z89KzUBWtHsyPKlkxmN3qqYFwBadHG\nNZwJxyIv6MnFX5obvLF206aAsPIDeBYNYj81iM5hJZCPkQJZ1nWM6HsjABzXnHyz\nZ34B7/KFJvyTpUtU4JFdZbggoaaOdmx8LULhT9YN6t3K6gnYZg0doeMnW8EJqc/8\nNsiT4p+pHXRHRJHneSJJC8kZrYsyfPh3XPlDr3zvBqAXRk+wELVvkZYFHM+auP/x\noPkmAN2R6jeoRS6cvkm524Gjd8/5E7+GCsiesb+VkksXBEGbt8pzZuphCQp4pJRD\nDBfC7g4KoO9u+lu6/nJ25ToVDmo0QbEdiWYHqyboTtNI+eMJkWYRBmWs2u1wRKQa\nZDSF8zTd/7JA3mOiF+T3Lqwt7Yw5/QTm989lKftKgnDmlh9jE8nSBUIdp5ZUPKmh\nMAxSHS/lC7GgP/mtZHo8tK04x3jUfQVFtY1iJOVpWhCu2jVJgHPKDXCNy2um5ext\nDKnwsNWJGq24/CK4m3b27qqGqTomRmXZKopF0YjhdasBrTWwKA0wtakiQaiQqpvE\nDExLIRrCAsrCRWrzBLkmJDQ8YwlT3AMfi5JlcxP4D1mYXfscj9q2b1RRHLCl2XXx\ncW67TuFDS4wMTLsPaGlzXKctrzXTwPWw6ZxlGg05WGk04wtWRZo=\n=dwCF\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-macos-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcsAACgkQsNpg+0VL\nrxihPBAAr9jG+Whevk0q1jxTwTKAkJQjoye9C1ToAFjY/NXWSt89XD+FrT9wsMt3\n3jM413naDRmyZRiyAtGYek0t4RvySLs4iMXbna1lqet9lMxDieigF7q7iqtmjjCA\nNFy/qK8quVjaFWQcbzsCxrArRVNYYRSpYwLxhECLwvGzdILkFt8urYXIx+gpduwe\ndvfR0E4yOTVxhgBsB0uA97OTuPwbZfOzXEInLknIbOW+TE6OCDG++Bn1ol2gQpoP\nHnk94kXur/zLWb6q7gwWlM9mcF1VHetMcYPyHbTAProS8ZxvM9Waz34vGrfZDqpH\nvnee40oQ4gEdhr1VPij44EItlUJBgNxFaB0kqSIEYmX6G54fr+Yg8WTLUGbGbl9R\n46voarRhDA83qPDsn0CKzvA0vkGnaanrKR514HkfWJ/S3LiQaf2ylf+JQOEiT6+k\n0DdgmCVUYBC4M4oWbQDbWwi0tUfcLsggwBREZCWNkEU45Gj56KbSfIsLzzg4+X62\n1liZAhwxELCrHleayNczF8ZcAwgfVShId612bRiQR26RiS1jff+9ws8UR8SUZHbL\nKOhqPZX+kVvgMWdt3gxapHXZjaHt2ShHQCeQ7KEXiVHV4YHeyPB52t00HTk163V+\n+glb9U8y0UyAJWWxKr1fEt/VQruYh/+IA2y/UOwhAyPLGEqgqjQ=\n=Ai8x\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-macos-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcsAACgkQsNpg+0VL\nrxjPIxAAqOKp1eAIvkBcjHkJMHBjkstXDaFfwgYxbi0P4hrKOOz13BNUJa3PEaoJ\neFCd8H+SIUIKRfi54bouIQZ9bUwHYVFsKe6gnjZXO4uCUMzCBkj6zXvvDNGZ89R+\nKaEDY/HUQ9Ss15An77532gCWj1aEYskIS2/2JAEAOIzQHU5kwZkVRAbh7mkXyutI\n31LwxJOiRO6V8WpfkbeJYqr95p8LbT2GcgBbYwrUUUzwGRdRjr8je3OhZbQ2uN8L\nmjiuEt5QMhSr6ISsLeVJPfUURiF6Dxmk/2X77W2m4RqlYGzQ9LSJAjiyG8gR5HJn\nyi0z81PaVq50xfd8wpk/b4f5LS2Z90e2yrhfMz9fqJZdOFLApvxziVvx8UvP7EEA\nLLCnhCSPfcD+dScMIbwnZnuXJ348kxjwOT/mP7Q8y7BK8ZpW7vlqyHYLnG1lP2vb\nAoK0Ujb+6Au1oF9R7jBTTZ10QKrzG0uwAr59LRwuU/O9Fma89GSovjwuDhh3VQtW\nqMhmVyH7yXvrI1rHCSDdIDMqVXlmvL/sqpZskm0GsxvEvkoRccZkoU85SsL7TXzx\nFe1DuDOOxGxPcAAH3z9xW43mndOYqivr/+jfwJl80h1n9Mhy9b04WlzCPb2ZKySt\nIgpLOvYpcRFfuLU/P1GIW/0hu2I2nlsHvPA1Qk0khmCz/ZznSdE=\n=SuRL\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-osx-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcsAACgkQsNpg+0VL\nrxihPBAAr9jG+Whevk0q1jxTwTKAkJQjoye9C1ToAFjY/NXWSt89XD+FrT9wsMt3\n3jM413naDRmyZRiyAtGYek0t4RvySLs4iMXbna1lqet9lMxDieigF7q7iqtmjjCA\nNFy/qK8quVjaFWQcbzsCxrArRVNYYRSpYwLxhECLwvGzdILkFt8urYXIx+gpduwe\ndvfR0E4yOTVxhgBsB0uA97OTuPwbZfOzXEInLknIbOW+TE6OCDG++Bn1ol2gQpoP\nHnk94kXur/zLWb6q7gwWlM9mcF1VHetMcYPyHbTAProS8ZxvM9Waz34vGrfZDqpH\nvnee40oQ4gEdhr1VPij44EItlUJBgNxFaB0kqSIEYmX6G54fr+Yg8WTLUGbGbl9R\n46voarRhDA83qPDsn0CKzvA0vkGnaanrKR514HkfWJ/S3LiQaf2ylf+JQOEiT6+k\n0DdgmCVUYBC4M4oWbQDbWwi0tUfcLsggwBREZCWNkEU45Gj56KbSfIsLzzg4+X62\n1liZAhwxELCrHleayNczF8ZcAwgfVShId612bRiQR26RiS1jff+9ws8UR8SUZHbL\nKOhqPZX+kVvgMWdt3gxapHXZjaHt2ShHQCeQ7KEXiVHV4YHeyPB52t00HTk163V+\n+glb9U8y0UyAJWWxKr1fEt/VQruYh/+IA2y/UOwhAyPLGEqgqjQ=\n=Ai8x\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-win32.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcsAACgkQsNpg+0VL\nrxhlExAAyCOnfSnt50GJrk8AJYBQGxtWTf+S8Kvf7JhrKLojlpt6cGnr78+633jv\n0jY6+O7QK8jyHmoz3kk8eaJvqG2D9JK6zx2V1T8Z6BIFX8Hv9rQFjfukMZhSEUTc\nOoyP12SYqk7Eq7ZpV8mfKSWR9x2bgrsC4oQyyUZLogyryAQzPIeW6uZu4f8p4/bh\nrWLaNBbf5Zespsp8F863vAKwtM8YakISrJEGMlZEVvoOC8QSpThDlrDhX8rezkMc\n8mxKpGaqiQHkAB1TLz5le3iwWzB7y3k6OfcHv+uE2++b6Osvv1C7hma9DXMOOSIG\n/3V3WFjoNp6SI3jXTbCzoFTEsdUAr7FEzm5kjAoedWjkD2jvvio97xn9DnrVmi8i\nzuFzx0Bhv6KODorHKKCOphcnjwaZa1uPmN9mnt4PtWnwaldYjb8yPhPiPIkI7MXi\nmMwOHbCkQ/uPEM9toS7dzkBG102IDYkRY0GHbTJ/hMRhbkY1pahsnkpvDaO9Gz2x\nLIQdaBfksw8BP7VG8GsVHiCMRhhWExxakvuYpjLldX6QcLL6PCKKQbTxZfRfAOYT\nE0qa6JojqkZEdDMJi/NH0O2wN8s1ldTmdoBU7gmKsktnAZZHhXE4SS3vrdISeCHW\nAHBJ+pzs6D2K0iJjD5omiadt5X0LrvxHSUZTMDXuzE4ZRYKupkA=\n=qFrc\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-win64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcsAACgkQsNpg+0VL\nrxiaEw/+PytIQU+uIi0XE3cxgdyqaMBhV1OHUlLZmrWB99Q1te4R9TokQqI3kqS+\nmrchFgBOtEuhhQAdJ4sDPNiT31oBW3QA8fNDkZtSjwpwEbbllhNWTE9ULXGJjxsL\nzZTL4brK5gBfZ7H+uK6keLCiAYHU255aPEbbt3vAwDE0iZiHi58esvE3s/5RVobN\nvsda/bhQRgPGC2vIVBsjIUxRNwsXSOBK1C7SWTNea7ocQT+HuyedY5nk7JQmojvg\neeFnhF7ZW3X+tkM5scBd7jTBfmhNcEo4FYp7JttMy/H7h+2XvG013p9mPDniQEuz\n+fpp746VpOHr6XG5QdpSM1GmnRF3ZVKTo4cbn5GfLM4i9Y35HO5GA5adpfUa6G45\nc7Ep3KqANaRySCSLLNcnSUg+4p366eUhUo87KPN9L+QOcXwybVJJ9iQsqzRZZmt1\nEfsONLy5kTF7GjwFHML4Pb7ZiTjxJRIL3aMsbc7m9gYY/f6CKtfb2/jI1G/SjhQx\nT9pTLEjzL73iMUmgxx9L5VAG2qHnjkBxqCpMf7X6HCV+jTJmy72QE191KKmkYxZB\npYkoihejFU3G/gdUYrqgJG2acbL6pqPX+Qc+CUaehCi+Y7z+GNU7o15j8L1byKpp\nNO2CPm/otvDk27pRasChkUwy3xxnkyxxB6OxAfYn28y44IcEVJE=\n=ZR81\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-windows-amd64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcsAACgkQsNpg+0VL\nrxiaEw/+PytIQU+uIi0XE3cxgdyqaMBhV1OHUlLZmrWB99Q1te4R9TokQqI3kqS+\nmrchFgBOtEuhhQAdJ4sDPNiT31oBW3QA8fNDkZtSjwpwEbbllhNWTE9ULXGJjxsL\nzZTL4brK5gBfZ7H+uK6keLCiAYHU255aPEbbt3vAwDE0iZiHi58esvE3s/5RVobN\nvsda/bhQRgPGC2vIVBsjIUxRNwsXSOBK1C7SWTNea7ocQT+HuyedY5nk7JQmojvg\neeFnhF7ZW3X+tkM5scBd7jTBfmhNcEo4FYp7JttMy/H7h+2XvG013p9mPDniQEuz\n+fpp746VpOHr6XG5QdpSM1GmnRF3ZVKTo4cbn5GfLM4i9Y35HO5GA5adpfUa6G45\nc7Ep3KqANaRySCSLLNcnSUg+4p366eUhUo87KPN9L+QOcXwybVJJ9iQsqzRZZmt1\nEfsONLy5kTF7GjwFHML4Pb7ZiTjxJRIL3aMsbc7m9gYY/f6CKtfb2/jI1G/SjhQx\nT9pTLEjzL73iMUmgxx9L5VAG2qHnjkBxqCpMf7X6HCV+jTJmy72QE191KKmkYxZB\npYkoihejFU3G/gdUYrqgJG2acbL6pqPX+Qc+CUaehCi+Y7z+GNU7o15j8L1byKpp\nNO2CPm/otvDk27pRasChkUwy3xxnkyxxB6OxAfYn28y44IcEVJE=\n=ZR81\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/jq-windows-i386.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcsAACgkQsNpg+0VL\nrxhlExAAyCOnfSnt50GJrk8AJYBQGxtWTf+S8Kvf7JhrKLojlpt6cGnr78+633jv\n0jY6+O7QK8jyHmoz3kk8eaJvqG2D9JK6zx2V1T8Z6BIFX8Hv9rQFjfukMZhSEUTc\nOoyP12SYqk7Eq7ZpV8mfKSWR9x2bgrsC4oQyyUZLogyryAQzPIeW6uZu4f8p4/bh\nrWLaNBbf5Zespsp8F863vAKwtM8YakISrJEGMlZEVvoOC8QSpThDlrDhX8rezkMc\n8mxKpGaqiQHkAB1TLz5le3iwWzB7y3k6OfcHv+uE2++b6Osvv1C7hma9DXMOOSIG\n/3V3WFjoNp6SI3jXTbCzoFTEsdUAr7FEzm5kjAoedWjkD2jvvio97xn9DnrVmi8i\nzuFzx0Bhv6KODorHKKCOphcnjwaZa1uPmN9mnt4PtWnwaldYjb8yPhPiPIkI7MXi\nmMwOHbCkQ/uPEM9toS7dzkBG102IDYkRY0GHbTJ/hMRhbkY1pahsnkpvDaO9Gz2x\nLIQdaBfksw8BP7VG8GsVHiCMRhhWExxakvuYpjLldX6QcLL6PCKKQbTxZfRfAOYT\nE0qa6JojqkZEdDMJi/NH0O2wN8s1ldTmdoBU7gmKsktnAZZHhXE4SS3vrdISeCHW\nAHBJ+pzs6D2K0iJjD5omiadt5X0LrvxHSUZTMDXuzE4ZRYKupkA=\n=qFrc\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7/sha256sum.txt",
    "content": "402a0d6975d946e6f4e484d1a84320414a0ff8eb6cf49d2c11d144d4d344db62  jq-1.7.tar.gz\nea21e5402983d0e351f37fee72c2d456192c734ff7835e504d3d079dbf483a4a  jq-1.7.zip\n2f312b9587b1c1eddf3a53f9a0b7d276b9b7b94576c85bda22808ca950569716  jq-linux-amd64\nab57ee39075db4a23f899d396ecef3c6e58f6aada35bfee472468210bd126940  jq-linux-arm64\n5f9129fffb49ff28a3f66a337dcff83a846146ad16a52784c1bcc3e5f26f3173  jq-linux-armel\ndd9786221a3a0f250ed227706b7300a69579529ac4a059c874c35a9efead68b1  jq-linux-armhf\n6e8f12833541c5cff94c556d72c12585821fb68bcf09acef56c854d107fd5a6e  jq-linux-i386\n1a2a5f3706bf1d192577c34e260ff1550c24d8a93d2aabb64e46c29acd6847a1  jq-linux-mips\n7b344267ba082af3b585ba552c0597a15cc76eca682a0cce4324e947f1cb078c  jq-linux-mips64\n3fb0c8890d4c07a22e47d3c794aa019df72880a5b84dcd2c2d2cf95eb16dc837  jq-linux-mips64el\nf4a06ca04d946f736f3754bc9a89cbfea79fbccc82b731a7816554f242357cd4  jq-linux-mips64r6\n08015dd24bf546285881a423d582accc0d653b61aa9b99a1399e1d2f25308d57  jq-linux-mips64r6el\n22dfcbd361c7fb672b6cb7e6aa47fdb73ca54ae27fa9a0127e291a80ec2e64e7  jq-linux-mipsel\n319253ef37d3df187057f6cc99803bd03f234dbaf575efd74d1542ce800ebd6e  jq-linux-mipsr6\nbadb7001ba7e4b9f13a95d65f150d35489904381a3cab415459d0e7e7b788ec9  jq-linux-mipsr6el\n3f7b76dc415ebae4208bca4d031cd91362c12f302c56c2de07379295502d6fe8  jq-linux-powerpc\n2157b08ad830c013346ee70edabcfb0a21bbd62d2c470423d1aa636ddd51764f  jq-linux-ppc64el\nae5f88513882250066e5773e7dff5b54e78b28493b669e7e4d29352339a204d5  jq-linux-riscv64\n60fee34cc93b29905e2f27b713bf95709b97df5845b64cd1541bee461eb0bf81  jq-linux-s390x\n4b4568fb5c6cbb8f1a8f640ff601c6d2bbecf9fa8f2cf796c7482e7054a01c41  jq-macos-amd64\nb8d313fd4f3bd8a0b338b9ddd1c006fccf9312dc609a20d2d6e4bad964aa99f9  jq-macos-arm64\n2e9cc54d0a5d098e2007decec1dbb3c555ca2f5aabded7aec907fe0ffe401aab  jq-windows-amd64.exe\n9500d0300e28a930ab3430a101ca940038b8e82ca441f5c9a1fddaa9d1b770df  jq-windows-i386.exe\n"
  },
  {
    "path": "sig/v1.7.1/jq-1.7.1.tar.gz.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd4ACgkQsNpg+0VL\nrxhEhQ//Y2Eeo5cOdVdpd1TXFAKNuihry0Y6l9OcZy41yysHfAj6iEhzjuIMeCBO\nKtoZU354/5FH0Ndevk+gpPoU96T4qREsrZlDyjieXgkCucYG+oNpW4k497DPX+g+\nGjEUtOVtMh7sCHx6CBDdTKKzhTZA/Bk2IexKGr66wKo+8eF+GQF2ZwZ+sgd78DYm\nCBqlh9FJhAQVzCCrK1CnmAFct+N5k1oasFKjUPxdzS5wj4XetWWfj1rFHaexxC+n\nr5TCvq9YepiK2IgTQO+zo6bzbiIliRME3Jj9+C7fLR8wqpsWsGpfx+HY8Ie6OAiQ\n161FyzQIk9U2MuN7rGTgyRkNLO/Zd9mBZZkhMgVEC8sFOUQJhey/Pk7ClwsJYppU\ntSVKrt4oO/URozk1xhGhaZAGw0vKCLLCDqjpKXrPEUTR5zqQjVnqjT4oBESI5Lvr\n/zG8Mw0ontK48D3cKNxuKzzUII1SStV+vd3vBXAglvB9/JTLgJlmiLoMGrnq9L4V\nKOMD852i8QFabFo/CsRdA2oh3yp3q7Fac+qu7D9fJMJtsCY7ge+q49mc4Tc+BBAd\n7kkZ3OBZtTaUzE8hdAzrJTiXm9DprqtSA75UJ9Yl5uDYux4V7LVkBTslo6sbrYfR\nyEFIv6yULElJPwkGunooAwCMhJ9tb4r1JUvfJYSYAa+jt9i20Vs=\n=BKS6\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-1.7.1.zip.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd4ACgkQsNpg+0VL\nrxjSxxAAxez+Ag1zwobaMD0QyplI8GgXNmX0JaSOfHJjp6zC9qxEpjNIDslrINsY\nJZqSyOIc9Wt/gyVGQNlSuI2Xnd859Z6PhftQ96KFKxkUbWmIUJErIomL91nq1mPV\nprI5yVcs18xVI1WVZSlibx5G8HUwR2ZgNb6VDLvhtqJMjD2HPjjMcKUOdUbgF4U1\nv+XMKaztiBV30/nDrLjJRq6Mwq+qVIn+FAyPP8hUvTDnNwhFmRIEofgKTMSUToMN\neAgmNLwlBXiVO5iVJJVmQaGG6VKA73iCk5DTxSDaFj2o4yik5jVsuMincu+eVpqw\nGEqR+sUkJ1iSJuGRXGzJtakp5uOS7g9bdRQa8EbXFDm1AX6bgE/kfvWs8auv3+Cy\nN/YIedUna8UfZdltjJDdFDOPYd89HYkAUmL1OoQguOsM5gYL5wFGnNwxnIj50guH\n+8mjT0gphhuBKygf8qZxOyK3NFr6y6/rhFkrtHTIvAgWzmjSqFTWcq+8m99RRDbq\nV5OB2MSJeT1cp0LBtVTzP1zrXY6gQ0hNOorrxirzAEERd3wXBgqlgCQZ+tH1Es8D\nVGsbQGjal5sIFxtA00D4l50uPbfWnXBW4lbC4/yBLvA6+A2MC9WSkb0tL2Grkvks\n4nIyW40kSaV8a0WvQk07567XDnJwZLJTATcMqtYu7RWiefCq/UE=\n=3DP0\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd4ACgkQsNpg+0VL\nrxiHhw//TBEUiVj7hRN2sgAoot98X+iLpFY/mbChem01klE7FE/5GQ3rCuAuIxJB\nMjzfTb36yrQeeqH8xrHQtsjyyMcZ0GLJjkQxusrLtQ+xzfyRESFfVCXHialsmrqI\n0OtI/L3y7ERKu09Iqo3ijeCa3RNAjZx2fQh/WOKB+mboX0bG8ZG8G+rwrqGazhix\ncdimaTcuONJ+87jUsxRDgP68LBKZL4w1h4iHl0GhGrc7rHAvDglmKeLfO/66qnMu\nFkZeyTmL4pVgsgQ2t2aEgTvLFKDqJUtUiEqUUmqwE+dn02/+nLLN3aCo7sw7zLjH\n2k/7P7VDV7oZsrr2JQdshWSlpMjx3mxeLKuED5WM8fXwKUvktBlGPvlP0VmcG5CB\n4eeAycj/iv+eSxt5HBYU5FtzbOtNWwrtt14AbN4RqFVaVGH2y/avjlPUKbA8Toz5\nbnZ0rrC5IVD19tP3m4DETepCGJKis611myN2hJ+qCgm61UsBTttjx6zafNOpo2jb\nxl7TPpEfmIIGA7hu8y12rdOc/30RaTtTFxwa2k8oy0ma1IrP9A9k2Hy1AuOjLRal\nkRHE3H6PuYU+n6TcP8XgoCJtL913/M9iH5T6EVm8gGFJxJA3E8s7Ybv+Qc6UGk8r\n2fF+WoKVyc6hdsasHS+VByPiuYdNWhts6jIiGGBybfb4GFhwFbE=\n=r9zR\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIyBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd4ACgkQsNpg+0VL\nrxi9PQ/3UjtaLAq4pQUQt1NeripPHXHyIvmy0US03V9jh23l4zjJlnysfjm1GjmR\n8HzSlpdofXdsIdomoUGx/QeheJMA/jUf4Re53qM89Uae5L0t9FoXP1XuvdFc6xKH\n+F06AyT5qQHrM9RFkTk/XUQquWR2ILfY0hPE6F+uYpRjoXqDLIIfTXLWGZIAxxO9\njvT0YS0z6K2pM0ourhD5K+Co+PE9eajhPa7AyZm7NAciLNA5q4OzUqOva4VK1r01\nwUzy68w8s5mOTUt4iATpgfn9aMcRloG6COJZd/CVeZRGQzNTjsstbXKlFzcx2G79\nIHNgDnXFF+Kh4lG645TuboPFRp1xZlG7upKU09bM2rHDRZTO0nzHsOo0sGJY98ot\nKW3HtrHzwTftlsg9m4F9qVVqPIdjcu/ap3okEo9ADe4QJmc1VIq8XxVlXvhw6PnZ\nuvbkJbTGiHAn/Mrh2+A586j4/YTZSSej0TRnx5vreMg8YswEy+rw5oUsHaYpswKG\noBYm2FPRhPFE+L3OyoR19h05N2RcBkuKRU80hLi7a73e/jX9N/5NfkOOiNV0p6pz\nGjJi/pWV9t1Tmr4l3kcn7SkViLr+P+bNY7XAhaOQNgHlKGjPjeT4xbvOQitCheyq\nvqp7sIDn1XrcEG5CsliMmC2sjYIB6e03QmPYSj5dyJ1eql+lXQ==\n=388h\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-armel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd4ACgkQsNpg+0VL\nrxh9bA//feLBpnr8Qi62Jy4q2DHyzys9x7etjLF/eMG1ZoQoWXhQxYu7eRwabWhs\nzdDOzLlpM7Xtv7yvYeigIP+cUlkhxeaak1D3Xwyj1/2Yf/iufhbDOnKekHglGnuo\nNCAuUhjGsCFcpL75Gbb+IcSUuPaB36mB/S6C/EeVbGmArvA4lpo7KCYTg+05FyQC\n8/lcnmNHVu32rJ22ojk+z9nZORRUFpIHIK2Pk77Vui+JM0M3nv2EDu3oXDZLRMia\nL7bUyP4GgTGlXHSIws+RVRiXlk/UMAJBptBi+vxhAWTrVmfcLjzYqAjFBf5AB4uu\n7IVr3VcW/07UJ1Mmn6W03MgZtnvwCqgLRrmTiZDxu++WLDyQrpL3kuffg81cvD8f\nsGhv+AROwOo1V5gUoYVRA/kP16ph5Zhh+6HMJt7049yKpkAkZQes4Q7fVpGVapVm\n+mA3FCrIIrzumJCdb6J6arYnZHib+VG/vDnjRafR6HNn9R/Xl6aWuYcSVUlPmJp1\nSJbzeFJEUFbv+TsutQLmkClGR91nOnFiUsyJZtASKjdyBRzNbWZeBiwQCRv7ckPU\n5OoQFtEFXuMOY5HzPI/dI5CIXCXAMKJON0aDupNmNQ4EPDtEkRjnWIdy+M5OaJoE\nWySfSwHalmNuABjGhgdUZVROqs0qbSGte1XzoNkVp36oLvksP/8=\n=7S87\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-armhf.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd8ACgkQsNpg+0VL\nrxgZDBAAioN1WXgi3onDx6SdbVaUnNp6C1BifwXXI2tQFFR5fAYfsjVxcZmM/kGV\nU85ITOs9tduggML2ZXWeNBiJcyuXHFA+BadvjDUgQWK/ZYInpaGMzdBs/tO/nnRR\nuMLuXbcPMiUmUIplxFelAUsjXkZrhomyRnCrIHB1IKcE0xYY/W/bWKzbUnx92jp7\nw6qq7amivKtONyvoiN17NlWXhKkRr+ylwAm88mwKK6xkPVgN2no0fXJUVrhtA4lW\nyrC3Ff8Xw3XeBHvKy2WFoLVsZlOg8l8dYdR+vMct43D9p9v7rKPqGmbjKvdOC4jt\nJf5tQ35lX2Up+/z06anIa0yoW9ywEiUNrmxNU9c11/VdoBRVX4MYz9UygAQDozje\n1exr6hUv9H16+A7gsbmptRxzrJsvAGDaJEG45is3eSFtBoX63FkuDRw87DpEZwDT\n/ojNrbu4KsYIHMXqZLNyfDPCSGIARSMxkyey8M28sw/AWAZnTEfusKcRpn1zYxjX\nTUSWwPS+NLJFGQ43Re0FmxZsX1aNXfT5gia2WUm3IyxLgyyj79O6pTa3y/GbBXN8\n2C4hiVPnrByvhLEq5WcgHDIYVYdwxTNR4YG6bYwkh1oCLedtkKwniKNGH/7yASuX\ncJvJQnwp/2oCNqeYV8heOhZlwIRCC7rZQbUkgC5uAZ/Xx2FTYGo=\n=KM7S\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-i386.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd8ACgkQsNpg+0VL\nrxiUfg//RIvFDrv+ie8dzd3P8DEBxQA1A3Z49czZcK+LwXmy2PJUivJgvnOXv/8k\nLnYXnURMtu9NwtpYXf1QD4Jz4q7I6X0LInaODYvGAV47boscSO287+xXVhulm6dN\nu0xLsuc6Mt/TikdWx3Q9WSOkB+1ZsbHFQ289S4Xp0zSQ1F4mpfWqBfEPqVaJPL1M\nPGr7j8IlWJ2GvVSf01t1aeHc+ijYZHdDm2YcHJ6vxbeHrqwFGXiTpllvauRkCj2o\nJgNVK2ilwKg3wUUBJXeAUxhaqoMmhX/6OhnolFBxkF25ir4jI0rzLAfr65Sfciyq\nYz6dI7c1po04D9HA6j3QcyLI32QRUKa+nUMuNMf+XrP/jC0rsnOM+l04YneNGnIK\nRaBQqQN9J1NhTFClka+o6PcSaAMxypGbWNDQ4KTyKiXId5iG4Csq2RXEn+mLMDOH\nu5mlZp4ERp1xzSZAL6E0QxVatNCnB7wIZWHAh7bpNnt3tgvF7KCjLKcl6E3PLY7j\niRKEDdrDhiV6hiniHPQk4dqYNxN4/E60vy4zdDNG/tHyyKHIjZsBUosqIAXRALia\n3WsXu6Qka0X9t1OO8kznFo2UUhFS7x0NGaNTcOBCleP81JIfdpF50UD2AEEWwhMV\n89yyN51bz2v9pumebu2NrhE94jLmOgEOQaUe5BzbwYLQfzE7jJ4=\n=y+Wi\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-mips.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd8ACgkQsNpg+0VL\nrxgcGRAAwEp2asToQT7ejK/dxWJ9RnWVT6i9O4HHA+77WU/8bp4qNbXKYOkmAVKl\nPyiFQxkJPq/fezEmRo4nURinHJiOnWRnznFeqhk5iIT3D4lubVwpQmVmJQvgamsD\nhS0YmSKgfG/4Ub43qug57uqw7F89foDGq6UastyDT2/z3emZxvT6gpMz1CuZji12\nuZFHnK0JJMpK9a4yrs8quJe9K+lyQg8BLT2Ee/UX9TeqhdR5arYKNEWGtzSD0pDE\nFCDY+QgWxSIlfyGTM5dwOL/Xo4t93z9cDADb+d2q+4bIfUK+JoUT+hACDJYm5i9w\nM+FP9lKk5d7w3wkOoWKMnKdRVnCm/BMpeRHUhXct9QHGtAQlM8X1S2wgMeh3RSL4\nuJxhb9n/jpVrCafValXCYKHISa00GfJFf35arZ50zrfrj+NSVa92fyvC/SNR7RXQ\nKK/e/MAUa82nU2DVJb5VO+GUMtWXK9zQZgJ64O4p+LTcV6hm55e/h11BkLeVGI5u\nC7PySgMttXbUVny8zXOCVtKw/yx4Kd9PKZUNhBkTocxPe3eQklFcdQLsrEEF+IIS\npEXFpXDMzG0opctSMpp03rIQDYj3INScaQ2HxsetBwDqI2CkJH87s4V8dCVcpWU8\nUQzp/emVyg8b1nkPyc91vn7rAiN19BRkYX3/VihPk2StcQbUZ84=\n=/4sS\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-mips64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd8ACgkQsNpg+0VL\nrxgCFw//Rsxw9x76y+iOqgoDYsBmDCH4v40OjljBtDyC66zOwU9vR95CWhM6iTr3\ndHsIqScDeAtMrY3aN1aOoPjC7JwYc3HljFNIB6m1uBAuRtaEFXfV+/z9rYK4vTFg\nkw/M7m+gKJY3AF3fz/W6i8oug211e2S3eeZeOUW2ISllrCc3LHCkLuGoqIlWty2v\nBQvvoEtYJRZ02KKTIZwWIh5ku+IFrTkc5+hxB9PGcEHS4qUnfhW0cRMP9/RwoBa7\n7HxjXVHG6LNlUXASP+d+CtOrRtxlDwaGKZzYq2pzmBzm73wP7RBUrmxuKL3U+U3l\np4cnKHBIvDdE/a+1QOLhL6zHZAE4WFfpKFu8cyyDhGOI5mxXPs7xDCPnF5GATETv\nWJ3BCPoWrfDGZpyTzonzx2XWDnIlc9weQ4aKKJ7Gbwb8Y3hHfSNgQlcIG9txgdFt\nds5X/ouwcRzzB3zrGTk6Jvwpf+rhdmHnRiuzkpp4SefIQAvigiQ5VRhjxGKjah+b\n43M+2wyc6539uV1oUbKGMQo11tWhyTSMYfUoJ9F5iH1za30xGQsz+TmrPZvwJdOI\neOMifiamfYAyQnB/zmSkgiK8F7uOjJt23EB/F9ydJ1zgPC+fzzgwsIWKL5Nymgsu\nvobkSfQNdA131IUwDyCMLBgJgLi5nZ2YwhdFoPGf7NtISzk8FRU=\n=qIDo\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-mips64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd8ACgkQsNpg+0VL\nrxh5cA//c4nMQ2cFJWWbiZ8EWLZAtpzoXYEfjsHwKjT58xXs5WO2n/DNgr2jCuWw\nfZaqv1rav/aRXX9FPLaW+uYExY98axq9XxyCAGVmqaJyorXExJKOFzxeIH5ypZkt\naWFeR3SPv4wTxW99bXy5Ut537l01quKPo2xUx+agdxPYGCl02HtOdFOyshNsbjxD\n4LNDusboIY48shNRjeOIoX2174M1o07Bg3Kpvp4B8a3y/I9wZfLHGYYAcbXJR0uN\n0Ey9ucslel7m70ibaHaTlr8Epzn7YFl5/XI4vJF8Dl68z1M9WkHRbiO8pSor5ckv\nuhXPdrbs16pyn/Qo/8/PFnA/jdTadaMzI4NuvVcvOp8YLFbe3UGAqlRjTpEs0cDg\nF/nfKF+PFfL1sb9zYkhjgCiRerhpGzdO96IuP7nzF78zEzfFT4/c2C/SBaLpwdN8\nax8YwsU9FRmu9Dp/aMy3y9H2QWmCz/vmBfwUGqD4qzNJesmk9J7HHgZqJ5e8SjdD\nnA+UlL9eVbXBJU2aD3x3+fX6L06irCR6JDeP/FiL+/25FZ8X4PZnL4LBTS3Ggh0S\n4CPT7IUp7dsNvdQoKH8HlpUuBskzIfnZpwP7dumz76s3hxPHZEdvAWQGcEtSe/BW\nQvWSEqok9wTePG4P2n0AYKOmvUDpQPzhWPigiPIU9PRXpXBng1o=\n=wQpv\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-mips64r6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd8ACgkQsNpg+0VL\nrxhB7g//UwWwAWCzjIIHrjCCzw0odLyEFWklrXhIvfwclCw5c9MQemR/qfuwzAQE\n+oRMN+DEs33SFRNokkGbhJc16BMqEX6l1msHFlqHc/HBX86HLwLmeEIwzVZEhWjp\nLsa4HeBaXEZmLkxnT8P9sNvPmVbFUb/kdIFd8qXPEmMYfIZ04tUjGIL2iVLBhjgU\nrzjaIdadmi3VRMs1HF4lbu6BqB6XNX4F8E1mA0NJ8cRo+5La5sA8hUVIxXPv30E0\nndEOnZYx1LN5bXAv6dwZrjD1LIskWzY19ep898jM/2/8KpS7oYP+w7E6QKWq6aL+\nE2pgjEAXSfQ/0HFCh89+b5m6TL2H2rmKhflHbZRgVuLi1k9CP85dIV4rpgpIw52I\njSPws7QkdVZhtWS/wDdknFZkyloWwLpxoCBW87EfjAfjDGJqQmNAhriDFJhsJGih\nTwhwASvmCpaJksizoWxJriTwcLCbofyN6qtjmU4+TD2/PJ6UeO6IsL+Z0vdcxttn\nQujEKBnTD1jCU+PrTOdc99knflr8Hn88O7wD9Bem8gMWGz97U8uwmb/NuOFylvp+\n4jAWrokM+s56naBkgtFyGaRlLv1Gh/s7NhmiYALnZr6SRNSieRacLyPvu6NBkx+6\nmvB4261OqZal0D66dGZf6l8OFOrghr8kXu9+45BQZK7UxPfAwxA=\n=sQMd\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-mips64r6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd8ACgkQsNpg+0VL\nrxi3fQ/+OFDEzY2396qJS9gK7Grxs6Ul0/wM7KZIFftzcc6cVShooMJTYWwiYlEh\nAwZsi4pqI/47zhQZKhjRebkw4okLmKX8tOrjyBC33tKRu/MfxxHQW73I96JvOfxF\nknO5OMB/XBHSH0H3g0IRHqFzv/y6P2spUZhY8/VR/Bzz5SfSID20IYYDACbSAUCA\nonsJcq7fqNK+ygfthB50nKj99WOWFar5SED6bn/uPgvxBD0JnF9eTC9IT7EVjNZI\nVtivR3nFQHuSUgFDJyWhKYFlpzRRij9KcPdsRSlRxFNZpVqOopI3lNJ2y/AHAeHh\nFHNQ6LVKBm5uJCyXttAgXTglTm97qKZaRkuHjRyAuiCDlGaKfZJYwMff6/e/YaXO\n0rMu0k1ArXUNPOGnOnGequAltDbu4vqJcKbhF/EPVA36t65B3Piyh4P8tQMWWMg/\nRFD41ZSARphbRct+BAXCQijwDt2M/jFhwjCPcD+UKYR4k0RkRfkDMQ+XCqmP/+5G\nb14+6OKk9yULXBrWlVPbT+rRoVas/a88P/R/l96FRc9KtSq8SbVJhuiwiSf/Q8P/\nOqqu9qY5pOWPdfndpAmaqD+wR1LCVT8AZvLA/cIX2Vr8urMJIgnf+tSq25UX6wYH\nZMwiUoZAFUyZVGh4AB6R9M+wiz2HByHbX87OFZxuoPRK+etpX4M=\n=RPjm\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-mipsel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcd8ACgkQsNpg+0VL\nrxjp/hAAgwlPF0DYTZPquduWvTeUDBT5lz3uQvibB7lGQ74GlHEspyC63Sd1nXi9\npfCSwIEkUgpRbdkDhNPZbDa7cInO1VFKCZnjgWdeJAIaTRYuFcPg5Uik8lhg9Uu+\nAGFrR1atjX3tePhcA3NjbZUKNOneQgibBoqJX199UxF6Q0o1O1EuZG5KVZbGb1up\nalQ2+iB78qLKGUmqwE4q01S0XxlSTMqtTKFjvRWNKJb90ZwQ3hdwIHpduEMgQ2nU\nVjz/6w0nGRXpw4+zVKQt7wJfbUKWsoKlElmrBw5otXoAmhff0ZltGR1d+50xZ7Yg\nNQecoVl84BhkChEIuUrYeH4XlRle01SZvtJJvroinrGEyeNuouVITq1+zftTmRbE\nFLAqabLWc+ChK9uQHo7DVg6GELKZbVcT+h0MrI4PBo0upjON/P1SqRxLEm44H7ME\nhuG1a88rCLa0b6qz8U331JuJhIch3Le2KA3HYDQycYoF+J+juPfyAsRGPdi1IASh\nImO0i1rotRlZP24UG8rAIKIqfBjUMKsltg8mVJ+QYikrFn9oQzGNxwMAH8M17hXY\nSNSev+mRr8u7zNvfHnCWRbjOiI664gMpllLhDspTM6PDzEuafKrlLpBZF4Q/ymht\nUa8olKOn1/K4E8ZcRl5ZrSJIP3E5p63reyVE21WOaBMHd/cyV3w=\n=yLDy\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-mipsr6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceAACgkQsNpg+0VL\nrxiWKg//TpJChosdrGdCiEFohHTNoHMIBvF1C25ohMTLRbBsgBPYS4dP/YaDWeT3\ngjc1lMn/JYFj7lqxAukS4aA8H4lSkwltXG25oE4mZxDfwCl1cYZ4A1480Ee1Ubc1\nt/6ypGc7VotiAxRCywRDd2h6Cb80RUczy1IyWXhS9OMbzBACUwYJhBKXdfWtxKGU\n1SwR3oxLUMrKkKSyXwy/5+bjSX+E1ZmJFcUI5VN8kwERv/3v/1go0oqxeLDagM/z\nvtmcyvMdMEuzdIROtfCSr+CcBSh4Vy8bNrJiPD1needlE+5pgNL238P+zPuqRl0H\nEsYFrUod052zoHWwaHOUN3tknaFKzTjN+1UmRRwV8go+bJd4XxIwB/g+MsB95Ewe\njbVyOWuOcMm2zWYSFSMeL3m78D3uHmHsFfnaeV3y6bjUnM5dQLQbt+N0kUiW7tzJ\n1tNc964lUeGJcHMBUSNbOlZDHlxPmfWsNufFxCxAr/D1Pm8zk/DPNWeC6HGGWdB0\n4rFeZFmvSAPQPdN0ChXYH50vzS4mQgP6jgrXsNo3JuHOK6bl3nUO1QllwOsgiCKl\nZMBB/iuZWwcMFAJSundeuEvPyE0Q78GmlxbOB6UWMAH9Q1Q5fMTGW5YAy4WvHhoa\nbTeZOZ9CSzb3hgxxO+mujrSe0ucaUChPeghaLUJVly43Jc1xLh8=\n=yC09\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-mipsr6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceAACgkQsNpg+0VL\nrxgpxQ//R+95Bn2kKcghpgJnrsT2DXFwg6pq8+fB5ikhjfRPps79QLtPdsS62I1o\nf8chDHA82IBPh21VDHo2l4Y5WeGmvRvidH+IQQ+SE9zoIG51quEWUX+slYWvTcV/\nlhcxQz0Z9pFSGy/+FAGUJX8BGLiyB6yKyHco/44F9vBNCL3WLRqEZsXI9E1yswcV\nwmERlOdQA6uNhTqdOKGfYtK9BZqODYosBWgE+FDZbqyYM58aBjTWcMBvtsuXDfAm\nnI5bG5umdtOjSeLclhEoQInD3971XI9sbWQRTh7gMwsZ1CKpXvR5b/+p78nhPbha\nYxk6x8smJ6WBSQ6X5yc/ZH4dHuYObBtbpiIHSCoVNbwzI7rQUng9fmAcrwcLDmlH\n+MEJzxXQ1bB2rqPSlf5TE/cwcthWNAPggwPMjdC3++OswzQ5DjtG9au+MgesX7nu\nrDYxnDS61ZPn34lDqgLjmYXNhZ6LNRHNu1QxBwd6e6adBfkygOB/FOnvVxcTMgTd\nGg8Y27UUe3iSizpCIiKTAkquM/gbFVVTze1vDswkFii6CkTkIztm9D3v4gWR61PH\nIQd+4E8yeY5OL2xggME0yg/0j4lzz++wze4XaQo1E3fNQcpYE/WaQuJmykDpsCnh\nhfkOmEd+Q8Ver3woit7RpXQO8uGrU1OW2dRDhQpYj/XZ2wF0sgg=\n=NopQ\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-powerpc.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceAACgkQsNpg+0VL\nrxiXVw/9F2CgcLQKF74V3KEOrg0cn6YjAIszrgTRGULbTye9jiKHoieS+Yo19ucB\ntp3iDjttP0a6jPr7jfPBc/I6ae+sjdQ6rDflJbzY+8ezFjtpCZhyeNz3cByzCsMS\naqojhS2IL1BB/ux+DpjUVecr5z1XXPJV/R+VYnKyN0CTrp8mh3MR6CjEmHGwuoJV\nVGFJe/oMMC+C2eS+Qn9yxuPAyotnVuhmlRsvKO5+5ec5yFnIJY2rF/s9Bss5cwyK\ntSB6EoRMND0uJSGtDfsHbgiJQTiHXTeFluvwyJQvFUAaThE4BPdgbfwN+XAVI+nm\nXAPVvg1vwgmzr2GHTJu+N8liRSVdzgHTYQj5RiAJEOjZEPjNRdHSU+Dd9PNTp4T2\nlcuavOOja+4bXWz9EL7vgeFcD+giUIW7QG3CYlL+TAWrxOLa5ZVwEgDc4zW6qZPR\nZ+O5ppOLdusDXt0U7uNiSeLrw+UiuFtMBes80uZqvmBI4AvuUjRzERISKlrT9b2n\n6/bD+IcwdigdRdnLQHXXRbnjFo35TajDptgdPMnG+l3LDIP8NYYtRWgHavYoBR0X\ntRcTSZF3QdKPSVzYwQ7uK1P+TFdsHqXtWKaHzUyhaOlRLmSjl3yCPVbRIwnLYIgs\nhSTJhsFhDo35w+/zoCm7IDgCf/ZHnRp/zgc3HpSHjWgWGPKD1ps=\n=FQz0\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-ppc64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceAACgkQsNpg+0VL\nrxjAaw/9HtCptIOmxpfbz29e1eqt1MW5yt2kRNZ+Pl/Xw1SILvhMtwHKCwrJKSrI\nyqOY7wQkfptemmReTN1xV+lNwjfc5l6GHQQpX5kzHjSFk87Cqo76ji2k7riQJ1FS\nRTy2i0cXkOW0IgHLIV/mdm7Yc/6Cay0xOzx2zr7C/azxNpVn2/3PXxkySWhfNUAo\n6T7K6tmRmUT6Gp9Q28LZIVJcsr4sw9TXlCvfe99G4jFgLPuqP4J0p6EzuZkgZOzD\n8brmWEo/fszjnD6Xdagb0UCZDW4FumcRwptS2uV9fu39BOIIzTlGJj5cQ08zsQlO\n2xRvwuOQzAyv1CzGBIIh1c36T0zkL+I8ATvBS6FFjMSLBBp8bDXtDKad2qrZHASi\nfML1pbscqenGkHEuLUer0kwcJ3ndi3WVNgErqPTmLB2g8TMCS4pbkaHy1StTnxsn\nNQO9fMBgF9Df6PyaPi7xfmGlBEJiW9/CYckltsoTEaWnpChkZGPiVgKcvh6W2amf\nY/evImn7NRrV/NE6NXzMnxCJABs9ozmoEgQWrqKEKQJ0nXGUakeDk0FTTFiQxVa9\n5NV7s4ISJOI4qDevYnS/8jDtjEe41l3yyL50BVmwnX+63rWXwU9R+VBeWgUKXMWy\npRYsZ9tNneL3GXoy4ERYZ8C8XFTE25P+qH8MyT5M4yaA0AJFZjM=\n=H6MW\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-riscv64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceAACgkQsNpg+0VL\nrxhxCw//TRcytUiUuQ4yjdCPzGP8DkXR8hFpwCVaZliH4dRd5ZF0Td1QS48cSM0E\n3kbzAXd8L2KmJdzNmZCY8F0p1k6q0/HYdf9bj/qaXncS/6/JhwR0MSewIUgeUG2d\nnT45eUkKoDXERibK/HAxG517umnzXAeoowLqMhYjc2PaZn9rqFluSDs6CuZ2Uq7m\nDsZF2cjYHBXLDKxkjOEqY1uo4E28VlRAkm2N/xQ8HJnvJSZ021M0tvy2PrSTF52+\nH2KC5JlpCGLTce9JD5EFmQ8KYLCkJ0fBY0M0CKvBK7aKXGPc8e6iCHP7yMtYPXJZ\nKyzE5jThiCo87A+GiWao3VNy2HMTBxs1RMJJ+raJF5VDSycMTkg5+QG2qaf1h0ER\nrxN3Rh2CTCkXQ+7GTECYGjcsmbR7XIHKk8oxmh46VEfVpsXBJSQ9eUzZeoWwdTT0\n2JnudjVs5EUk3tzzNGDjoo/EVESXSoJHoZFLPFsrm0BfvWkEF2933Hl/hQGTxcg1\nJZPlbbk+csraGiixdZCTWvRFNHCQjixGUEODR1Fo9j2vtnpVFjqQMNXpLTCfsejb\nUrIOXsYqh8+RjzSuYzhGbp6NmUKZMBRyPrBr9i747O5fqrv0lunIDiP9eXh4DKI2\nHV+v/hMiUv5anCMihmTTKP99VOpAfBdmG0jFjfEd8xlUcNLDzpU=\n=6jT7\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux-s390x.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceAACgkQsNpg+0VL\nrxiDcA//ecc7FbMqqVhrICDLCVu1h3/sNy6hsuOFz9n1A1IWB1/vlGXkYaxsONf5\nAkDcBRHkt9Gt3PXxbLyhLo0zb0NWbIkIt62IfHX/NU4bEpk+95DugWMKiZ7Jnyo/\n2bsiUz51IxGlsMubTn+VOOjfdFrob93NupQI7Uob6FMI2M7347vA3qBwFgmt3CU/\nWrCRR4o8sZCmjIKWo8oIZJ/7kw9fhoi2mvN3lxs0uodd4/V/t9dQgpx6vXQ13CF+\nB4UwtfYKCMURDkpxM+6OAQsQWHdFCrpv8wnxx8M5uNmqxkfKAu9S8nYP5/jM/9gF\nnQ4A4viwc69HGPxh0hOLWXXdP4kLGYA88zDzBrPjyQhWOaGXJwUadmojAahXLfrI\nYd7mUQ4wZKZsAYK4hT0NJAsp/Da5N4bXYoyvDPT3e5grYab66WBxGpvsaCZhxy/z\nk9Ur58eSmD2ClHiUdmELfiwK/jehh+3uHDg4uAUhxcybz9bSgxATwGUkbYND8HCC\nscRRmeyY8QtlXdtQVd0zhJB4uV8RJJx1D0LzeGqOyrn8HX+iHmbnRBVRrNlWirKE\nQ8LeFFCD449rDn86Ss03S5uwilDmtkyZ1w2DWV960ApULsi8UMTLGLEVlBU3IbUU\nOOB6RlPfv8pZZG40R4xrldjiQdwUD88hg6OkvUYHcrkII5xYdU0=\n=v+tG\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-linux64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceAACgkQsNpg+0VL\nrxhBkxAAj9b99EVI4eIbHthB5LehqOXsmRCqcxh0ygfquG7KzqApMaYuqcuVULLq\ncyVh0NzmMLalzf2Wb30BRshSJgUHBFIbilw8vHshQ5Wr/wLOr7ZJNP6IvS+iKsR0\nlkk6qM106ZmYxN/Y0AHUBjh449gjFjIvDD8ROWlC/2BA9Hq7d6fJQj6S6SmM0P9n\nOKF/GxjmBuIKSPgOP++If8WfbjqBf29I/irXOVFX/8f6KsCuPRBFNUW3GwcvgEEu\nWCUdnAnbBDjgKFhcXZK2fL0B1PS/9JZlKX9qNfmuiR+oCDp/MJoa7D4ilyUPZdzx\nLqzeMC//aWbJx99GtOUJGbE2ZYRzYc1/5s7fwE/i953F+Qg7U3xIdMpabLkHFn3V\nW5PNZvKnzKg5LGWZbHXjnadP51Sgi2mosMfq3noSLOd3tNoYh9sCR1hFMAUY9wwz\nssqDrpd9kycDasJ6Q/eVs/ZGnByG74K1J+z8ES96d9MG0oiezUx2pqBWWrjANJZw\n6fKI2rYyfztknT4/2oyDmzEYkrfX0liJSYA4mVDl6UxC/qq2aexjKEepFJf7zO0J\npUxRTvamjU5dNVTy4DpBgZesgVx8SiaktyH60WnphyUL9CWlttgmwDXjxwiVqVZ+\nXEUprAlN9SLMVgD78Hl8RZ8xMb0ZeiL7cb66H04IkEnf5XWZZ4U=\n=yRmS\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-macos-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceAACgkQsNpg+0VL\nrxg3xQ//Z2VE6wRM6rIHWnT9OzadzGcmJjEqCzCN7krdkvUMpO7OjTfl05rARnqw\nin98seJez4GydIpBOTlwm0MU7zM6lQ5AFsTLcR29XqKxJZF9cYZZqe0wPbDWxZuh\n/4sEP9cQ+Os85q1USbxOrnO0rcGDPfuBc28IZv8NOHj76DUg867d+ApTxzqkkicy\nZd3oBN9Ohrs1TFN3VlEmBOlUKWxhGJTVZOzF4YzGrxh/toEfYTTlDNppNt2EEDbN\nHCvn5z5pxJtzc3338a1tAEoTxhdFn9fr7uAdZyxm+SZGTB9V+wfFUcKXicx04Bf7\nHn1zmS8yGEGeXa4pA33fR1MsSnO67T4OyMx18ZmlbkknJiV4GvaCmco6wlyj+AtH\nC5pHm4Fhf9p9IQXO+I6xcJa/allChEjv67/bZGl1QlRWrzD/Ut6SetqMHEOFyU2T\neD1oImg+zlpFNeV1pEWBALqLhDLFkd0XXjSy77RxcBsN+w2VwHEb0PHbWPZ1+Etm\n8i/7NPuty5eAUG4vH+hskqEFLFi0L11j6L9eLcAutjNCbR2BAOACxHkfT15bVwj4\nrUFCH0Xy/jL5qr/8ondT52MthOQjUF/bw6nB9Pd2JJWa4oDihbYKC/6fzvFhLtOC\ntDuM4E1YBQnfQA+vPP+qEItOa5sFO/Fx2NiNAYXp54li5BSSkkw=\n=jB0s\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-macos-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceAACgkQsNpg+0VL\nrxgxvg//X+TyO3SdT94jlBn0JHBmztCtiKur1nm1XlbvA4cibfwN0hK03SPzL4d6\nf6lX49JP76CtN4sGPYhOCim1CUTYRQHsCzTM/5oA9RSC5ssgg4rcoO4GK0PmaDt+\nPEgiP9Qzi1aTubjcgmfkuK1+oiERYtRTDdt4LnuBBFL/mLsU6zrR9WcDTQSDo1CQ\ngqyn+Pvpr00UeVGS0l2JHyE+4ZgNOODqlz9tE/7Ab4iHKYF9ahPuCUoMySRA4WOk\ncYphD2CWWd+mJ2Oi3ryvnRo7mlJLzxusWmrkFv4ei+skttrQXFcxCOJxvqruBN2d\nIrR71/Ydy+ozIGwWsLAFQ/yS4KcrPJiHcmfybwx6XgXp/qyNeel+B1Sb8aO1uSjj\nQ0j2MBltS4DOLvAEvhFVrHzKf5zmAJETwpK4vcYqYALnLMW9O0kfV/PDpN1r0eJP\ncyFtu+kjuLsg1M8Hpz5y/uVoXnNBSFtCBEkoE9Dh58r7vyVp3/2BHbXvAxWQuE17\nF+TwEFHX5AbRRNQEmG0uhuAaSDU6wcInepgR1Nn4F5+wtT4s+iSMe5MKK8OEV26Q\nq88sbJ8AJI97C1dEzD7bPYoqBxwOklhNISBI6K5rnC1Y4YnBHVNY1M9bgT02TzHz\nq5wrEHlo0dAzUSoCZCJvWWKjKD30yGXqybBL8mogU/dAhcJbZPQ=\n=3Kro\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-osx-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceEACgkQsNpg+0VL\nrxjqlxAAsKcs/5wnGUfL3DBueHA7giwZXd7Od5sXGPSahQpezsYF8S46t5OEN3y4\nfyj1JvXfdMFSBi8Pcw+LQ5iXv+AtmRksF0UmewibVrq4ETVVF926n/tcm9eouVOF\nI3VKZVKm+UULhRy8XVjkMMCbqb/AZW8HZGuOnpWg4UlQgPX3FpiAYBZJdT8TLv4O\nUHqp8hMCp/qwCRSshTcKBqCEbdITm5OI35hqfotpoA9F0SUVTBIbu+xgvksrW5X/\n6Yy+OVvS01RFgF1F6KeJmxrfxo4K4/eNSuCbYJTHfTNB3vK5RBwki9ufqY7GOhqe\nRcHC9q1PSK/FUlp52MhwIwLGp+fdKcJjOpXcgZec1kHlPGENcAi8zE5WrCGaEtQa\nXK9DtNedbu873UuJJKA3uoeWFQLsG0GKIK+ESgG5lZWQvP57XyG2rQx2opTLVasd\nEA1ctJFi5IIeP8vpyF4/WI6tgy3sgULucxFlpsdxNHEm80tpa61p0A3YVRuVxAre\n4GetVrb21dkgg0kfEmhHKrntaRDMI7DYwHr9YNCfxUPapgkcaYfzLM+VouFbYUiK\nJDnPwRYV0ti5V30nfnbQzCcVCk2za5XFhbH4kXMwbYB9XCT21hk/xlCCPG4FxFQN\nGm1iNL8USJjQXtdTDq8W1aO1kah8FJO6lfZsEcJEuUpvQbbhXe0=\n=rNMh\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-win64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceEACgkQsNpg+0VL\nrxiYtw/9FETxa8Nx91lb6WKS5GknbWaaiaCIXpN4GqZORUnrMnoPqF35PyqEYPZX\nXXn+jvZ5fvsvyWsyWrE7+AMLZ+bS/0WQnryVg7pxfo/4RBW4eqcagBQgaORbShKd\nJO3F4I9nuR17QPKk86KtjvJlntxnJK0wxJvIWiFZge8gvymaLL0ot1tyak3HhD4K\nBPeRRl31Jgnuw/pIjgUuNPYU6DaEzPw613e8Se1SrpgA6fA4CYzO4nRl1ah0Mxws\nwRSVDakGKz/yRtVj9uGFSpGWfgezkU8py+5fr8PcmcLt2tVj6rFzW7siCBCMHQDu\nUnSuVaXtfXxc0YZV2Ih8iMP/Ehy9RDQ8CPwvo9GHPz0FZuy8lc25DB+IeRYK+qhZ\nz0upYYeRJyp8d4t66ReiF3JxADF1uEfN34ZSHznS6BpVHDtaAi0kDjy3c2VEDTLV\nQa3zx248cT+qHMVOa+6i7AhWAWuAsSzM5xwiuOmb2RDBzoYy3maqBME5VL3u/qWt\nQyPHkJKpXg6OifbsyerOTPSvWUIH08lv7UKjHQJYRrlpHjwyCq8W8VlR9ceX6ee4\n4IRlbZwZpv3f8T5RzCIhx28t3K5i2rPcsblFit0t8xIa+F/ZiW/0uQXyebcyFllq\nGq/KMxdGAbPh4P06Dh979MMhmgr5e+FjY2W4bkeAG6N0stZ/bdg=\n=/bLq\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-windows-amd64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceEACgkQsNpg+0VL\nrxiYtw/9FETxa8Nx91lb6WKS5GknbWaaiaCIXpN4GqZORUnrMnoPqF35PyqEYPZX\nXXn+jvZ5fvsvyWsyWrE7+AMLZ+bS/0WQnryVg7pxfo/4RBW4eqcagBQgaORbShKd\nJO3F4I9nuR17QPKk86KtjvJlntxnJK0wxJvIWiFZge8gvymaLL0ot1tyak3HhD4K\nBPeRRl31Jgnuw/pIjgUuNPYU6DaEzPw613e8Se1SrpgA6fA4CYzO4nRl1ah0Mxws\nwRSVDakGKz/yRtVj9uGFSpGWfgezkU8py+5fr8PcmcLt2tVj6rFzW7siCBCMHQDu\nUnSuVaXtfXxc0YZV2Ih8iMP/Ehy9RDQ8CPwvo9GHPz0FZuy8lc25DB+IeRYK+qhZ\nz0upYYeRJyp8d4t66ReiF3JxADF1uEfN34ZSHznS6BpVHDtaAi0kDjy3c2VEDTLV\nQa3zx248cT+qHMVOa+6i7AhWAWuAsSzM5xwiuOmb2RDBzoYy3maqBME5VL3u/qWt\nQyPHkJKpXg6OifbsyerOTPSvWUIH08lv7UKjHQJYRrlpHjwyCq8W8VlR9ceX6ee4\n4IRlbZwZpv3f8T5RzCIhx28t3K5i2rPcsblFit0t8xIa+F/ZiW/0uQXyebcyFllq\nGq/KMxdGAbPh4P06Dh979MMhmgr5e+FjY2W4bkeAG6N0stZ/bdg=\n=/bLq\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/jq-windows-i386.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLceEACgkQsNpg+0VL\nrxi3Aw/+KIV4xZdceYNHNsSQw0Dmca4ftP2rPy3tzxHb/RdAtcG83p2bjrj76fNp\nfdZdQ8LclGQYwAQ4w4ZevZaXOdlAj1a0CwuRxMDlTWJ8rsiUqa47bBeAd6R6HyHi\nPkSZXgcwhrsF3cUsXe/sb9Iw5/LSRYz0gcyRrWLKGZV49ip4XQaHV7zDnQ+YpgQo\nppM5CJ+A9qsFhzfmEpW2R8qD372NjzCoUfExJlgWZGM0IAxNWX04sr/spnp7dLnE\nHBYl7rVGT1LMwIqi5YbzD/1O8DzFd61nJBMKjoJp4kRmer1gxzexXlWWM2e0AXT5\nrGxjSCHU5CrHQ98RsnRvvJcwNC2bV4YyV9VJm1rVlDGzyKkbRgRn/WtN3Yd1BKKo\nAZ8O9jzWbb0b9NKh8SM3x/+BZwqZ5/WvokG/N+jLwYSyflHgbJkGbvwWBnq/8Fl2\noBJVEH9HznOanyc7fasJp29lGxzCrgaoNKjdCWYkmqvbXZddq0pZUk09gQu/QsHt\nNykYjkXII6+z1vzFUVugZH9ce5eZmVdZRm1X7VNNTlfbdAFwdV8+5m/nfB9XYdT/\nLTVPk72Hfu66OHcgpht1mYBnQfOzKgEQ1ppwa0LQSDpOUF4zTXsbzm1xe+F8bkhh\nlMpfW/YI9Trtjumyfl23fg7Smcc2RfIZLr7yPCJAQ82X0HcT5Co=\n=Y/mq\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7.1/sha256sum.txt",
    "content": "478c9ca129fd2e3443fe27314b455e211e0d8c60bc8ff7df703873deeee580c2  jq-1.7.1.tar.gz\nc9fab0ed0ce278dabc0606462ab9c4c3385bc801e958993dc0ed3ebedc15cddb  jq-1.7.1.zip\n5942c9b0934e510ee61eb3e30273f1b3fe2590df93933a93d7c58b81d19c8ff5  jq-linux-amd64\n4dd2d8a0661df0b22f1bb9a1f9830f06b6f3b8f7d91211a1ef5d7c4f06a8b4a5  jq-linux-arm64\nd6b86023e0848c93a618a74b6fd741ce62f5d557fd3c2c1d7870663713b2c174  jq-linux-armel\n46d18f115cca638efed22b90342d52a84a25ab1bef570551d3a16f7eb065c298  jq-linux-armhf\nbc473fd4b385789e9ce3d02a4c8df74dc988a34b20fe4e1a80da997eb360b599  jq-linux-i386\n5b7c362a354dda4f91bbfd26f7ed92c7cf7ceac28c022b1579c7c228149b55d2  jq-linux-mips\n3d4b43d0ab571431fdfc786f951a0547a05f75aed5c076409ed2cb58b7244de1  jq-linux-mips64\n604f5a87da0e17a1e8c12422eeacb47e93e3eca60c8fe17a35fbc629d425bdca  jq-linux-mips64el\n21de7590f4bfa078514a6d3186bd68746fe331eca4807d6ca0299fbba2d2212e  jq-linux-mips64r6\n30ce843d9910925f6ff3417ff13db469b5a73a2d727700cb4c3c12de8665c1be  jq-linux-mips64r6el\n5174f769b2a8a111743e316778aeb88ae4f8cada0caacb5c93ce6baf9287dcc5  jq-linux-mipsel\nf6d4a65deb9002cb59c00e80af6314846d2229ecafee53449228197f7b8d28ea  jq-linux-mipsr6\ne88b5bda2d0df0257033477fe53eb8544fb44c8275c814d4279ab7dab84b2e51  jq-linux-mipsr6el\n761a9b3ad168e4ed0413c795f5546725be3ef1e1a11951f755524dc3f4a6442d  jq-linux-powerpc\n758841de8a905dd82cb036c9ff6fd6e598549c6f6106fe61795797ac87551af5  jq-linux-ppc64el\n04426a00def567398f6190e830b35e026fbda2ea75157fac98e41b622832ff2b  jq-linux-riscv64\n868b7c3ca74224a02ddb613261ddfc2e43b12daaedd5eb58373dbdc7f2c5f924  jq-linux-s390x\n5942c9b0934e510ee61eb3e30273f1b3fe2590df93933a93d7c58b81d19c8ff5  jq-linux64\n4155822bbf5ea90f5c79cf254665975eb4274d426d0709770c21774de5407443  jq-macos-amd64\n0bbe619e663e0de2c550be2fe0d240d076799d6f8a652b70fa04aea8a8362e8a  jq-macos-arm64\n4155822bbf5ea90f5c79cf254665975eb4274d426d0709770c21774de5407443  jq-osx-amd64\n7451fbbf37feffb9bf262bd97c54f0da558c63f0748e64152dd87b0a07b6d6ab  jq-win64.exe\n7451fbbf37feffb9bf262bd97c54f0da558c63f0748e64152dd87b0a07b6d6ab  jq-windows-amd64.exe\ne4efdd6a2c463ae714ed98fd5e874fe834a3a2380e17885bd4cda1c49e5166df  jq-windows-i386.exe\n"
  },
  {
    "path": "sig/v1.7rc1/jq-1.7rc1.tar.gz.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmYACgkQsNpg+0VL\nrxgqOg/+Pj4c5lo05Ei10+d/fjFevoo0VUhSK/yBqFya98nRO1JCnvNk9SktJppa\n2vWUjQVTmWSJkuBhjukJgb0Uj/njzQRaQpWDa3JlRLb88FZrn75MGDt4gGD6QM6B\npzm/Oq8tdWYZP4EmKAs5CGaegcYBqe3kgK6IckzVdlM6LjVdC7TLry2Qy7y7iUWb\nElWI5iRinb5NOBxC3J8S0mX0joyTemCbvO3uY0VavTA4slnVia3nHeNG1II0nrjs\nHfyc362PtzYz0q9uZZ7vWsGL2GbKEntGYHejJsOSQB+un9FUIuHPubradNN9eIYQ\n2hOUNfdzF3yR2pAO8q29JQ9LfViajQ6ovIoYA3quEC5R1cjNJCWbMJScJiqY3+V/\nlq49XNWghZ6Gxd5DzMPiQJhIpLQA/pARtW/cqyIGnXkNT3ArUYZVlqMxd0eeWPJ3\nW0T0wpxUe0u07VWCnpZTcPFSdNRjVNp6un1Qj+mhWZ+BcD6+fVGCDvjaF3RbI/qT\nojcv0yCsR4D/jmqeWVwV9f1WtNSI4pjDC008KNU3o3Q5Lb7908g+cDGxyP1C875m\n1o3yVWJh/e6b1LZn0Jag8L5DP66cJHDA9BNACZH/hnDUkkvlBiZYRwoyN8EqZd9d\nfxmW9EYGpAUB5FBZEJg1fauR2sUol1OkrjFH4rwxBgKO1Yb0UC8=\n=lfBY\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-1.7rc1.zip.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmYACgkQsNpg+0VL\nrxjMuQ//Sn0UEuZkY1HYXZocEk3AWOAlTvtIwJYNxs4UW7HlOy4hS2pG2vi5w5om\nTp29frL3twqAjdCWECGdgDDjTiFb6NInsSD61cQ6ycLD8N7HRbUm5MCKro1opZkj\naByTfVFNzX357aajny2mm2QirELSGprQH8Jo5piq6FtNtBq9L/gf3uB3rlyaC+Si\nmagcFR4efphY11mNRZ3fHda0vZp04SPk9UR5YOo6UhliLWH75k1DIeIa5ZcF9Q5C\nl4ELb4RYlo7QsJegPDK7ws9pXC8bEbqJYq06RVpnmxZWzjItBsKdejT5AUpz7c3+\nO0ZFdadg0orsjrHlUqHMmZzncuieSfZSoNO8lebWvC9iZ2+OnpFMFlfzuhQwCJFr\nHIO/EIs3DosMm/R+RnxpBcb/XAhnc9J8Bn/09MMwOHvTGVLfNYDX5DHxVPRd+1HQ\ncejKRtZiNNG90vwLoL9q6923U52DcmN5JpPSwhv8VecRyZO8rkoxIDFv9rHrgfVv\nu9V7cf+KrLzjeSslrEFn0I7hOW1urqvSlUiItrJHxcUtI97hEk25Qzuaoc8EVMoK\nCqoq8hRXvJCkCQ8za47a7OKZuUzGP2q6G5Ihh0ofoPyga1xCmYFnjQSVGyy16ovz\nRNnE+LlOSPl4m+zATDVCYh44LAriLhdjof6cMLQUoa//sD9HlLo=\n=hvEl\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmcACgkQsNpg+0VL\nrxhUHxAAi49m2xrVlN//CHhhxZGFwpV7vnqBeCB25kfNVctSOUGwkx3My+hjBCME\nQxEaMeZCk2PB+ECKylOuv5LYCbQerBUfDoucItJ4oWrjSI3d9qT5iSpMaNvIzfsT\nopT4ZuV9SRqS4kf16FpdsFlhMRlahcx65TftLJei7/c49xjxA54QvCqPYreI5lVv\njerdM0ChRvQxZ7G5v07CKDkUimodEGUaURxn48FQLduoypNdxvd9sRuErG3XjG93\nU2k5naBKHnvmafjZPX15KzR/ZVGoP8zYbBoIpcLyWIhiH0/I9JzbhKrPvArabEZa\n6TsOrAQp8B/YO/kWjGDbUnKsaBOGTJ06zbmzNilu7nU/8u7qeWOSVsPXLIHOmnKt\nsv6DLFtDFLe7h6H93L9uz/6MucXF4Sfb1u+lcmhYRY8hotwXShadMCFcSe0OR896\nayvXCvfgkgyQgWZLA9VvRKtUdnPnK+8ML2pNPxRGq0GyxyokBYggzeP+5CDa7dwr\n/4gYzvQqt3BoWbqyLiVEOKUTXW4Wq36YwV7eJKHr03n0uioklYu5kwyeBXhpI4VC\nDMTOFYMM9jq1B7bIDNoJFYgbhrLtZgAAW4qYO595oaG9kTmIdyto//drozLsHIHA\nCbans3RmBdoTuk5qF4Zlp7eY8ogklw4gxpsiZjLq2++JUKL1ZoI=\n=3M3X\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmcACgkQsNpg+0VL\nrxgLhxAAg1d0RMrOEi6rdT7Ajh4SvP4Qm0x+zvEwxsVszSPxOiKal6uKDHMcn69x\n599mqYJsXK8zbiHYtxoI3AmrQY85/DKEwhm3h3N5sa1IBzGmASzd3h1ewE650M4Y\n4Ha5WWJWlXzA5e3LvocSl6n3ejTCcaN4pQkCwL8cd00YArRptNr6CNr4HVU3M8z6\nZyBsVsR+WzFrY8R0h6pQ5W0Oh5LGWsVKGG5SvFqlQDEgzOfo6nDIA0ZIwg52wV2A\nRwF49y7Wi7X3gJ9NZ5jvpVpcBQxmorpCgLo8CLj5sCTRCiuTj3S0DS5RHfSCd/py\nuCFRI4ss1M7z2yjEYuB5MtUIhFAImU+SEx+SZQHoL7XGHmoF1PUvw42m8L6t48bV\nSzZoaOKsJy7hmTRZNd7cAlx3XITFoPw4h4qXeHDWUgGs3kefgQibBG0d6+TcfoaV\nyKqCy68rE/v/P1CxK9dkVjawOOwAY/rhn+DH3ayeNsMgi4QrzBNVLp1FA41ZJFcw\nz7l5KFv1ompqac3EnVbxaJxJ0qaqnU+cdLkwnFV18e9oLTjeRbZqVSqAB4IX4IKh\nWbjiVrSIpTxGKozZwDYE6+NtJ+3Z6RCtDZE6sYGGkHuFbD5ZQNhlgf1hDg6outRB\nB8WWGInBIctIFoU1hGy8gmkAx7u+ljdFd/Gg5MWdbhHluQTM5Ko=\n=LrX8\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-armel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmcACgkQsNpg+0VL\nrxhn5BAAgwJtpctwGgMXltgMZE9vRGDGH7A0VZJJ4mkRD0U30C/DGaVM+lqhTOKo\notsZocC7b9gMbVTcQku2/8N19uRxmO0N2OXusof860UzKV2cTZMOIsAM0E5Ug9HY\nd7MgPsh3Hni/GSomYjszTczGlkFFxLuIfFkUgt23+vgLIxont7O9xSwlR/7HYleq\n2rBg25Sl6nZyXztlEal23A0q+Xue8BkMhcxxj3DPXvMCrCwuxIG/OcSO+eIu0uv6\nvcW24mYf/ntRjGth1om1v+dwGKcCBAWFD8H7z4CRh8G31rUGNSgNaEp/fhWo2+wV\nq3vtz26W9xBXnSoAoWgNt7oiqwywW65lkcgce7cNuxS8cyvG+dwx40waDQQXj6oA\nYBQ/C8oBd7xiuRuybWE29khQdrc+VTTfti3x7E21fHg7XG/zNVzjoTEUCuyJ4Nju\nMkKajscE0u3bLdCGt9auF87hY0LHfkGv5RFGBJxDk9nGS7nNK0iOQeEz4ur7Cc0L\n7xMILqmUI2dpO5SJETA0Hm941j9rzZZZxGx7frXHzbN0q01tYqGsD16EajkE1i7c\nB9HLz1QRw97wB8H7zlX0ve2YnDR3j5wtEJSQd7vozE9f8Qy8MNQ9ij148ricXmnU\n+Su1FTCpcvotcKHLOdJqULVMJIb3MPv3oCesIy8uFJb4QXYMU8o=\n=eRCA\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-armhf.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmcACgkQsNpg+0VL\nrxgZexAAvccUklYZ9yShEkTAYdq4mLcbjQZcSM6wREPQa9hfnpkbnN1YcfvbAxM9\nag92xVsztuvX7cYm2PHX5nJ/LGC8S5jBs58bPExsd9tP9UjZwK2B022YrFGjycEa\nOXurdv563dwiJqaplvNUWHvMN3LuVnhGi65omQ3+ZJFmdIxp2h77L2DhEmuW7h73\nxRgOVsduFJzxKJWjAE8EploMds04sL7OeMYYuYo4KDo6malieKM8myk9KPL7Msm3\n/j1acYeEzpHl6Bk+yE75mk5+adFNwm39Erhkm8eZstSb99g3+3T08gQG9scuKNPX\nO+p6rvC+sN1AMxNTgTVPaoFIRXQ1AfP5/tlwNwvPXhSBuEKPT18XazP92+gslMDK\nhCVJvf9UeElZOtrZ5kefhMKJO/uQ0u4DsqHAzNectk9yRzpH5KMNUQDTYYlLtaKr\nykyuqNSJ/ysXP1RAZeessD9DpFzpyt7qCwbNzdR3fQDYcylHzb0R9LYUlXy9kAKp\n19MBAETrPfDDTh03QeffkFXGkPVIaJSZSfg0OVsizjQwAelxmjaEjdZZeDb1q/TO\noR1dc+b7qyP2RFW9S/jrG30lHUpQifivHk3eihMUsd7lJrBC2ltD+1pj3V82B5y9\nKclaYxjH5eByAEaRUOB+KhtU/hDQUnrbKNNuSrLvT6nIQ4tuaDA=\n=CChS\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-i386.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmcACgkQsNpg+0VL\nrxhwqw/8Da2dK18NsmwECjZ5MUP4ZNhp2AJMai1OymyrWI7kKpYGVOFlMTzX8hxq\nm7MzFv0U3Zlr/NRZx0OZU0t5gI971E1lNOzXQQWNK22cpZQPOkbfRS8hN+bPhc1p\n+OiMSCugfQCy5l70mRWXIIxBomdEhH+36oQ35rC5by3TwwBfG4Cu85lXd0dzjezw\nvDUaQpUsx584XMERRTR/FJZVzxwfdm2/o3+upYdcxTBTdAsQPYzMQatVf6gj563B\ngUhG2epJKYs5lVqCvnruMZgapgiWwDpFmZcY0zDjWPx+Jpyvdx/oFA+nkR4u/s//\naVSZEjtQLUOSbHTYze0ITViBiiKjt2NojYXbyg5kMd++h6elWGa6BRDryH6sNugu\nd78pIKi1BPKM3+eMSGLtO0dwhvevz53QXNigGi5+RuhGosPRjHHhK77XtHjJldoB\n29xWnMUZBCSkeuK1GZXW+ISqzusYX3bXrHhDdjR6UKhCkAiXW8bTLzckIuERtYuZ\n4J2plut/YfT2mmNrerpoXt5JLDk4uYKOuegt3Mqyke5pEjw5gZjCOzUq/4ekjWCp\nUX6/LL8DVU0qTttr4TkvJsC0rGwtolxv1tADZP9LLU96CNgSsmc0R4ZKS7t8Emdd\n0fapXq9A0z+3TIhHr7UulzkrwQtSNtuBrPc7tlSdbv5GRST0HWk=\n=kyea\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-mips.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmcACgkQsNpg+0VL\nrxhFqRAAzyNAw+SMQ5qOTrGkrrgAy86U4PcI43/W0cYlE+51XrZh4a6yqYWH2Mje\nnF9s8KwIFvwo2uj+G2OFiG9cChCsd0UBS0/Fm+u1+ZbPPQ69fCRLxqBSCStO5XZ6\nc0NhR1E/5xBkQJX9VP68hMJMq3ob1cpUpNCMT4RA8ARVvPNYS34HvMCj3GtZdyb3\nlrAStaaZUy7dYlFeLGKk2t4pmG7r2NZji0muGN9y/caXIoRvrxD+Lz1Slnojbfux\nHcSV4OT8GKmf6w6D9Y9pxQo15azjiLVdKgOT+HEojtx39YV7RAgiKW0A1gObUMPn\niObuI6KlJ9z99Hx14HAfeTnpuFFpxUnq7S8Jb+0sbJxRb+Gp7MHXV+rs5wSBB/Vx\nYvn9zkBkMDN87Q+l3DhpSPPL+lXgvVbB09UAahSG9QE5DDu/pHE5oQrzX4Orlh/4\nue7vNxL3SDUsUNTNPn9eS73YxNSPbZBh5yWAnoTVk9M5IlVYOuF4vwRQ0y12f3pZ\n9dLz0n6kSYArf2XLH7qYe5cmCeSOGgiNlp8P9mJ0r7qO1M+pKm4qtpGwuw4EWQEd\n6s5lL1Z3pLBd8BNcG7d+sgOSuNGMh0UIOzXne4yqsbtdHbafaVPJn3tsIDsPRUiz\nAyvnyo6YJDlkutALYDyqdaIfO/ZkHpal8nWyCFFTgNjzVq0cnMU=\n=QMxG\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-mips64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmcACgkQsNpg+0VL\nrxiF0BAAgdGoAA76AdTueDltQzYy8XQhHoKnw29VLPjEkiJH+p5001ifjjuwRVR2\nSQIjmkORmRUJaJurNquUcVp7teJxWp64t7m3jMKFOkQKTH2eMm6MYNRfeko99Vaq\nfE6TZ+Ix1NC9g22A6EarozsSPb3luhWNa4OIlEUPM2T0o7hLH145mWV17+gdI4m0\njYGE3ZbD5uL4k3SWe9GLT5PJFxMCLL2TnMmtz0zvUCP8MZm1C+RcF32MMXoxjgXD\n4dWyF2b8mTraR3XbmBvOty2vKxFqlQ6W9W5RmayI+REeAzQY/711OGlYY5gav9R3\n0dDV+VQcd5pq2iorXKoJwg8BQHlqjO5Qvb8ShKbF7BvsOHjCSFfTvzD1skXBphvD\nf64jfKT0JQVzCP7XYG1aMB+6xkDHZRUBdmR+20D91ssdd5wQbrfDggv8xO1Lk1Tb\nPSPDNY+V53ZLdF3fdSa6/0Srtx3yHVvEIl9amYjW0RQoihNAUz+xoUChc09a7VuQ\n/44yNp6TWtH9LTKw+g1vmJ8VVXFbQMLmBkYPrCxDj4YsF59RBuAUmMFD9NoED8Y3\n+Nwq3IpNgvtLdymSXKtDNjpoo1O/b0/H8E8vFswpCtHHk69i2Sg6DMb/Fy5U2LTL\n5Pv0cnKmFAP0RnIv6fwQuysRl5TcF2hujIQktKVkGaUGlphJx7I=\n=h2BF\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-mips64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmcACgkQsNpg+0VL\nrxhhWA/5AYDVBWeLyXTLuX0ovruV+4bLFjlcoi0T92s14WyUOPm/0snpF+lvR2DX\nzN6FawFr2v+cqOKCStlnfLNx3/m1/tL5uGRKIY7kZR5tmvdDKSJhkaHGYGL3adU7\nihuIvN9xzhHaKh9kg8NaXyDNCD/Ir9KZb9efMGhweQJk/xV3JnYeaVRR6YNsBIzG\nmb2pb50NK2NQcgbFEcuEyDLhjek/wIN5gFY8+fykDJVdSPZNZZ6eg2EpKgvf4EEI\nDvZ36AHujEMyv4JcYsnHCCQySLi20sfn3nlcq5WcNjyPEXGmkMbj6I8AsD55cSRF\n8IAiJ+9XJMa8Coh+bKIe70YxdZEkhlDeECNTW7rqtVS7mk2jv9/nzlSUHcs1RAUA\n72qKohp6+MqJrI4MLHNa+HkfDIfro2Yf1MPa0xm66VKlZrXPbeexAFdHVt5gBiq2\n/TZ4qOCptbm5M8xBE+pkGihoISXteMcpMoA+PXrdEl3fc4DiqrhL+1Ku6BGl0569\n3UJWwqpOCO8N8IXTt3pZGETrzT4zh8L5NZdeyJp+thns3YSmG0n2FScgObVadhQJ\nR+wRlQZ+73qDflbx69R1j+epZttG6hXqR83+I0JIBHm8NTU7gKARcjUJbQ1+dVD8\nwmF/x9RmtnpUZ5KlysgCLY8RBT0E7irFvwmLMWEmjGr8mUx1IGc=\n=I53H\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-mips64r6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmgACgkQsNpg+0VL\nrxg6LQ//V4+w0x9VGTJmLT0DtZfndudMXuNkjw4v1i8AqwsUYhB1GmkQsuuZYLyv\nhO7HH/EzX2b3CIp9kNoHnpyD2g9zMk3Nf6NiSATEPr4xUU/vdbjgtUuU8Biv357E\nvxI6DoQ262glxH8zA0JX8QeZB8+VFKfshoZDJPE4MW3+u2mZsOemxErA6X1LB9/T\nR/eOgmLXBQG3n3H/YHILbhYdNKOd8VYZkMK6TdeXrVl7KRomdp1wXcL+oyDXNSWd\ngPZvqudR2YnWIIjEGxq6Qa9hlzaNh+b1IYFPrSAEptQNxh7gTydMMIchNtV8wdIX\nxcIkoY1g6Oc1iwHQODsgp8tEn3m7rMGfCKjL+datuVwKiOoIZCQpCjfPTIK9btID\nub0Fiu2bKZHXUhyG03J01rL09csEl/UySdesBkPf4N9HmmuyQPNeAZGZUW5WftM7\ncQm6eFiG49wA/u51fzPYxJXlvxxPxqxIjJMbnGlUijdFKz3KZsl6zhtcPDA7VgbD\nA8QJFaUpcKg6oCaCv5iKof8+KPluJWi2ldwVzxva0THslXD/VTvLEQ4WBcFwE2xE\nZM4Hd5P6+oELihewahRFniVYThv3RXAzM3ezxmNjc0BgyXTYUEtsXeCAFUkpgF2r\n/oT92jW/oBzDSPUKL/2A1Fg4VfoWhi+qdkICC0jV6b2tIQ6kT2M=\n=yqFT\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-mips64r6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmgACgkQsNpg+0VL\nrxh0Tw//cYM3SASF5CQyPZSgSuIQSnc4iks4iqUa3urgB2mLcyZ2KFjSed8Kf69x\njgMYR6PXTDPRhaOB+PVnN8bv1THZQ2E3gUt5b7na6DwnAnD0mD4IFbp0k2KzGqUI\n9Q6fGjqjUTfFjWttfKfkdNaYtcOEXRpsf2gfdPC5jNC86pdss2E89xzuy2o5pduf\nvrERu4kGAGQGutME443hcl9YN/1ZhsTh/ib7wd/ib31UvSHp2j49wPgoz0JYgm7O\nrQCV6SVEBl45rAfMtX9h2qZJJXiIQmlZr96oeJ7S0H1wwCOLTAflMsOMWZv4eOgz\niejpU5mTvvI4ZUOfMk+Wt+3zjtH0RuYtIodUnN/nLOR/uLWpD7eaVpHIfXGtCYCq\nJ80hOofFuxN+dCQaKi6kdr3Cc7V4qyfcNk1dxcBq14H7k0FE7E68uuHCBNWg2UI7\nmQlpgM2+27jscGeszdohD4o6C/VKLJZBQs6Yd8w30FYLFyqtgM4cTEoabXFQeKaP\n18CjXaoO7ELXdTP3D5FTKbDSxvj0P4Zn6ZJP0cqCLhqMsiuton+XWpL3dLh+Xef3\najzDBZ9oYI/xTSi88Z1oC8M+8XxqvkASUGI3Y5dGLVZVnBOHAWtT7gmq2Nw8Vdf9\nDShVQ7bzcT1HtFkFFItSwbK52ERt/wnHs0epOgcMRSs/MDdnzZU=\n=+/3t\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-mipsel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmgACgkQsNpg+0VL\nrxgbUg/+Mrnx1ob+WACO9L9iDmLvzX0mhtGfnMrYou9tVrfwBwVGzNdmtcufE8F2\nqthcANT9tli+xg+XFzZlfzmPC0oq7Gtf7Q3X563JE94RQF9sljy5AmoI+UKE7wD3\nCP4PSqp35GB4Ev4kLmiowTIH0udcid9yutQtCMB7c+jPv1pg87KK6hjaRfXYKBF9\nVRUHzRfPkkx8yXrvl+rq9TSZxqiPWYPuEcPLLQk//WinMBj50A/quTmTLvOii8mL\n7Ldxzsfw4w6tKRGPq60fwkrEByJGusZhafzHM34LbjSu4gtFrELDeQ8fjyQvgIvn\nDHOz5pU8Wb2jcKRIRolAf3MC29+PLDWIpvyvmbitT9fOqPn7E71PFvgXpPNfLle6\nNQcwHROCcZ8rOMHjm8mpwd+NRuBNa4+zRCZolzr7cdkGEsQOHMIHtrUOQuSgB2Ov\n6UseGB5kE9YCxgS6lAGvrwm8m3wdjNemVUkSeh3Ghws90x+yXAReSd/Fcn+WCMgQ\nMi1htrJKUXnIL7MibdoMFdWXZzq7K/3oqTFzODLoYBS6RMZRsmToD4DstKb2e60g\noGCrCzoATdTOn61/su8UmPeiO9eBWMSCh17EW6/B65LnDNFdbaOhZDRjaAz28eRU\nvu4ZbZReUufhDLrf9iIVoaoOVSASr68ZKEGTJItHxtl8F2UPON8=\n=3D2n\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-mipsr6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmgACgkQsNpg+0VL\nrxhh8w/+PB4r3/JmzvOfEzyRqLG1wLC3hLdm7dXyWeX+FOIGARCZ/m6L+CxAe+sK\nmdIBsDiGzDYaZQqQ+ps2A7XzmIA3NMIT7hRrfe0pFH+HBYWP3B42m4Ad7qgkFC7o\nOfPvjwYqhNq8rMTJIRTMO0q6VQOqTs93QzqoVwvfUYEZgeP7T/MVq5Ir4lp6jK4I\n7B06+zXjCdbqW0NC70ga6/kV5iSTJpCI9H6AYhaAaRCeuetKEq7Czl2NtkKJ1p0V\nmWSOCjcpzYFs7GvZyaPCYc/BSs+63ds8a1sHcgtnz+sCCZ2CkoE0fUf+5bkKCX+a\nSS00wPu8frtBU74rT8TXezBrxt3SxWIOm6eqWWWEsohF0W45FHE7rrBHa8KgsMBX\n0iegdzntJWgSSrMTouHae0Yr5tHoDPGS9xThatUqEKhn1xii+E7mkq3ryPaplumy\nh9AahwoMrqr62w2vjfjGDjkSMxJjeldwOVuaUjM+2lidNM2dE9cfjHzvSNmtlMyD\n9l1dpV+AvBe1PIZUxeUwX72nT600B3lRaBdfnk+kJOMUoMqRLgsW+2oYK6lOObiJ\nDW7jwgLyk+vG0IqS+344W6uj++VfdFhVAMzdWKX42rfCgSdeu/vD4sS4lmuOp1yr\n9IFlQnYCsb9xnQi4U/4CpBg9jeWQ+KYJq3d9VJVfb40bh55K4Q8=\n=h6tI\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-mipsr6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmgACgkQsNpg+0VL\nrxgsBA/+PewQy0cuEYaVXixNa21lWzqgSjaS7R4l1KOL47aNhmQbVITeFA9FOFro\n68Au/o223tFMhBWbJafB0UXUyTOdBAF8xN2OPgXv0TM7IulFSO9DMb9frHIlrg0u\nWMmcNr0rzNAedLsnQ66Fg+G64Se2ER/cqyxzZ6i+TctXQnt9CjupZsykK86T8eug\nA1wmVyLxwZnYM0wCvR142ADhCwj6yZRBUyOPvtUGUAlVEfWBxEllEqBOZHInd2Bh\nQP9AYTnZh5vBm/+LixhzKTJUeN2KUZCKnWc/HJKBkRozyCzkYPx7fjA8nVE/Bw7B\nbOhdPptxfFgck+/sPF3jlfi+Gu9daaBBYtaJZQijbc/JXXXbB0ipRaSILbPTOskR\nFnQ7agSmEciRoiRUccerbQVBlrF6B8zNZ+xdE/iXVsh/Ph7dRPPcfa+DdU6ysHuA\ne61mrcwhcbojx2SGLC06uordoMvAUCuCbbmGsS1YNwDBBmUbPfzNySFr47A/8jNR\nyGHZkxu/qWIuA6HHEXndsbwOnMzCLVPhD+efbVOJ5Npj5YbzWQFsrcIwci/vnNT3\nAYlPeanjCk4pWUUljFQuc8vJu+YckLqckOYS2Nk6BV2c8OMYsxuyFjQcafAOflqJ\nutiE7gnqRyy7ktUpUeEUMgnXYmBfphFUfqFdhMS4LINY6dGHOCw=\n=xT/a\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-powerpc.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmgACgkQsNpg+0VL\nrxiDnhAAmNuWQ4GrXoWWIaLERJlfi/VTfxK3A1CCMPxphGEYG4D7kFURmAoElSR4\n2CBIUP9slRRKZWgxyiIJso4uiuwDSkDeH4IWuHGVZG3jHcOs1XMo+wUaxQfocg/N\nMtaChc7DlaiqmFOZexQD5+tGdI95jSCsFN3oAh3P/pfsLfkld+c7AIRnMIco6XMf\nfShBpQ+Y6jZ75lbxFVvoAXHeFN7Jubg2iIehQDyXPkPNZgxuOUlBRNYz4zuzh/ki\nH5wJRHfvi+CrWmRGihyLHUVQQB3V3awQFVMyisePe+4jIWa3LsPos29VHYhwHGKk\nvec6kPp5dd8040yO0AvbQD7A3Bi9s64KDo7cPdLi2wMrCXCTrCHILuSgrdNDmb3t\nmzVyevU+6foTH4Gt5buED1otYLhA9JZLdoddeNJwM9a2xFYn1yHBUiqhFIWQ6G1y\ndhamUNuxR3MXgJZKhoJKuLTYT81JaFTf63qneBlOtf7B89CN7YVbDjEpVMAMb2l6\n+0eidDvBtDFYaBVdn2fmOx/ojDQTqAI8Lq8Z2EM5AixM45vUb+vIusU/EKGq1TIH\nysJJXECg9Qhr4Cf7lthcjxnq7m8+/EgG8UgJuWnuknpOjpTYXU8PYLZ8u0dWDa4N\nEhMxYABwPnmu6dqlCEubZ//EgApFcFKxdoShCtrByw0nUv60rXU=\n=DvGW\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-ppc64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmgACgkQsNpg+0VL\nrxhWzg//Xp84TAC6nKex2ltAnpCJQzql1CPauFW5Qn0bRKsUcXB1j4iMi7/piYwY\nbuetz+jcj7g8XpEzCvV3yrE1iRCiSqL27oN2k8JbwfHuhJWSaLaAANZ7FI7LUyMw\ndR/5sa9BrdTJbJYw0z5AmDYNajpOJLdYwOr6/rt3Pte4e8rv0rGkT2ZzQqOwX2tu\nbJyocHZMDwnk65iOPIfFjdWD32zDcbnUAxsUTWPktv672VYAJ131SaKhQOuyuxKn\nKdQALSS+maB92cG96IjnqagQR3S8zynvOz9uThW0yn9sA9u0oMkGcmHRdK6FdYQ5\nb5gaj3TZy1Qf8dHwS2+QFuMYSACMM5gjfF5L+iEZsn4pD+bRsp7QPbZSp5ebGOBq\nuCRV1PRUfqHFRMF7ZL28/I/RDCHhLY26Y6iUnFVUnFvuJG8TLQbGDo1Vkvj8GVQ2\nDr7DNQuqGqtjLyfkkueE6NFRtwsaimt74ELloU+RQvrlr8IueY9uBS0Tb7/hidMN\n2mWhjxiScZFG34+bjQAfr9aKlzZVTpL6gXFDNtTLsbf5WP8vDG6SOzfv0NaTGSMu\nYQIKNO+gKiX6Kz+rFJSzhDjMwOVCOcL6YHXKWu6aBZ92YRdWKMMbi2CvH5fblvEa\nKnIAValae5XkY9GXcObIoCQkWWEeG0z13vLUs3qXKc4THSeFPVQ=\n=AZpR\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-riscv64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmgACgkQsNpg+0VL\nrxiiEQ/8CPwASVeAhBg50Drctpf4c1MY6TqJvsGJaD4uTzjoUBr2BBmDEhAJVeB1\n/LsUnreZUrEn1Q5C1GglEbuVSPzrJGsFEI7tpwUOGiLmCWLJ05tC2vuIdc3+6PTq\n9esR9n8o3MrS8X0XI5uYUBdyXoEXB96CgJYwy9pD+p/arrXsxzfFh39YGphVJsGO\nHl1lv0aS27jsNUb8z3wwSo99zJ8zMEgm3xJHymg9yZnlF6kEUOye8BJqJStyqfvW\nbqg7UbSxIJ4g5jSvaaFbMdXiIS1j28pX9bS6NP37xHr5h+oGk4o/aoylEsKJeHga\nI60ku6kkh7pYGIYY4g6ymXbdBn1/fmk1JCUjwE1/bq4Atz1IpzX73HshPL9p47jZ\nMtc+CwcS0uLy4bXR/Uiz6SLZY+o2ivOUjAaqppIdv2UU25KZ2gMxxK6wRWhS4zD6\nEb/yO5iurIhrpU9ws/zVSSsaqPfhMNp0k/+bwRhnMyNXDP8uWiaqrKPz5tnLV13y\nO40Z45KaLwMTlMYCj7CmgX736dwfTQr2EZyqpiCTfcXPpQzHiiE+EXx8jtZNWLmA\nPJ6h9WHnTQt52Itz7tDa6SgyHi5Uu/ZgjXv59A7LTcbGM28sryr6n/VYd6cQNh0s\no0Q6XFYr/9fjPnxj1seUfRavtclac4BqDfdGQ/+MJJ4Sx/sPn1w=\n=u4Nk\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-linux-s390x.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmkACgkQsNpg+0VL\nrxhT7hAAuOrde3Dk3GIT4LAcUBE9FvYBmJNYoibCN7jqbMjyhv4ElM3/VO7U2zAp\n2mADufO9MGpqFn0H+eE2qfQJsfAfSDqIKj20LBnKFqxKQzFSrwbePlrBge4a3ODt\nk56ZTxM2ijHp2yPTaDYtKejlSCpxoJ9fquIzzd1H6y9MRHnOxA5+Fi7VV9XYZa5p\nymft8SyXVG86324MN7U8WCTkSS1P48/5vjq7Cv2Ng6saLneeGrQg0X9Wr76PpCSo\n3JYuwrPi9U/BX8sqcX5m98UYqQxdKdskeBm6FfzhG8cX9rhFTtOF3Ud/DiKVNiFI\ns/B9ZHSGLogNgn5seycLmPXukDPEWd7fm/XPdy2HtH82mUc8bEk+TfrrSBE/R1v1\net26SSr/XuEq6gtBOrDN8W+9XjpAeSJx9+HYc0kUM9cDo7eRKWkQ/5DqYc/t560y\nFDCOjDgJwezh50quBAtUBTDHjR+AkXelp8tGBgdeMTODC77wpATXcooS9NRMIpky\nfqC9bmGYojok9n6quYOUdmMUtIkdMtzYBNOGn3TOcAbiMeRxKolRy/JINBZ6fSUW\nchZHXtKGg5b0kjyAT1Ti9jl6s6ZqPpLarPNcb4XKQWtlGzn4OT3EkyCSFsD7HKoQ\nC9ZDd7zbRU7p3SwHh6lb5Meu/fDLWzRseJLY6n91CmSJQxEv95Y=\n=OjTY\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-macos-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmkACgkQsNpg+0VL\nrxin4g//RcbIWxy1MlVquBec4JJASgOISbbMGcyEXSATA8OPL8vIe8H45GR37z0d\nsaG3bZ99ct/o9T9akgzSX0ybmPwKgbGNuUNg9eegXJz5JFvSXKTw/oOmDHfpUoQ8\n+NAX/t08UPv7kVtvKFKbOqMzc5015c6fWg7AzawsNXbgzE7PxbruCKw4/duqGNJe\nImBuv4Rr0vhHUMTCfU0ANSnGdVswtxjMSUjD+sJpY8eKjLglQjCvz/4d64iiVEyV\nEcfz2vnkbAD5vtVkTVoL31KWntYvkwBN+O//fxGRFNfnWT8RYCY+mgEhaDGWpTex\n9cEzxXciaYa7hzMZStrg4bli1vs8MN+lS9HeoO4pF5ASnStNE4T4+UaDuu/jq85W\nHl5fybJ/5lqDFH0nqzjF9bsVvks7fhfMpiicuY9EyY6d7GIaktzmNHyDyMm9n2xc\n4MQeof2I/o2CzFb8wJRdMljUwg19fEWPDsK4XmL/CtZ0eX5JzE+vC6J0dX1pnOZz\nV50Kfj5UFpzncGP6wfPb+gFa2WCVzZzIpx38IMaiG1ayu675RVZQVQySX5ZEnMPu\nT+8dVYG2Xb2Q9yFsSjbvU7x0TFzteKxOOHItL2D5GqH97HZagOsRS7iO7/ihBGbh\naFeS5gAoDsErmDyCj8i2XsVxSpc0ISDYNiePZlX7ttywZSJ2qeA=\n=mfbp\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-macos-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmkACgkQsNpg+0VL\nrxjuHRAAll/Lz/hjYoVdwKRNuT00NzeazYGTtUpskIFhzmSGxJdv8YCAEKWj0C0j\nXAzeU34zEOXhzUCyHdsypmRu2zARDhzNr+mbJl7SGfh5cM+bmJ8Ljl6QbP69JorH\nIQZpMGvR1qv/fvkIBca7ZF9h69gl1MRDb1LLu4062r6Kgfq5VxeSx1gbLR5ghAbg\n1smqIo7WR8mBTuHLOC56bsZIZRlon3rwuqUkyYlYtiHay5nbLuH9HwjxsblVwtxn\ngIm1/MgOxRlCdfuvxI39bNULK9khiieyhi76Sj3ET5zhBQszxR7KjE4wEzwbkvlb\n4lmepzPJdawkTRs4BBDCKkk6Cm0dL718/CRuyxs/oVczkX76ylvHURulpmoXZSHF\nSXKU5D1pwREbyMFIvc7uM/d+Ww9yxxJngzE/0lawVFozd6N2KpwERmMp51QdylrU\nt/Dp4nTL1WwdMuStDdSFLX5F37eliKjx/ITEGzTwUBXCkKuFW98KJHEH7Doa8I30\nucHcG0EIP6ilX2+ZKQ2CIplra09k8N/65mBlHBPfjvm/QQRgUUBVkZFo25xiDNCu\nl6iDuo+U5qRgJfv/WhEl2fjKowhuBoQso3/r7xeF7UtxDOyYv5dGeLCm3IAYbqUz\n1NfxxrMh1r2oZa/MPg+c2V4Xrttf/X+cAPSRh6cLwaCm7xpkyP8=\n=/hN0\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-windows-amd64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmkACgkQsNpg+0VL\nrxjghg//a3k8YL1fMg8gJu4K7seXOOwOoP0Hf5NJolQRBC1GXh4JW53ZSx7+KhUH\n1T7PQKQ00yL5oHgdYookG8uOZ4zqkl7OKqu9Rryrm/u9GOw7HWfTqs/dJL5fQ6d8\nvz+bHvcMLQEiXrvlsZ6kG6ZO+1yp3gzA0MS6HZ5G3o9wFrt+CuA6CDlA9K221FBo\nX7t84dz69rvDdoAf6EMOieoDnI4nDxAE2nls0oWA1Py3Z0ztfH91OROPucM3uhxr\nRM9l7QKP29FvWzkU3c3dmaXNWKGUidVsxJtzqynqVZMiJG/d3fbiErFNgPi69ek+\nf9D53DpkxVrpEw3fcUrsU9tEdOKRTujzYC7O2y8WozCalU1H8/Ue4YE7uzKkhlvp\ncIX+OrQQng2vDRKKoqwJC1ANTMEBES2XEreoxK7Z0xNZ87WGpYuFzjLKCIWJM4Ah\n4hWZ1ymTMJQEvqgy8vhPkNHoRuSrp0ZbbkcfsY++lWSzvK6FK2VsmX4RSQmNtav5\nf5qBVAhqXURsLoRarRWhJR5VroHGefevFiS8ij0V9GedMowuSGsm+7lr6gvfOsuU\nPH0DD7G6ybwvZTPKSeNFGe2YwGwVXG/WGI3p0wVjtRuRAftZsCzKmQ7gPK4gFb5L\nLyvItTaST2DA41CUJg+VXr4T5GWUJvxjmNjoGAgK2M4RCmcQ6xA=\n=lqH4\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/jq-windows-i386.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcmkACgkQsNpg+0VL\nrxj/ZhAAxVJ3mXqCkmk7/6CxTmXnZZreaZz+RPsFU1lc1ZZ2Lx9xJS/jzOMflWEl\nLw1BtG1wWgxm3P2ph8s4bdI/vSOtmZbg2DYCwOEo/iixFbwgdMuXjEivKMtxSFKY\nYSoD+JHjwd9gpZQkph0mEHQ7radsFTnR9NME32BCPzoGa0403BpR3dQFsjCa26Db\nyjV43MY0k0SOTtimghZfyB5r/guaO+49jR1TJprNV3jSZ4eHH0F21IJ3leDVOaFC\neZAkDN9GSfW2Cag0G0e/roWSprM1Ehd0eGIMZ76b6/kf1vhyaSj6EXIgxVg1cW2C\nghp4Wzzc27oS0EcrWHJS8KTQRPzLXb/PuCo/VQddbi7PQ1h7zeoLpcsDPAWfrOHC\nbfkt0uxiXbbdDjlLK65EsdgcpzRDYPsPSk/yvh3cNR3ZWUYGImjEt/AKNNTvaAid\nonDIdf7tXMMbhXUzF8+m2GoxsDegQDVw3iPV6liWub13Sz8aUrTeWclWp262NASr\nYEV5lJj5kC/rjGJTIjPXPvOBXVXy9RuSgFnY4yMU0QY0Ih9H/orwHQW/LBbcQG7F\nXm6jEKdBVxGExfMeizuaT3IlbBl3hpEGemAuzuq1pQgD1ru8fCh/GCyO5IxrYs4l\ncIjez5lCml+pHmQhKbz4gFmFt6ioOywTgHCSY8GAuPIBSzBxp+I=\n=cXGV\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc1/sha256sum.txt",
    "content": "a6a7837cb46c61a8666467fef06754fe53b95c1626b5416ada58edfe1393dac3 jq-1.7rc1.tar.gz\na552843335c2939741ae4b52979d6a3ef6057de5518fd4d9547d9847a6fee897 jq-1.7rc1.zip\ndf823ab1c7c9dbe4bca47c5ce900cb71573fd4a522411eb38dc8dbfab339ba5c jq-linux-amd64\nce66388d20c6cc69d95b24f50b03157660c60c164db23f58e403d0fdd6b2e0e1 jq-linux-arm64\n46360984be3ec632d642f77a3dbd4730e77089f847db2c7b7c648f4032e7fbb1 jq-linux-armel\n0ad30037a0ec8ecd15ab0323aa402d9f4d5ca93c4fa1318b9f08cc8ddd739f98 jq-linux-armhf\nf75abe58677fa16ce1a93215e4448ff3920faaa78da2c6238b2f9484e193f4a2 jq-linux-i386\n9407f122e820e0e5a0819a322d8232bd1e9146347c658ba903eb85768fbdde8e jq-linux-mips\naddd2e0da5c34c975da6d5ef12629606b978ca823b99ab7e8bde7dd8440a9706 jq-linux-mips64\n89c3b6daaf87ae7a70d0d8e8aab4e9026e097fc8e4dd950c33689ba6360f6a96 jq-linux-mips64el\nd2cf17cc238e57a9373ae69e6ed7ae3eb918e0a0a76972909ef9e2387db5a0d7 jq-linux-mips64r6\nd07023b4fb28fea0240c0c37e774e854c9378bc606dffa4c183bfdbd1d08d37f jq-linux-mips64r6el\n5aa162cdd5fa3568cc1550e4ca4dde7f9231460877d016717a0475a79571ea03 jq-linux-mipsel\n2ce97d0afe6d6420d2f0515a10e64858e50434f38f71597b7a2f703a12cf500d jq-linux-mipsr6\n3f9ea2de719988c13bb355225faeb7d05bc04c362fe96fd8333e3f7450d37514 jq-linux-mipsr6el\nd127e6d3c5271784ae5a5673869d55e352fee3ef6ffde66c9a08be4627b6caa6 jq-linux-powerpc\n5cfcf735ee21ba01151bc9e03540bc5dc373df5a7ce2389bd9ecdef4e82301c8 jq-linux-ppc64el\n7db74136fe72b143b311567c9b63a16107aef7237299fc3a5749987b778ce84f jq-linux-riscv64\nb7dfc2af6d1a84957987a1051f4d20276655433b2e8a5e085db75f6683d7a52b jq-linux-s390x\n299dc32bc6fdf2e085e70f7efaed72da8b66fb4287b323106c2174dcc8248357 jq-macos-amd64\ne159d0a02bb5f41930f8d9775777a2dde5d9e6747666e285c00d5729305a882a jq-macos-arm64\n56c0361bccbd325bd1ffe607b64f955c30fbb800fef0d58c5ef69e2a242ce577 jq-windows-amd64.exe\n9357fb09f158c880e5bd67d971bb98a33a2c0a1ffc33e859533a89b28c914a76 jq-windows-i386.exe\n"
  },
  {
    "path": "sig/v1.7rc2/jq-1.7rc2.tar.gz.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnIACgkQsNpg+0VL\nrxjNAw//YHABP13K1tpHrvkUkKXAu4zmXRMMdR1cdxamvG1rruA7MxsOh7FBmfFQ\nzZAssCk6WrrMANmDd0dEpxOCiT8qPfP7hE6fFf9xbSpzJixjIn2VNLc3KkS26aB3\nwV/3QWqJzExz8Bsw/6OOLjw3fL6e/69x9sdb7CtNVsY+8CNIXR/rLzbvEn2zK4SK\n0PtHWMDPfeHR6o7/TTvfKKdarroDoJjj2ACzg9IGtaVoi8wADdtF2lBzeccwbd2U\np5s7GEb8HecN0nA47DkzkZjb3MGvq9KTJXrVNQ1Svn1a82jSJq6FoeY2D1ZEoyOh\nd6WSK1s5iFqU8v7GUeVIQcKnQMpwYGRfzeeWktAQbca8WS4m62vXVPrnfkJnGJSF\nSRXq920j/AhhXWv0LiDxUIlQdx+7nfdGsWLooyRoR59KN4J4IkeBYVLoVb3QHvhY\nN1cw/pC94UzhxGlWcDG0UttNPhIY2oiop3mQKl6cyWIpZddIwFHDvrr22cUfZcor\n0yZbQvpCr09xAWE7Lefg27tR9Q6iFhktxbGuTW/9zAqjmTP1anoJ5eZpH7tViv+/\nfar8JQkAdcJWuFn14oTvLbfwvigmCPHInHfLwnY0QK51HOsElbllQLy7BFlk6fN9\nuMlSJOUfpR0S/v8jKaq5tP0ptZP3rEKxhofMEbUCbd/FVPLyq1w=\n=yNWP\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-1.7rc2.zip.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnIACgkQsNpg+0VL\nrxjjAg//SjVeth+bv/MCkT5ZDiaaOQ0LRjhRLWthO4A6VPpmdtBuEfJ4sbd7IjHI\n+G17JJy8RwZKDSEwhEQNNdvCPaD0MFZkzuil9vM82kcw5Ao2qir7lWqNbZSYcVWC\nxbKZys0n8GXEcCeaYnJNmlTfHfZYZUWcta4BvaeHEp1q2YIXxkEIqoFvxX7P0SpS\n7vxiffj+rSOLY/xklyrpl40A44ukxpwtd7DGbCUecjZAUTJC1rL3ZlD3jf9qRtQY\n4QXJ09XnJuUSHG6FCzB/BYPDPzlPlu9amhK+tIkMkyo78FlLy0mUHIsf3g5GYhh9\n0ylQUFgBpjIy6449a9P6XwmcBoLE3ir9+RDg6Xu1am5L7XipiTcE0lx8Op5ZtuzE\n5iR0+EFa9ZjevFCjXhSgVE1zqoa6u1/9wA0v4jWVPKTPOKs90MSScdz3hgS2k3XR\nvchm84BN7VcD7ob06Vcd1G1FeWHJNKrTRufHag58dHvqQF+F1bqRGsnqPkv8avu1\nA7o0HShxRBpHccxkHKDmjN1imkxv0WOKH7kC71Yr+7mZsfsrOfCTelGwwHE+CJ/5\ndea8VbPNReX4M/r84fo5k6+epGmhSxvH5e8gOrj4u6uK541xNzGhJxUJg+GDYHL6\n87e/UdBs9V9NDPkdLJoWJX2IYlXUectZpZMZEa+TjRgD2w5QX2Q=\n=Sum2\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnIACgkQsNpg+0VL\nrxhSnA/+KGGXVk8TgZD5dS4k/y4hfmZsYNqgOEK7tYTsJubXwLWOzqUjAJJWR7pV\nrzp/XyhUr74692elTMufOFQw03httc2MjNnLCetK6x4d1jAvomLJrUIU/zGqn4kr\nwvSe2Zp3hyNLepVm03oVP0gly1Je7YMyHXeuqDG+TBEX4RkTsTaJCnl8WN3kTtXj\nv1WHo/18jhJRfMoj6n+dSGXk9c2nDLX41QPSwOM6Owyh7dwjFZPzTcnNywQPChmw\nsgzBqP2PHsRmJmtYaBJedwvVZ27egiMV1Yy9+T2G+5RpIXmrQMCvgxgDcF7S3t2l\nkNVsZN+nurtbCWM1YU4m1pvDmCr4MFkruo01rlXVzOZLDrT/njF8VVgadhsXfmBU\nO4dU2c7XR4x/rTTEa57SHgD02h4nveM4tp7mUPuVVaPRQA4GqMKEE8MtTv4Q4KgJ\nxRdLnKdr0r9JhVJHsrjni3bqn1fGOY6o4/LqmDRoywHT7uTcf70IEzHxhSPZtLag\nR8j96b6H6LHCVjET7BIl/7WmNcvIwU/6OR/QJt+CcJn4dVfxKBMix3rkg+ZuH5lF\nvm0HAI/uSEwDneZFp5RomFvRH6UJlB7nrWdXn/Rh526Yj7qfPbHJWnX9/BwNnpzL\n7Zpc2EMdb6FoXtWLUL/E0NNQW0tTr7B33ykXXAUG2DN3Z3ce1qY=\n=FtAN\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnIACgkQsNpg+0VL\nrxjDNw//Q90Z3WIulbkc3hiFizXrN8XAxQnsuuEjUI+2pMaO4OQnoB0UFL++ch/t\nwfnwEAL1IIZtfZe10Mm1YExGQKTpiecqq0kHN933AMjAmTWYcfIzfOs444T5mPRn\nHYmx4bFEv3cZO0jUoAbimk0HQdcS/ew2txrpqlQVYvihT27CkY7L/fnDbnum8+IP\nAUKotFpnhfFYt42l6/+MwVBQdXnxb9bhJ59PrI19Sq4Ww30qOVB8g+Ms++LqC3V6\nRpzFUUeZBJLVw2O6RFS0DsZdf2TR51hX0LFOnCLq61QskqFlaoghV006Bh6osBY1\nQpMV87n2dQ62PyAtJAHkNii8cKe5na05L/05PrRc4ii6PAGpkg/hWbIBRd0Ez9eq\nPs+GwArG9uVEDSYi1NQ6z3fiQaiHxnwENAmqMPxWi0ZZtv6wBsIGNWyDaLXTnFyD\nzBu3XzLs4Rf70sVDYlUmAgJ/lNzwHeRA6rFQm0w+TMdb3seSHd9HrFFbFEeqSwlf\n23iTyyKnC/ZoVrA690/3bOtTfPJrPAMAWKfJxj8I2T87TnvWdlYomMC0mkw1/Yac\nVuEkaFt30MNe/E0EuiqfDgJSfnPke071zCdQAzyX7ohMaBpkBnZsLzd1FE9Vh6x9\neo2hyO4wgPzXadhIzQe7z5tmOsHJVb76nWSGhdsnb+yb4HRVCTU=\n=2NCH\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-armel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnIACgkQsNpg+0VL\nrxgNOA/+PCuuLzpM8J5D3lIJzHr2oNsGNRiAItZG4PRbul92VhKPDGB4NOvfHHRM\nkj9rbU6Vn9yFU2/L6W5CXcN+YEGobrr8NFmnxlJifAhQlr0ziHNqrew37cvy+GC7\newJbewRckpdtYkoQ9YMFHcYGCDbcCCc3MalLso1iS1hI1OFRYH4ydXlTlknUC6Br\nI9kxsLjgIQC6JJOmQbAWZoCDTZ9YPKt4APqmgg8NddD3QkgJESHUWQvjC0Qvbe1b\ngCFyFit033xLMKnONy/AC2/SyC6HY6qkfU2dWwnDCWMs1yOxoVBzKC7Z0ryheZlB\nEiraPpDR7Z4WjF2eiwQiuk2rJEVH0iFPah78MhZwtPVje2zPyGDTsiGuQJ8aGYFJ\n3Zl9afZQ6/ujAcxuQdFJkSWnVw7VqLl4sZDa+zKCGl2iuOSa9uuU117Ib9ZQtHXp\narayRhAA6gJlcseUlkE9MLPLBISzexa4RvGsTgaX3Qhap148Ehhg5dsnesQpTT9t\n1z0+9JNb7UZ49Pi1sw81JyS7LR9iFpwSIGfgMChLh0I0eRcOD2m8jD5/c9q1SmqT\nFpPtyxbxHfsjMKf60PyGVnkAxLpxhD5Y2ngAh2wKLUEQcwWLCfvu1mlpDFW7WXMf\n0rI4N+Js8tygqBhskYC/A+Lvd/g6oWfVVh+bXeYIcLmTck5PwWE=\n=Vnt6\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-armhf.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnIACgkQsNpg+0VL\nrxgyAhAAqHyDyFZcoX3JD6BmxS29CDcrzmOqARjUkQqLxxQ3+O7CNIKJxKrxXmLL\n/aPXqA8mtr8HohQbt6n/G39/5HyrKLI2jnxU71El3EXwo/y2DzJsYylqgD4ETVzC\nBfV9VodC6/pdCa1xJSxLzD9kMzrEIPHivUWjoLSO1H54MComHh3uzpZV4d4J7DAo\nrUJeshouLxy34/NlvTr1JZg+sdjvJUutCeR8iMetVg8smNcGFOLBW9Cajkts5xwx\n+txZ1AsoILGzAE1+bFHYKDDo3VJGiTvJta84w2OHFaJkfWVMYB5IUtvWpxjra1hB\nrRoeUL1wA5vPsAsuX8Ndn8fOiWaUd7N2JGq0yZcsaf9tquhwidIGg9zloET1mJCY\nlT2tlsdMNhHUYisfXgZew0WArMApbavtmT8+9esWKc6iByR+AvPXA3zfqKcA1CI7\n4Z0R7Q56O7/tyXiOz9gvOkbvutznhl5MW63ptieMGzqHzLsn0272Mi4iqOc1h2yU\nZHcMYibPOuzUXcgEWxp5v615Wty0cPfwYRhRGXSNR+kqXWxw14bCteDg3wwLsBpi\n488yhXydJ/X63YB5mPNMKsIqLuRl1/x/aRWTBGC5LLx4clg3sLtIxLtY1kh4q/xR\n2xiZOC+tZLkGKLz6KrkVF2Auy2074TfC+8f8cH1lU18v/rAUuZ4=\n=BPoE\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-i386.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnIACgkQsNpg+0VL\nrxg9HxAAipIB4LUOyRgT09imIt1IB8ocwE4YTPhhwD56axCqaslDPBNZgIyyWJ+P\nIMW0CTgHrMVJj9FOtWQT9I2X9d4qlueBtj9/hY5rxqt4HdyQwZVfaABjmq/Hfv2J\nno+I9o2n20NthtYMCfhO2pL23HhmmTow3hcovccmyXPKJb+xWpUfh/qNIDss2DRE\nntHIZWEvDnTCUeSk0cFkEwfvEtptPMlCaH/2gqdqFJp3sFxRz+7/xnHniKkKmxLf\nSx1ShI98/5D4CTZu1wJ/3SJnT8HGgOfo7aT19s/aFG/OVnT693XDd289S1SbnEW/\ny/iObtsDLJRLby8EdGQNDEsp5MABb+e2nZmuNsFcqc/Uo7pnMLROd7aAT+dfXaK3\nBGUiwfNO6w/C6sPXHmgCKiHL9l1/gtCYWcMBtNOKuVYRCBqUzL/mKlLYJE95H6i1\nkoBxWn2VIy3lfuLs0gCKZCuCQDXjRHvhuOhIbM0BWchwpG37MC+3jlFV63Irv/xh\n1IGiCYLt5mfnLglpBAM92Irx4KKaFvX0DvF/0A5PGUdPDCWHfE15YX4CC+XfJ3rV\n6KgICRJEkHa9DqbymMZ+7I3RRw/d06tarv2fPsTHFPNeMBAqoRg0lwO9WaSWQ7R+\nksu0nwRVlVY7Dljw4uGjF7qRpIvCB6/aljDklMaLrdgDjwVTSgE=\n=SmB5\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-mips.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnMACgkQsNpg+0VL\nrxh2OQ/+I8uvLk/WJmfGggLcW/l9nlD86lEwvsxjevZokFAG0z9PSaQuN2Z+4T1n\nMD9uHIqJuxvDHOp6hAI3IrCzKISV59cBRxAbTgFPU4s6DVW8Y7NNKtEfk7KUiYJK\n6Zq2bxqSVrpoS/rIuoNj42BLS6cTz6v7yJ15RHHERkQ9GL2Z+nRHfcqovz7dOOGL\nTb4y0IQvsPb5/L0O1M3AzEYbcHwCAtfEkiC7CmBJlB9DCC2qKq8yo9pYVZYpDdaA\nuwotwYFREo8NoZB44l3P8GlVRVqDsqImiVODsY1InMBIy0q+7c4UmNLkJDrLyyzn\nJEPg29vY0oOXN/vK0tYlRc+NnNESvVGsnGnKljHy+5FRFDH/mYJRxMzFlTEnV5+g\na2+sPqksTdtKJUgHVo0UvHb27t8WRxxcnXNsDC9e/SuCdQWOJufc6siJiUEOnUWO\nG5jUNTFOiOewhLoA+qSN6q6nlMrXPhoiNe77lnQlDqf2B5aoErUNLRNPaZbz0K1z\njSlOYkOPHfnufisa7/cHgbExLTTB5OJ5cGKkOpuyw2aNmqFiyfU3qsKX23ybBFlT\nRQOzmlgpaO+FhJ/tXyx4u+1kCNCOM2OYMcE+qqVaQ7nTDQ3hGdblWby7K2PJm5tT\nFq1P9iYbk1kBEFnvOZEKKvMWxqjTTVWu3s97abiD9yehce92wUs=\n=HInu\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-mips64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnMACgkQsNpg+0VL\nrxhorhAAsTr+XX32+V9lKVdD1rNSeMZr56Adudf7qibQh3DQLHyborqd4FVIl+mz\n48dhTWIEs2hhjxRIhBbRWlh+H7UKIfCYIeicPxQ3wtfFnmr41pYpVVWq1zCsA1vQ\nn2Wn5DtPvG9m6tzgyYqTLbwESz73xBrKV9QBT5QjWTtqACr+LRkAx0BAVlVfGHBP\nl3ZiZCm+T0tFJo3cxIBW+MI+hhCNSIsfWUQri+MIccJq7s/hZQKzJnLzeFfxC7SC\nSTcbd9w6xrY/FqZMT0RBsJmo747XeYumS35gtkDz0SWgT8kcmwgTVK4cFkUX+Z+G\nwV+QvNilYrflrHDc+dKQ+SPywGLVXi60V+kURBKXXo/1Ub0gJYIKIcW+fgEhVPa6\n4HOvljvbXFgUrXP/94q4HzoXxe8eg4TuhUUF0SgALFK9MTXxGR41s7P0gkYrC0Lp\n8btaTfttSEFpDvc8DblP9X1tNEKcILThln/DSdMmchMpYy0vH1uO9V/dPBN3LqrV\n9yA8RR4k0fepWDLk2Ux7KGG2KT76zzu37/803x+AB3ExCqW5uIx+dmhdftD7p0VP\nspTa6sh8qlj11NqvILZml3vwRpF3FhiJ5baNKYUCGgt+Jcn4MQdB/lcEE4VGU5Uv\nsT5GgIPuxq0Q73oVd6VdJlQdIoMJ6uZfUxYsxtlZ2Zk1V+Pzx2U=\n=jYTD\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-mips64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnMACgkQsNpg+0VL\nrxh12g/8Dui2XSC8rdM9ruvp4zIqM2eL7LPbErgxcN/yzlfIPJ3GKHUJQmsTnmQ6\noQtiNbQ7qNjdm28OidzweCUh3F2Vhcf1PeGEOlw59qG73gsL3EE856VAVs+4XSgm\npBpmL9qmppMpnzXX+Rr/seXZH6hNW8UPa7Y2idADnRBa15wWiwcbrqNdSaErWY6m\ntVObgEJOSETzgcJxz/t9v3gXVbMARQeZJ5Feom4DAA8bgNyUoFagX6TYVYWmKRZT\naaIpULhK7BGg8pTbjFfvzeFzVpeEQ9OJfC00pI52TVg0rxrzKqMZeI6PGgVnoEJw\nE7nsqq7fhah3yvqckLm9eEbcSD9LyUM9Uqyw9Mof+Ufnb+P02DMLWBgW6BxfC5nw\n18lfXUKg8TmABCMm2KrsW8OsILsmHS/W0XybFcVncUy6Frzvg9ckaHrRBokbV1Nw\n7CvLLO/WhKGlW1QnNMdixEXCnKzqkN+jNYMw/DMqzB+Flmfz87g0Z8UlEtJxlz1g\nXZqON2mDvuTjDKIZkTYtrbE0VuVMkl3NJDibf7O1AgGud7D2+HJjmzWdWnDKQuDt\nL7o8ebfTIP5d8euFP+q9hKjLzb7dEJ3siOjxvd/PQPUuHJLDRYfjoLInj4mqnAH/\nL7BixDKh4xJ5orfJCIAQZMXPGMCZ/iYU7Dd61clpxJqbRhgzwMk=\n=1brC\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-mips64r6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnMACgkQsNpg+0VL\nrxi/SQ/9FByl5/uAtnMzjWYVXVg5M9++dd2OVuV7q54YbXQNJsMB426jAn48xSDO\n1O31SxuaB3RfB/jcIyxSM7LYC9GQuIHBlrnqcBiIDH5GOPdyArtRTnbquC4JuYVR\njEIbbrczoJdp4k9+2+XnpcWsUoiKLu5v2m74KPErTvxUytAIlg5bP/o41qe3lzuB\n2Wz6rzzRVBbqqwZtYOEe9lt4fmzSG0GmoP4c02ROAxNeiDSO9I9kZGOf+OLDxCDy\nuowHI9zNIgb6yEXt8hScuphcIPS5WSdn+XT1Tp4VytuF/tJ3r4etOnWUIS2Ak+YV\nvKUEeN/9jdtYpNTjP2nYyidNlDZgzEG3Srq3O7jY9eyH/HhVJXH1rKW44E8xbkp9\n46B/mVT41njBWwQZFzDS+27Lx+Y7E1ulPzX20WU8OQmoI8UNKPSxwvwDBEGlSple\nOWhm6IjBEmTBPYWRqn8NmAnHYhB2ySkW5JpDekDcmnCAh3a49/uSDAm9Tk7fVYJj\ncA0SnGGC0/dfNaHkXi/ZDs+mjrDdPRS//FnA/KuKSD8jLDWbv5fHe8zYFRgv38Hu\nL5i8PI6UPXQKNjKtUAz75Sog16xa8VnCwHM2OWPUp+lLW1j6WSomLsw93YB3QFd0\nEF6jAk3I6fysF+xXq9V25j7V1aNfXq0Wfx6HAqt+rfeg4kBOyIs=\n=TMuh\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-mips64r6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnMACgkQsNpg+0VL\nrxjsuhAAySYBBPWV7hEQ/1qFlHCIZexBjycLIsp4tButfx6eVZGN+J2zxiP8riTY\nlBaVJseeJVQmnuJ0oOmMLBbQymZj6Iv0Mk32FKiuC1ncPTl8+QZsNVdtse7r2mfC\njL6LvaHfU9qwfMiufA8BXrejPOxX8g4Gv1YCJWAc++H+eCxupNVyPtUYFFEb+gr0\n6jPxkeTqudAKah6gAfipBHnxwutc6BG33uHVAJjcGEdf9KqSVNhLzp2S643c9iG9\nwk/r0S22cRS8x/HdIXxLwXj01ocxbyw+vMTAQo35CN00YXqxQShnzM8WkNKiK1wA\nQIpoQO98ebV1f00BBEfHe4CpMqtVSabrTSnVVNmiee/sOIstNSuQb3+BVLT5VfXa\nAs30sUQI6MHIkVwDw/N7LFj2sT27hJEgGR3Lcjb8WSDBFbfs9k6FOMuIc7gc5MUJ\nuozyLkUSi2QQcdkxWooQdMEmdLxeB5r6jv1aPSc1MJ4U6ZvunEGVEsI8/g34DiKV\nEqtSg11t6ye7Y6gulZNJFvNFR2jSzWmDOhpEctkzFMsRWCJaXQhrOyDOYcIfSzPr\nco0ACbHgX6rZc4ymtNjg6RwWkXJyGtkPdaAQqQdhC6efpvK1khcsdsGu7HohMHsM\nw4/u7d2M70umljsVRZf1sh7C8wUA3qO/quNC83sEs2+9+dv6R2M=\n=hHjg\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-mipsel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnMACgkQsNpg+0VL\nrxgmARAAr9PkAo/RydnmisdkxdMnse1yI6J/KigaQUi9t34zmAeohKkgVunmLir7\njXmJdK1GKYmkf0xYZ7Bd5M0ktffk2GLkl01J7mzh4lU4vRWpAe19Obu6rMJ/i+Xt\nfCdd8RBfxToeVORx6J2UUp2ux/yg1f0MfxvyY6Z6UD+EMTg4MH/L70ZqEbG60/h3\nBTl2QPoqN4jvACsjI2Enhm1GuF8uCcv+QOjoLnxCl0sVWUICqqhv1qm+TVP0mRma\nxiP5lxEF3Y1pMoDpg8lhZz1/MNSsFucbhJjEv07Ly2r7qqeEQkqwHMKebVxMPpQr\nA73PpGX0Jk65fSh/KyBdT9p+QllLiJCkIbqrSwcN46Ii4Pnml3gDv4kjBxCWR2uJ\nDiy0TA/cIt2jyQgJO907DUTjyBto3TUMzeiznTR9LBc10hqjX+Po6WMqpplraDtI\nSIFVaQEdjnqiV7pNQ9v/Xmxj6/hBJ0jYtRWBAsw4n/hbBCxecThlu9X6NAXWvokY\nhQSycKlbRoKP0Qkv6/OPJU5/2KkccmFUSt98bKg/dCx7KqcADX+DmvGyxV0Zw8XK\n+LonaNTFZUNsa4rLgNUOG+9aOyCvhw3Mug3FAAW7/9o+EcRNZxGhwy1G3DMM2kPU\nmo8mqt3K++OKU9CTq6hlfkzdYc66gTYnEcnMuT8VmernlwQtmuw=\n=er+w\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-mipsr6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnMACgkQsNpg+0VL\nrxgFww//fa9pBf9kvuxMrfPrxB3xHHwLxoVsQZBtj44wbNRdRGYyu7leYt8jT0a1\nFUyZYZ/yqRAxhE3NRz3qSr9Y2W9Nz5YUYZBUIzCzvTyTTMAlQJKfxW9qBUV2U+df\nHQUOxou79d+oGMFscHodkOy2KxztwNAKPKRgHrg+CsHnn58IThiVJy7HNVAyoJZ+\nCqWo7XrINpA7vy5jrpgy5f+JBg5Lgn/5G8Y0N9G6ZNJkJdQfmNlHeMYzG2ChXSD9\nYvo5QrPE21kDOCSmHgcem5DTgvfeK8ZRfNK0dyhRmtM0Ba3xk1WxldmU+k50DX1i\ngVozHMnyucke3VVpQNl+e+TKndu6rKgoRGPoFFRLwsYIy73upzmGdg6BHH4NZB45\nwgjngXTWMrn8OmFEqsPZVWbBb11FPeA/vxzBgEYf8dtZ22yVwHyZOAjAVIWeL10q\ny6+SehTQut8TDxLc6u4EOkRH1upaWowfAY1evQbr/RbW9hhfE1AhOyDYmOwNlKcw\n5lFGTBZ2DmhODkhxf8uBdIPYIUAAP268v7XESwUmEAGaO3+hrAF1KMBQZcroYXBJ\nB3G7qeW4Z3QRzkKYXa5jRa2xpH1fT1LRaYXiNULBBbowTVWlaURD+ntyxecayEkY\nuXXSxQsfErc/IfXaFizpimSukbAVg6YCiCox8p+WLfN+RtwuMKE=\n=5Atn\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-mipsr6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnMACgkQsNpg+0VL\nrxhTtw/9EoBVXkrh3dpJd+6g83e2iYzTqdd4nxC7ZamuF49WJAPg89yz8HTlBKSg\n7Notd1RmkfHV5IDda59sFZz93YlxKiT4D3+wlCgnpwBIO6e++899yGIwTssq3xMt\n5MzhBvbFv4+47yNzouKHlEDxjoJ36VHt9dRJP8xSjO6PC43yFNVnlTvYoDof+2td\nXwmTDw+IeRJZcw0ak4E1cxlWmlU/jwl+bvhcMY+AN0ZQsHJuHIFus/2fSq3nF6UG\nFpqE6Gend6665z2+fpv+i2hyQZerSO+2Coj7CVGf+cWQkt8zymEAXPkff5KpxUAt\ncQZgzp7CBi0DhrDB4gOCFyYkFRxq5rITeBfvUbtnf4DEu6n96nuC6apupysZeY/p\nEnnbV1tMUUF/9FGbd6Ar1XkF2IQ6HfV5nl81ft2Y6BSE81kl4Wd2SVnTmZrMNAWo\nWotGikkyysTOixG3hu9q2tnU7v/jhryiVDRqegqkcNn3oRlx31BNbfNJ+j23azUX\nPw0y9irQE0fFdEu69JFkTKSQECWX5tZWDFy4m5DLc0UJKBb5Tugbtq/iY7uU5iwN\nUZsvneGNaNe39Hst4OfCTrSLSH7NCEpxnh88TKtqGexlV/MzpxnR1h8wuVrwH0Y5\nddtam6lKb3PzP82d2ZR4aeLOF2OUbmgN6GunC2YdDOWL6o50Nmc=\n=9h7C\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-powerpc.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnQACgkQsNpg+0VL\nrxgvQQ/+NcKAxuyiCDLXNN2t9fv1OwzYXDU/IsDVndfL9W4LN0RZljAS/vNHov3R\njfnO5vmIkpbMOMZ/qebuF2FF9VZWVeveMJoTDweWRJ2+lcc8v3OPsR6BNL9Nw00N\nTy+BaJkF5dj1MbhIG6enRmkvpx5JpYxFXvk9T/AaCUhQYpwyiKBlc+LZ2WyMgZ9f\nbNRmrPQA8g643/C/DuAgho953SW9V81iPno0EyvAfqA1EcCDZVZ0Zyhw2Cj9Nb3t\n5ahp4hQlqocBSUUE5mWegnfLDTZBn7Of729MpwFJdQg0xWKrxvurawp6vM7CtUBg\nDo+kAbGU2wl+b6HwlCbLua1935g7+h+VOaIMY0ppGCV6CvaJt6ZrkF4DdTOB857P\nO+1HJ8EawdJKY9s1Zwy1/66QtQJm6Kaexjjms029Dw7bnFwtCPtMHwjePiBVR8K2\nu3384gjuOwc1PKPWF643Wk355wElgXnizo35cY6Dz2ZoNLreVPefeca26t0lznRL\n2lvtlz5YzTfIkhLAKSyi0zB1LUpwWvyeamyvg1CNf+W2nrTgRAzS5J0UQ4nlYEVO\ncPcXSnkWkZ2vnkLGLZUGtOdMZv+2n9Ey6ss6KwbdiOAncZkX6EQJGLiGqXkxumgE\nfJNPf77l7K/MTVDlfQWPeOSWH5KAeZq+kpsR4wFvIFTGxC1u6aA=\n=EJKt\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-ppc64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnQACgkQsNpg+0VL\nrxhA0w/+Nz6Qwj4aZndpyYaE5sRmgpwmCUjCCycbvgh4JSWm5fwoN0EdWcu9i9zl\nFanjXZAbheRdR7zdt34gs0bYIGXM9NLJpD382zhY+woQC3oKjE0AO/crwjSt8sGI\nEqdOrLb6I7lgj2zZ5kmCPOMnM5buZ12NbfjlRsGXAu8bVfHgyTM1e20rUSK0ldFV\nEtIlvdi6dOZdTebBa3nniNSUzyX+csXW1fidX12k7Y/VTNO7pU+veGb6EfwrFR8n\nXmKH/zKT249SFMDCbcZs3VvuzfDJ+fBCjqsEK9AxCLsffkbLhJJqlAOKZaSE81g7\nVwnwV5XvyocG67N7bVe5fA4b4eqBPM9WHpwv6WeqP8VCHkyLm3EJdmQhQOrcVDyF\ncA1nHlx8fw1VKTAV075l7bscEz6QT7RD3dpWqT96j72SqDxfzuLOBUT3zolNscHc\n17lgr8j8/qs85GOBMtJRb3SlJZb+aLIVvEZtKvwYVhM9bdG8+7j3N2fKn4/U3Tj/\n6avdq2JeNfVeUpPGp9AmunkNfkM8+7tSK6VOY1BZwiitdjlFEdeJp//m5ERq1ul4\nolxw2LIJcvEYzLozPRQCbeA+xgoJGBkwUgeF+o4YBafhi3qc8HtU0lWXCO6pa9b2\nsXko60PeBy1fBzZSaO1t6nPsWsuIPPL2blLS2Sc3ShEC3/6Avc8=\n=nlSk\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-riscv64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnQACgkQsNpg+0VL\nrxjquQ//cBvlwCn6IH+wr7jehS2J4chhZ/vT5hW4VkDuBXG+LnyarfGmTtGOhCRx\ncyEO8tqOAH0tql8SedFGJ/uBRl1M3cX4iy3AFPwHTD4Sb7Qa+/lpfSPxJjiBeVRT\n6KLEnI5eU8yJmpbGLIrJGtX/kFQDNxFcsw2htpzWCzjCWsba1LodD2scHlLTw/Wv\nRTebIeu+cZ5PH3ty8oA1baPZWH53WpZzDyNSETOSDMmyCwf6ZCuCi5iGIKftKc1a\nkmmM/o/dWivU2IOUpGOzteALIgbiE+mMx+7uars6a1joz4Kwaug4lUZq2lUlzLfx\nC3fKfZqjN53tclfSdl8MGrcC0gbSxPAHcU4X6pvHOKxEDQgzs8Sj2wikCq5TiHKW\nXI6noqqu+qu51er3yJomG8s06DBl8T86zggHo+XqqgFhk7x6X+h5z9Tl+2S/OOE/\nOpQIH7e3lZQ6yFSd6nnfLhC0RQrlfs9RWHRT7xFR93acFnl5+9ZbvmDS6CnlhD48\nXPXvlgOe7ZwQNUK3Hzz8YjiMEtnV19XxoIu7cpC37dde2uuMZrUyE5Zl7Or9xLUY\nlQrsEId1oE9Pf8Y+q4X7740Eiy3eebvaH8+6zMOek0ZxJbR9OA8QTHDhS4UsOJ4Z\nfFq/CkiY7GPYFaz6apIXd07ZM7MOxgeSUjJeJ1vpSaqMckhdqbg=\n=J8Yv\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-linux-s390x.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnQACgkQsNpg+0VL\nrxgmkQ//dlCQ9YptfiuHISrZydpXnpAC7xJNY+s5YBTef9Y1ae4JlTbqVjkRn9ml\nQ3hGpZ5fIGmSgikRt/ubvEHOW+RwevgJ+G8lYPRSBAAy5pe9fXrT5pyCjSuUkhsw\nute7vTxkU8HQ4hetlb6o/4eCx6EH9nI9KiCxoYO5AjzsRmUdFtecV4CJivh00Dv2\nisKDfjI0AApBqjtolTULxJ9wZ7hufyPXYiOBpp879JD/6G/KZPV5i2dt4p+l/BIV\nNX/dl9B+ZCMJlWDiwvfLb9Nr9dj3szCzmJ089JquU6gsrVzn/fFhJI7wYujVF+ng\n1nuootH6nwuTGI4lWpwuBLrjRONJiUH312EVkIiQQQN35iE7k8oHtDdGn+/jd8Lr\n2SH+BX+W31pb0iHKgyIvGYUlFJ19pGX93hzJA4YvoFaDvRN0dZy5zgPOATXh7JZf\nlZ3HW8h/ye3PFgGOuzUZ2469+BVajePkBPqQlXPMMe+modsbxUBe5Sz8ZYn4oor7\nDnpc64Uhgvi1kLSmL8ugLYY+1W+tvgKLAxzXQtMbIA4Ao9GTrbwMU+1RJMNQvnU4\nauVhOrpZXbn4hGe5fn6xrtT89GSV6Wm6eU3vDI8UM7lzvTMBclFiDOPzN1dvEoEn\nLj/R9A9yKWYmL+iHLXkSUQaBqt3C9abkYVdtOkyzbReqZR+2xo0=\n=HUKC\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-macos-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnQACgkQsNpg+0VL\nrxjajBAAwwnch7qxh7qvxRE1Xeqr5slfgRHsRkwg00Be7aVBxpX2hKdeUBHEtR0s\nksHYAmM0mwVFMyCCPiC2tP4H4cAzgvThABDcv+fK3snhcEEgUn3LHtJ7x95IwBcv\naPLnW9I+H+4n1dEGTL8iVEGVbTKC6ewsJIs+rNnbGXlwiY5R8xGIRcmwqDpMPchQ\njPE+LoQ316ehMhWESFUjI+kSzBYO+UjJZd3PSKbc60oTkLpJq+6hVszFFBYWhlC/\nHufv+MWDYR1BngdTZIlIqi/vPF1Zlm4mDllIjlb0JATLAdV0u5YbrUpTj9Hvy7rf\nqXBwvwk5LuYIFgwVmJeSJUEcA3p6Ivg1211Fobo+3Pc1qyRZ9P3RH7AoU8upNIS/\nGmJ+ESMw++QVhFdagjbNibIIsyL6Bm11VOq5rPkuzFztG0UgeCeSACN17ypQb4t1\n2GAfck5ohrnuQHAYPFJv+HaHViHV1JOksFLWvYycXbb3dmg7UoKveG0YbZCLjbIB\n/k4hA/fzP+Noka0RAwH4w/yu4gpr1EbESKpxBKvS7je1R4SYmNCZZtcUkols6K98\nSbzZyHabSLZUR1K7uuhe2OlKIgVFtPBhq0DBNeU2Pj/iVV2nkmR8GEYeqzUfnOsi\npQUlWgR2R2vn3Nf5Jlc/tLPdUjbPYSccrdIKeuTcCmD/uPcpIfE=\n=PzAM\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-macos-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnQACgkQsNpg+0VL\nrxiD9g/5AQLqk9JWi3FFqdoTx6LI2W8FjKJoh9zky67pv03k2MpSGG6xjJbW3DGR\nDBAm3fjvgnIjeVYa3xJtIOX1Fdk4Xxg2nJyvqubeg0MnMtdjO1B2RPnndeIWHBAB\nxGIzLptp6Ws5rgOE3jWUTacwhrgyYA7iaSSRQ3GX+TRlKnec+b3RJVxVDZAlp+lG\n/54qSOEapkfqPYCWK8KHIYk4BIdXvmNIqHG+WpDMkKAo+5TYT0SUBBZQbrdBeWSV\nEoOmX5SLelTS2VZHMZmfLmb5/WMeWgcvMqahG4+bNzIGw+InNDBdS8ywBDldjlkT\nDbRckAUf0DckdpxvWvHLmYlUuT4oHkAVivEnKHZSig9VQ5a+46S4PuKzPzaXzFsp\nwG3ikTBZAAHw6OGHUwJtdAt4IrJw5NMzhvkUrXM7I9svKXdVh/GJx/7bh3KmwAVE\nPe5Qg3w886vDFwRd9uXL3JtRU58WZ0x4Jp/vvtMLOnK+xFqeRnjwDZOt3WB6UUlT\nJN73zzE1vZJQIpms+RaXxxVOAw7YnE/S7B299ozGj0WawN46CK6UDgtSJlqIkeD+\nTJHg+w6tQJyEnvWpo+hrL9azyzXuDHc8S2zjgb46iWAuG34GBHpTYlDO21qzTXg/\nmNU2Kb6RAIG44pH3M3JSPWAeyrKJ6tNqEeI+IMTD560w/+uFNmo=\n=cu6S\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-windows-amd64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnQACgkQsNpg+0VL\nrxgbWA//V7FmvI3ufiZDhJUFk6ljkx2+Ufpz3ciH0U4FNMCNZLnaKSP6hDZxrKie\nABmHkoNpHM/IHjM/uqNfYxEYMNi+k3YBgYCoQvXaEAAk1SRqGDAAmGDA1nuY4bRJ\neUMMJ35uMcN0wc8nKqkpPNBprOucR617CYQ3r35jTujhhnNi4oJlLGQ4/oNK4o7i\ngnztrdcHNUo93pkyxXrzHmNp23iSp2cYVV/gXCT7LszvQXhrFPQGvbPf0lr9KDcV\nkDfwemPQEuBoahiy4ujQ1UFVs4POMi/NiZ0tLHz/t6yF0o97R1gEi2dRNnd+AQw0\nhzbstzi4VaE+fkvQ9SmF7v61he3BP1PrjITQgdK9U7Ehcqh6a1x+p6LZgYQhDiSU\ncU3qvLUrgQlkVcVX92qhVusIg9IPW5dAF1oVECjNDCD/l7lPgvC01a8OmZ80kx0U\nWRqXJG6lPgHXS6BxZR2NQV9rwc8aY0faC2k0o8xQ4Z+UaESjadEhIxKnB8r57Hdd\nvnTCKkN7vOtN5Ey4oy6NpPaiSo7j2R/Wgz+1keoCvfEHpqu7plbE1HbqD/IYdMGJ\nOzeoai2aSMcgtMrc50sc6rHHCOjgwoGmn0GbWRJTEsP82h9AnmNuPZ+5WVE2SpZc\nCt5PwyT3S6wl8kDrzsofDl//dOjvsp86f3RaJ78QuooJQtQPfss=\n=d7yO\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/jq-windows-i386.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcnQACgkQsNpg+0VL\nrxhvqA/9Fj3mM/e5QMBmZ8BSfc4ewuSFzVHsnqr45RhzOkZukyn2QyBaqJXha+/U\nHXKYZ34lW1zFGMCBIC/W59d9/u0LAfAvGO8qi81FodjsSEmnzBumk2igIzQR/khS\np7+5Pop1JFEnv2g9DILhQhNCnuXbkwrwOq0NvaC5WhnKqsQpq0ntKfT5CvUwoaMh\namLt9ed+A1e8Z43wioJ1ybpI/PoWEcMHkisK9bIOj+BUOoiiCT5T+fYid8uxVzTX\nkpWvS/neJjMF7yf5HPOlI7FI836fuyIZxEypXh+k8RP337gxLzyoLcyK0Dk0jvEK\nMSIWZ/x/L87YzgsIjKSE63FMqZT55ZKFxRtZnq/e2aIem5I3f6K6VXfnV56c2xlC\nYgAyJIyOF1IlJMKGZzSuFlnsKnbkyXjyTOozQMF8W9WBNOxbrL44zeUkrcS1do69\nld0WjIO0qrcXL2ASy7S7rfCmqYJTLZwGMGIBY+JlRG87xEDV9k4W6xVyTljXi+Ws\nS+9RxX9bCFklDstUNfZu7WOt5PYIUezjTKa3o2iFliJhR0j6UCpgEKMAeRGIHW1/\nvJIJVwSSK9XZkii1sqAPmYTArkuLp9vVbESVu0J1BsOs5ov6NH8tbIMrqhM8+/HR\nExjG67JnyP2IY0P+k0PvMu4YWSd2oW0YyNqSDmca1kCS08GJnRQ=\n=rvxh\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.7rc2/sha256sum.txt",
    "content": "94e908a84fda47e548355539553f6c2f038636ef6c1558dd0cb65a4d789f33e7 jq-1.7rc2.tar.gz\n80b4cf6356a8182e57ccda9f2a357b846f6ddd65093ad201a590d8c2dee5dc92 jq-1.7rc2.zip\nf53b2c8533928c7866a3e6ed0e16401c323bcf77a761bc578114ce253c73e865 jq-linux-amd64\n7a02f9d4c6fa890dc3bc87a591d1d5e8675e95efa65d098272006f200248808d jq-linux-arm64\n9730f028999299a0644c5c77ce83686f78bb512f829e91046ac564692860eaad jq-linux-armel\n743abf247ac5e2c133d75fc6e402cc49a3ae00d1cbad826974553b3812122831 jq-linux-armhf\ncc0f1cb7f64d5987f0de7d15472ea21db6b95c5cbc9ecccfc97f52e8b3e9c3d8 jq-linux-i386\n16e61275535115d81e1a82c4d20d5c38b27df8a18d6cd7abe6fd4da370d6eb8e jq-linux-mips\nd07eee7484b0851bccf3b4a371679d2119cfd7624f55b2d3593c9d88bcedb353 jq-linux-mips64\n4c01094443b5e1c026cb21e5dc9f22b02676d14a1755d1289317c09448040c73 jq-linux-mips64el\nf2ff6e66401c0eac4b04aaaaa4988f793b364652cf71bf7099315b60ee62259e jq-linux-mips64r6\n9f2d14031282bc6f22ad117b16e2a1071b8e81c012cfdaa2caf4680b366575c9 jq-linux-mips64r6el\ndf17797707ddea48cbdac681de2ae092482f79ea3a1bed5d979391b82573863d jq-linux-mipsel\n63f8837e53fd67bd04df19d0cf68d02d90441421fef8f60d9999d4c1039855bf jq-linux-mipsr6\nd6815e4b374ed6ae3552df148df1d42019acdfc7e032d02228a3e94893a7c2ad jq-linux-mipsr6el\n74004dc56d5dc0f3537726d35da0f0c67c2b282fcecfa0fa56a9455fd703eb26 jq-linux-powerpc\n9cf7089f0a2864b7a0e090e6bb7e23b8ff7bd4154fc63c44a327d1380b48c416 jq-linux-ppc64el\n04ec542d7f1ab2aaa5ae9c3f3d49701f64ebcf7c03bd87091d607e794cf5234f jq-linux-riscv64\n94ebf5b62a3be0f2606ca2dc837f3368044b467a26e609d53362fc79ab9ac197 jq-linux-s390x\nbadfa24d3ff1c8e5570a31380b5b6349edbecb29785aebe4b051c60c6ff2c5ba jq-macos-amd64\n9df6253fc8178f6fae8d30083cb926ff67cad12bed2bdff9ea6c06304f785061 jq-macos-arm64\n8f39c01f1fdb9556b13b9c6625336b0bd34f45c037546772c2d8cdee3d43f73b jq-windows-amd64.exe\ncc2b4b741422eb98da1101a7b55b775f57aaa5f05e56bbadd28e7c70b3484e9d jq-windows-i386.exe\n"
  },
  {
    "path": "sig/v1.8.0/jq-1.8.0.tar.gz.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLce8ACgkQsNpg+0VL\nrxjwVRAAxCmdBiPZvaAO9n7OCaIJqGJ5aeveTU5IlnYlY1Q0YZ7DT3KzxwEivQnO\nwNzg9CN2Z7Lu8OWlnLo/n0bVXuhf9Rv9KcwI5ZkBRhh6AJOmd3pXNgtFBtPFrL28\nd0A+9x0u3HBhMdwPU3B7PXPFb6hR8djukojtZjn+eZZUZe9XjgnkDOEEloReg3M+\nLBkhOa33OHpYTGJsNyzfhBIgUMzxc3rPUlpXeeLZqJfWkTA0f3nk8uRQWZy5zV1F\n6kKKDDeffRKE9QcYtvDd2Rv7gUfhIvPZdRDFmphty2n64cT6433IcDELZ27hgoNq\naR0tqosodwTcA2o4rir1Vo/LOd1rpDLJEmLMZ7qcUDCT/SnewAjACsPjcXU8B3dx\nxj9q4wTzHWt61Fd8oa5ysIFvP0eLe3pE7kOYjPlSOj4K2ydGvTQmMcF85hfNxo1B\ntLw1vlql5qaH2LXolGErTcIVEI0wVIg7JctqgNSnHBUF+PMShYXuZcRFGZRNRkoG\n3ECsMPGtSL/TbIZa7+4Ee82mWAw3e2OG8bs8fwRWLeA3dU3dlggPMayKJ/gCPPUa\nkOxpdGYxisH9WDzSCtA2RjWtz47xMfVerrEICAgMz8sYyDwa/tyfgW1N3BM17QC8\nhW2xXsyQKsf8DAxMiQtvnWxZsusDeM5gHibqiIdl7gfHMIqE+1o=\n=WcYK\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-1.8.0.zip.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLce8ACgkQsNpg+0VL\nrxhE5w/+PH32q5aR6kP0JJqytPnGleIB3u/q4P8wAisaVuWbZRpmpLBBfNK0vG72\nIXSf9KQ0Rn095MgPjMbkAMn4Hvd+cDL3zFcJ0Q5JuDv6Y7sLmdg0on1X7D27uJSE\nw8nzZYkvikWH3Nj2NFpcrY1VQup/2HCRm2amx6r+HlzUjt7oIDOf9q+cOChHWJ+h\nlKSRTaFWJe2R1Bae4UBrlYMvXmBitl8oFYCCdmUKWv9aVo1e3ksyFGv1a5KyZiLH\nc48BTD9B/GVs79b6thI6kL1t4bhCmtNUFeI1rxnc/HsAoNlDMayjLGaRaoLG8RS2\nis33IJndyNbKArqJPZ2u4mACe4aN6j8mRw+NnKTZ0OQIOQkXfrkD6slyS2G1tsER\ntkwz7/ZFqDTRy1uontBSCikEuuxBFskxXo5zOUI5zKFL0lkOYKZm5aF4kMsO65+K\nWIZ4N6nflgK8Zj13Pjd7z30fK7CB95x+ZtYzzttyEDDOKw+gNG7Dj/eOqtjlo3ke\nIK2OkQyF3aVqysv8n3iOd++9nYxW4f+xn5bIFUu1b9KOffjiLYxZgAqJ0KHIWTuD\nqYY8xgVESdBibe8x/U4uw0jyyIT/H/rs+ftx6fr93vzGLBeJKKgtnHOnSipk5xr4\nicX4I3xaRk/YdEP1cQ+Dh1mAaIIYWf8OUWw/5RHKTiFzzedHtxw=\n=538Q\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLce8ACgkQsNpg+0VL\nrxg2yg/9HiE/2PDVKJqNP3ZO5peGd6lMBoOonnMFKzcCVqZ0HOXfIYueSU4rtw5o\nWsCyI/L4wXJ/LP0TVAC/Tgd5aFcc8FDdY4Fn3BKfcSg+B3j6KTDuqnXmi9WnXUwD\nPaW8n8GTtnogNSEAma2CGsexHtgbg+5qmRxVGHAKtd6LSHa58molR3N7yVZxdYm3\nJUKt0Pe6ixFCFeih3mlPYVQxV5vl/BHXkpK8FlBeiwIII4C+STlic/gHs4HqGXU1\ndpUr3+LNxqlplCqv4hAYkPl94gN+cQP4bF7N2q95vZDVCZX1rPbD4A+J0MWtd55I\nqB8dOjmwmuTgNUqIUjhc9Apx34PneVowOJS5BIegBNe8BkLB7I7+Q8CaI6d+mCjO\nTU5+3N4vhXwuOgcamJkHqMsJ5ZJT3ksCFrm8qRfaJkJkoTzTAPNoCqu+AaXwE8LQ\nUdBMMSM8A4KUjsKaE1FmaPH3svQfz1xnVkrBI4C0McpUQZeniGvLCvxcNLwIN+25\na/kXBKjyADDebI6TipnNN5WFiEcoLdYqDPaxjlijsh0KOEx8URI2ukum84j8SgtN\nzFcdiBWifaOYAEyz6Djm5N6AuqJd+fCSLi3Hl+guwhOpMgQPQ0IL8cRY28R+164/\nLu/aidTOMb616nXby0e+laOlYS/oWSlXHgvja/niDk1NHRemk7E=\n=het+\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLce8ACgkQsNpg+0VL\nrxhfyA/+OuVTUCDLb/ZrM+I31oq+r7eOlY77wBhvSqZ1Sl9ZuuugtqOyiKHAhp13\n+/8iLZ+F+LGz8gDz0UzweDgV5NCF/Fzk6XBaoKqli/ZF34Jt+21jOgC3aUKdzGXe\nbFii2QEIGk0fEYaebz5TdHSoWxpvDBw/8He2Tx6tevFX/bQHJ+CfQikEx9++T4+l\nMjTHC3Rj3b2C7cU9LDzqCZnOvwXe2Qs+QUSVNVUDtb2Xi/wfVaAjgR/w7ar1fgYc\nZ+wSVMsCW1QnPY3MNLEbzAzYebEmIkI4SS91JgmTcNpZr4vYntpjy+IRehMiI+Rn\nutZljP2i+uYLS4LvgWh+IwOVq2ZW9NzJtRUIXMR/+iaf/jRzsZ47rwUFhjmqj51V\n7sOHWHxYt4JmCTgILGYGBHauIw1aeCNjiEY/W65xi/oPTXtPmmMJd+CZhuoCz7F4\n9zQn3ea5yMfczaZ92ZAOSzqdT+Ir1zTGD7cWXfXEdqScyEJDKCquDmL7TzWrbetg\n8JAd+Xsb9viWAJ0b0+4B89zvwpZgekmH1VD25YsWCFq90U28IDB/5zmlG0KFSKcH\nRy8u+/KWobkM1zJ64fQ6vTKLU5EOEtmFLPfmTZGwnwh1p2m64+waJ5Yc/2Zcq4To\nfqFmQeckqbLHFaoIh/AnOn13URAZmnDAv9+UHfQ+3E2WduIztRE=\n=Aqcr\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-armel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLce8ACgkQsNpg+0VL\nrxgPtBAAt7r3+L7TgZwk0/jGHvCB6yMQf0DUrk5oytmVj8mfnW8CC/ZqrEpr/aHk\nWJYybq/DKZyrGXdNulVvzOLzYcmfKSM1qk/6vv5HJ6xTHlh6YiKbYnki7QYKY7M4\nQ33xOL4Lu+wxXMN7rQbbujZKSHpu0LqwaNv3Q6fpJpXDsuvO+0qYdLVxZHTIMCSp\n9+t0F47h7cKEMpSuPFpy5dEUJ4g4+m3qUBth7xcgdnp3JUuMrfj3JzSUIL3AbAt5\nyiIGliqBBDaZA4Uqgu46Tkxz7gri5TuPYJKOCH1HUFE3/irjFfRG/IAux+PoauGe\nD7rxa+VjqoOCp9V1uFSfBO1xaaYfBiMwKkdGayw5TnQntr/Bh8//wNPSA871P+rk\n5gOBp31MT1kSTMU7k1OiX9Idp4+FVUhVc72A+oGMSTeMu2NRZ9eVq+76pmEn56bn\nK+oKminsw4aVC9ThkR3Y2ZtlV232eNVBRJz3fKe5GQJ5x32HcUmemDczqKNtokZ/\nlu4zYQIlTOyqOuvU78aEqyKO6koe+6y/BSLMAEw1yLMy0oTRItAJYDu8TdbMDztU\n1YqrRkg7diBytjhsqFRExhIwMHN4ME2MNiokUSgqrs5h1+y5O5H7faEoEDK9heew\nWAnKiWCCj3upHjyDZBVjwyaTY8Zc50qWpy1VbPNCeN2p0Jw6YOo=\n=F9I6\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-armhf.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfAACgkQsNpg+0VL\nrxjpixAAsE8+WOa3VN9G40OOdu6hVlNwD2lAPOPwS7GlKdkllHoNrw6rMduASYBl\nwIs9zk1HG4y/BI9Cp+F1r4w+ljzkjzkriRPn3nf8rJMiya8B2/TdSlJFIJ6UAp0s\n6VaEPPq7WcZwQyn9v1MxxIC/UCx7xNsGL/iWbGLsiAOoYQjiFoWsds3Cr/IX2emi\nCxcQMKItM0Q71HgMFTbtUU+suywwIfpUQB9Zvwtb0//c47G6UgLXWXXD3gj2A8iZ\nr/Oj/FJZQYWXiox5qCmvQuOXV1TjJJQ/QxBbWr0DF2IvwMsOczJjM8uSW9WmqaA9\nTsz14jjQDOlu80WqpF0Vob2FAehyEFEfKQHDgQIoPGHbeM6mSUUjcD5uL9qoV7Yh\nAUyYokgoZFRi4bP/rW+qZVLpyHGBPeqv4MVdYNfMiOj6qoZIZkmwDj3hThisJzFU\nPZ7MoSh+LnsclMWuMJgSmSNMf8avA60/aAXZHzY3o/P8oLlGwYo3RkZVCdLYyDgn\nFGXLyW72sGFhrvwI19A2gu1umkzmLScYSSaTOmIyboq+ZA0yUGAZcDg7Fin/KP94\nWGctyjwnMp9DuxVt/dxxAiRTKnxiTYJN8fOf/UT3zouXwSmmR1ExwkOX8TnA57lW\nRf7xGaB5+KqDp6HNGYRfm3kdwF9fMo11xQ3SQItzAbwaPBStbIA=\n=cpPi\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-i386.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfAACgkQsNpg+0VL\nrxiSSw/9GXh9DdbiEp8au9petkagfN2I1/dOX8qgdP3i6dZ6RSQQoHSwyTQ+IRub\nJgLIzxtHe1koydVFtMt58xXobPyJ7lPCaNp1N7TNwO9Qek1to68jtehLY1qa7RJA\nvZyFHrY5MsPJfyDxkKnUuZ10p++LMEAqr6yRT7vJHUVJCDHXXOTkZ+L11bZceXBZ\nXT0onrl0QGuLLv9wWDO0EYumKABLGvdbsFj4ShreRiCzqJSgIt1Bpm2FD6185Jvg\n+l9scTs4JBFkSk4v31eu7qIi3xhP5DbMlCVeve22VMXwo4E7wkcpvcPJhazMD2Pd\nvgLFE+DYISQwaL78fKmStEyz+kkqAGpZ8t/LTsDgBkYVN45tImea7+fnYl6AuYDh\njr+GD2U1Nzb82Pec/BpfoRz8PKPWl9H8YT2nY+ukR2HVCqwmCCDUYhTZPmE2yDki\nyRTp8cIZOyYc0jqtYVUZFArSoUPNNafeZS0EVsl5JR1yaCxCcjWSHbWmfDdakTBJ\ntwsEu65kEYbwmF22eK8I+mR5FMIAc8YC4cPprI5IxTNhwZxaNWUt/UHG7VjCpg9q\nPOE6TQK2WEu4knDUz7QV5A9lLwNTw0B7+193R/PyNQgsVuTXnqp7Ipz6VYYF47eT\ngIM0pRipqKl3ALn7PQn8AntP0jwvTMhLrC6po3bGmFJGHifz3sI=\n=VVWl\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-mips.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfAACgkQsNpg+0VL\nrxg1/g/+KpKpO+an3dPSfqbwEvyKo4cPP++YTv30RqeDDJqjPpkaAu4a2QC6lEOL\nW0ZI6/PbnmT1sTM1LrfQB9pMk7QYX49NkKNRZibwRowpinuTfIAFI3KJo8uusigL\neziVW0C4lzeFMESYO/uT34RnSF/Lmn1sVfk94sLseQOlgz6dg73/wstsQDv2Ho0r\nav9q24+F945rmhN+Vz2UEVuzkipmiEo2ZbSfVJuHwlrYo57+y+3aTdehJp1qYV9p\nA7MWoHz8+5jMDjlLTWKa6RdUJgiYhgwj9Pv4L7MW/eoPnN7cS5KDQL3kR7Et4bbq\n14r0/gSBY6F4qCxFopo49fCJ2gf1AF+65YFcvIaon4QXPv6YGUkHftRPDRoTFBDh\ns0WcvLqnYBWDoJ/Qk3amoU/ytTX6/gXT0QS4t/HBWyI8P+eQqIleABDbzFPqwyMA\ndQQfvMkL45xkNEdpoJrfj55cOo+W6tUADfMwvcDjvpBik5IY2bVdjDiJhq9/nu3O\ngIMQBfI3OTi8xLPKf25J+Wp5mrW9UXSaQ1+XhXCV9pb719UbcwOc7qSPQY+0KuZo\nMPuYWWAUVEDJOoWniFVThQDlP4VK+a6wSDyomhPwey/0o0TrtOmn1YvBv9NE0C6/\nCG7UPj+jhOXkPodTjLVuBw1e9fAEB/elQ4RavFX3BlwUpdLV31s=\n=vkxu\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-mips64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfAACgkQsNpg+0VL\nrxg9Nw//RPra2Jba4xF4yxQGIB2WHC4PETWDX5UNNnUcjXtzKw8ihQ5dmmNI8z5S\nn9NgAFZTIzJqGIbkahnasjgwcUEKH7HSPvjGONv6utAjpK4CX16qE8GRPsCw6X6e\nMTaapSlQZ0atM1jPHJ1yiMiH/U3mcFCTpRGotPb5NGjSniTw5mnUrXIa5FHXtJV3\n/lm9RCjUq8mEwLJzueTbHNGM7OwihuoRdYUAPvK1yWkJMESBeNHGVHBg5zHt+HHo\nR7UdlSY53RDJN2m3yLFufOEoez3jcKDGO41LV401VGCEVx+hgAEJSt8xSqOWItCM\n5MkDobecFSSWmH3kDB7KYqXC2F7Msh1n2YVvco+EJp6MD/W8JEhtoCBVNOdijD3w\nivs2YzDz2l5oojSYntqBRnUTx2f37NPqCMF+7ZNPDlRDU6+BJcNTfAvRZ+B9AXBU\nv8iXuMdd7RENnwq8Vc1eV2GX/g3ZCfA/2v141uQqf93N3FmwRNbw6qb4QT2msohR\nd082pggp7NBJSdL/w2UM1NWigGp/TFWv9aqcEjlAowIK4xQcbX0qFaturlFoIZ90\nxfwp0i+KR3c4FGD80sIvWW2CC0+1xYN7XJNAN67VffyHAoYw65ZY6wvmWorjoXnT\n500jPF1jEAQZE3h1wYATBo2DZYJOZiyK1R4r2sr7ZRaBdgxk1xA=\n=tWDC\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-mips64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfAACgkQsNpg+0VL\nrxiL0Q/7B28UdzFSsYJwe5/s3Qs8UjYjujXVlDyDmprsGxi8wFFQXxTh1QxECueW\nKSJE4mZNXYOFRsyf0jOgMJ4/rN8FZqe4WyLzPOp1Y0gryQ8FPf64uik3jw44Vn3P\nDhU5XWV9Fo1BWvdzRmdYt+RbnNM2C0dr/p9ZQPia4sAyUeRzL9QJBpAJi094PJuH\nAzTcY63b1woOiyo4F5h5NRtyNl0ugzwRDXmZQubBvgeGLuE14rPNiJukNrEsoXmJ\nwBJNzrHDb1E0gCYi2a0VkWsE0quvZ/6Q8IZBOVtNGYTYzXQNZ5UIsbk963x8HBkk\n2Nmoi3G3ALIKHHbWhZJlrgXLqRaulz8Z0fW8FbJFfHBQ85UXBosICsG+grVwQQ9e\npgFDLEJct+tQrM6zyg1NqnZ+/aD9x1i6gRd9WFLtuPwLDou1FC+6Txex6OGbGO61\n93Io9XAjg5OF9jqYVf4iLkesJB+NlSg1HVEcXdrqJak/slI9xfYU4ROA1/wDMkoE\nLGqnwywWYKYTC/6a/C1EVNUOtvDfE3/eNaOFu5fdG2LS37ywhRcRIhmnojzF5eFr\nctPbgp0mEtKt88jdh7mEX2TWVMm97rOM8TFEwe5Wxr7ZWkEXqqNcqTnjfZQ8WWqK\nZ0PtDSsM55jkL5aVUKe5f9RMFnvQ9gvU/M+TweO1rsR8XscXX6M=\n=L2xy\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-mips64r6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfAACgkQsNpg+0VL\nrxiyoRAAzfeEQ8Y4hi5kmdUAUGdcyH4Lli03bHffZgEvYjcUiqLJObs4nzrXDlfe\nJRPftNUSuDRjwN6u2cJXlJ4lYd81D5SnigsUE8hs5gQam7qIy6z8k+wWbZxPF9nP\neXGtIsIzwL8atS14mLNr3x6OliQga6US2Kez6Cm7Nz5h3fGMI1MFcM6DqJl6tdkR\npfzjR/lXUM2yXLvHjXFRZcxTxRcagAEju4irSWVlH3VimYR+ekJqaVS+u3OJ1y1x\n5U1Nfpyz84Qr2I9TBaM6wyfb7YqYImSud4kuSlsgmIlJOrdp1cBK9oEazrKvNu1M\nA11QYCEMJRcQ6sdiuznFXH5XuoZEog2ggwP7nST2KTS31Jc4QpldEQX+PQVXtRy0\nafRAtd2I1cTXS7n12PY6eEAtKs5AdEqGp7a/SAKhbJqEmR7Qlg3hHFarmVi2NhW7\nr2TDg42hq6nwGHA4/2/GdccEbFbCOur0nMkXPd1ziXs0vT4pmD4kuHE8GN2S9fbA\nDtdB0Sl3TG5PRNb3BVXrPFN5A4wsYiIFuhHpgY5zWKwdCOuyQKn2/56sYAYkGjV1\nDGRICLhzgqt35xE9RVhShwsAuGNMAID1a2pXls0Vj1QwtN2slpk+WJe74cJsQ6UW\nVG5kt87gjYWsp4eXehHmTnV3ganVlwi2K6/jSoPU/tvzv0c8F1Q=\n=N1xr\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-mips64r6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfAACgkQsNpg+0VL\nrxhc5Q//ZsnuolGGYfGqPSqkaPRBgjXvJ7EpwCiSFiOv0xTYTtxd8mH4gCzQHEWl\nfrml7RLj9RwR4bAfGyiSFOQZ0p4K964x/Vbkr/UMep4JycdtqUgHkhRjZPNu/0lJ\nCZnLCU3H8wxq2muCOwMppEMnusXvYKDqixYJkVDj9kNupWN73/vqn85nZj22Fv0V\nB2b+fVP290/56wVUgGCuoB3D8T+f4FRGosF4AtuhewhFQ5jb0mvouEP8tjEd6k+2\noKUjJuewU18AkNHn1oZVLgyFaZGX10zVvjARHM6Nz0fY1eIqiS4WrLH44aDPd1ca\n8+B/TN9cGnUqFnPAlGCCddgPjDW1G+JWTb2yaxLE8jSQB8uutADe5RCHxsgtraIT\nXPbppI+UZMtucpq2elF958lcp0CLGeGkd25Go5NMzXCd1NJxoOeG5faSddrTk7Mv\nvKMow1s7zTqP2QfgSuPyY7DKzrD2YSnUlY1hPHR+Fg5itxeri9CNQtaXFbuYk3+5\nDAuoUV9CrmZsggszCtVUQogeF6deRlBFGxnWV1LgZu8lEAMRt1ef4otIpFDWcIe1\nkHrmTl65DjXK56MFrwhihqbrW9gyok2qhRHwAbpsfDIuBXj6OeOxw3CpukjXj6yc\nkhd889+n4jy+Oo2JnHLoQUvS7AEVP1vIT5hU+D7PcXbUzSnOrmY=\n=wiBQ\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-mipsel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfAACgkQsNpg+0VL\nrxgEDw/8CI4xLrjp+jIp0B2AX5fD/n01Py7luGw31eCB1xo5zRV7Wbzr6u7JGMYX\nXNmFztdMiBz7WxDARTgXn2/elxxanTl55okUJuZLC0voUzOEdrXFgBqRHRn+QXKn\nj2XuXKwZrmimauQYwi7PLj3hIpsZ1TyRTM9sqRCdshibmkWJsUFQzvMnMQQ/SWJa\nfPBczzaeowUSXYswQkehPZLwvVOGSKkAHR/6vfHSUtD64oUHa/F2zunPwXQPbQjk\nfqZD+oNWEG2ibcF993P1Vi3YNglzSjc+rvNBBo25e1gmurcIOYZ23ilGrpRaGpGq\nNrRRYY80wBDBmVTfbsdWrMuAesj65GuoTnpL4ipZkmV76I5thFDLtx3OlNzmPadE\nD7X2C8BIpBDlTVqz4prlHpny+BvlAyHwRUwaOWVn0YxeAYzkKmeyAQbF6pdv6G8L\n8TmRbOoT3fNvDk1ZZ2LDprsw8vetHVDau+J8vae2Qbysll8ijGb8cXIkRovgecBR\n80rjDPuzZGhR5LrGCAaQ8lg+2ZoEp1Z72AwQuULHOlV8AmqsQGneVz/RZxEl6HaY\nBGYF1iCEgWOY+ngPCB6WxceXNBREh+RS3HNdwqGG7zBfcM2wBOcMyGtaYgt70Qp6\n3M6ztq7KzrGASBz18OnitXNIqyBKB4B12Df5YZHDOMZ9TpLSB+Q=\n=rang\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-mipsr6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfAACgkQsNpg+0VL\nrxjvjBAAyVa/mL7FB23pNGYIHNYlxjznlgPOM3fNmdakMoC0GIL9cGlnw8d5nynh\nCXmPnozscf2SNmxuIcakkKcEJ9wR+2Rnyf3QiMPDY+qdrAsJoEqBNVfzn8xk5VAg\nB6qE8Jc4DxGXjdFkNrA/DP5ZhncanBhv3TloXzqURDDplzAEA7VMffevkm8YwiCo\nN9Ov1BAG8S50JfEaNtIeq8I7a9apvte3DIFh/UitGHM0t07i9Rp/zR3BWDC4+srX\nqKEUGbgP8boi302wX/qT+g6m+6mQwTCjIlGzf9Ff6XunHnSE2vTHwXNf6W0Loj50\nUQyPP4wc0hHcEn1TfLEK3HPVEP30zG5PbqKR3agGxq+m9+02Yi5KDxaZUClv76Ud\nxIFfvCeWHm0vPWoRYrJeXB3uoiYB/6PzT3yPxmR2bObZdk5+PA0J/WKDoSig0tzv\nDwzSwMtTqUQiAaQNpr3LLIEljzMypT9QGif75wtYJpF2vqrBSiJBMTv5CXhwzkw5\n1FM56f/FmPAxjQcNzm3UuGvL2KIY5FhMGibPPV8Elw2+OxOHTsp+fBc1VufAWWDv\nxqkAojOgiRqMLx405yn25g0OPYD8lORTQ50RSigvNpCstqRL0ePpmkh0692C0dxq\nHYTgbOFOYaWeDU9RHAhYI+JUX4pNApmZN2BVC/PG4ywEq3GJGhY=\n=aIez\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-mipsr6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfEACgkQsNpg+0VL\nrxj15A/8C/s+IKuPzxpIBAwJCOrItbE3nRUyBXBkudhol2o9iHu/Ww/VMB+I5pOU\nfRHcYTtpE9R66TtEYqh7C6XXtO/HjKpxlT7nMvzBS8FOgQ83RS4o3vq2Vbnz9jbq\nG06eEM8Hj90IWaujnfWvs3dXHthgCyOYQy06+/0H8Q1neJ8O+v8DebUMnsP4GTpY\nN89HLoCkMlllkb1dof66IRhVMdSn65a5BhObk5nI8qtncrX5rmW1Da/MRQ4epNos\n+VpbK1E8gT80WzIyAyFTqhZxcfy+5ObXWSRCdEZmfFeW1GP1swQmccVvQhz3RPB5\nONgTP0B1ZM1B2f06b5RlKFuNXshseJ4gjFv1WoAYrMiIumBC3225H6zSFH4076Nd\noO6gkOnNqPc6Qkaxr7WgDcroZ0PuF8z6tqgWTMu1yxSpoEY6tYdzTPySExaAY/xZ\nw6WPCwEISHcXobkO+vP3iG6GdnojXfwhhRRo0NzWCbxd7bjvOWwt2Q2m2AAbLc2n\nzl6CRb5l0VM0JMKrV1PPp88+ZCBB5YA0FhyjiJ1BlyhgSAwiNZ/TSdGgiPCj71Pj\nNlkSNzLU/0X2QifW1r2x1kOatiLegAOkB39a/ddVfRsLugFRh/TjZF7931NNwVSR\n0VZqZqR4Tidcz9uEV3ISPBpx17zjw7If8aBDvcLXuInZEg3mYtQ=\n=P9gB\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-powerpc.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfEACgkQsNpg+0VL\nrxgD5RAArDShagUVgzAo98KfFoBVn6fiESc6fjiiF5uXRd947J7apCpC/HbhxG8z\no1K/rKHWY41VfGixaBRv1leAXPgYFuv0jhCuvv6kTELhD3VsG4BYBNi2lzR/OP/X\nV1sKYw5KioxOdHyXoCy3g0nwPvN9oUhRSirvy8XfnP5xaALYbs32WA1C85dnUfcq\n9ablDsoqxUwz0tFn9qYFJ2SwLxBx8GlB2WZhj6Qw+LkL0YAjetdw+T1OgkjUTc2z\nCnwCuVCz1RgNuBPlx8pUlxlZBT97GQlfQNwmwtKgc3dt7O7DJ4lyYZdZFnUok3p3\nAf/VsEaNsyerRaY1kUnTsKF1II6ISmjxdEcKhk52SCDpMFVm9hY+/kgfjuHJDaP8\n6dFl86tuUCgK92GtJlOynG5cJfRnS1YABP07704f7wNzO7rUlW+WvnNKp1ro4qem\ncj3A9+JcRYxSuJ36kkMD1AJ6cQEN9G/XE1IpgrwUHmuEWwVghz81u713YLHp1hWE\n+o8V0OyoFlWHfwmefOJYywBtqsPhAbd6fuxujPhYlroVaEOiy23i1zjFRd/HRPpe\nWSDaf09NIAdkKvS+wsWNSo5SabPCrMf2InqN+PX0xAx0Q+5FEnaoZJsxmbWQtbRN\nXKzzJaJ7DUOSMJYTLrgAHePA5QUsJotxtuiZhfY4FwW0EsQHvhU=\n=OSJh\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-ppc64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfEACgkQsNpg+0VL\nrxjgag/9HTPiS62srTVR1kt0pINwNrp8yajy17xOXByj8JVI1k7GW622tsjjLGrq\neZLTqcGPZAV8JCS/+yPW9dncfD/IKAs2eSr1De/n0TqKcWBZTh9S6gi+IlfhtZPB\nimnRsTgGzGwUvi3o8Rti5ifoyRxXFLyyTRlYXSt/N38uYmK1NeXZCEWxv1lrCnKN\nZt6rJqUJdCy4zwCZsyzQFV9Jk71fXBb4Fewp4OIv6Hfawacv24GKULm+fVQmJfzA\nY1Yhucgq3UuEjFwDJrIazBnHfi1Ax+pmBJXAqlhaq+ccs322ZXJfdk7VrQ9OvVmk\no829J7Csauzt2dI+a1SYqT5HFk0+dioQgh2GHafFGEKj9xg14blMQzHBI+UdRVKp\nBANtMyd1UBabkg9rYu6B0Ez891bEw3zrxMPox/5ThVbm9v7GyPJFtW38CdUwT3Jw\nCcwPP4KrUqyFMleRhKt/c93zCdNgu6svTeNB8cSAs8ND9Q7WnUcn+PlrQNb0Mhmt\ngTjhfwd51JI6F23W+OBP/SjuBrO4m9JPR11ZIgc/QLPMLYLuiUlMwzRUh6RE+Co4\nVOTZSIPBvzc7sAT7Pziq0x9gwnlOBmleksy3mw70ghDzmzadSsy0l7tFZFch/x0O\nAzQrNff78gny46JE8kWh+GIeYZvuGgoy9PhDdIX0dynBoH5t2gA=\n=9bYZ\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-riscv64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfEACgkQsNpg+0VL\nrxjlFBAApB7lCspLLD3bEVs1K1LzqzTCOtZu4qu7eaRRU6p07cOw2CaJ/pGul6En\nkQvQFxHRpUUekDrUNE92OvmWWyj4yskD90S85xxZpwPljO9p1CzkRjQnRtOI/Vx/\nNAYJg+mufxSYH7D8I3TLZkB20yd0UCTvZGa+2o06nUcyI9RhiWupuFewllrxwQAu\nVbEvQIoVbxnbVlAnQHdyBA/nSpvYcTEB6/eK8dFL0nxTHDwRmwyqBz8UrKSKn6ZV\ntXf4oLLQa0aotuvFLkuHDD9fBY0OFclWMJdRqXd/S+W5v6IiFpthy6QlG+4FGkrZ\nfv6yXRpeaHXEVwK7m/6HOay6bnPdMJ/zFbUHK6PausNGDv+hbR33TOXrhaEBtutZ\ni6TMZUIGClhTpoSdttSOavChQrpMRwxvsvIYj8gdzmBEfy7y92/eEU3w57sTMS7n\nRqCpCqLCOoBa8L37+wN/Pe78Bhw5gJo9XKgrmFb8juN43h6Z9KA4Frx0UUPieTkk\nQp/qeMrzD5t51C+Pdym+pZvJ4dx18ebvi3ueENV85ZyJJUAUVR3E54dYZ1l04dCf\njNYMzy6KhexkvcddzUp2FeSzBOd2YoqwTiz42QNg20knNYWRQd1mkZJ82LKCzQXV\nmhfm5Qis24zeL6e5GQOhgwekptMi528NVyZhbG1RQb4Hvk66VtI=\n=tVIV\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux-s390x.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfEACgkQsNpg+0VL\nrxjhYA//YJYQhxZVtc2NryRyrxzAOVLOIiX47Z5EiGbs58D/NInO0c0yEzYcoZ5G\nPer8m9TDigIgk0YDx7ivAOFHCoNejoP83OsaD6YpyowjjQ64mxr/LDqe/s34xC9X\nE4m2706+h2YViDL2IZESsPKt9puhdwOKOYzCCg7LfvzfJjgRtBe3FP8QgK6SeG/J\nqtUkG+c+Oe+GOWufNuzeQO/7H7RWtWZi2jTwVbny281jVKAK4gw5hI1R9srrKwkx\nQ6p8swVVcP3YHnbnWY/XNkXHHElX3l/R6GE0Hm3TPRyCSqCzVReFuOXIV7OYepcB\nnxxDflYjlA3S5KfGO0x7/hJdIxwxwQ8dE/yQTzPZEuut5LpkW9V0jSahNamA9g7Y\nbx6IOh1VUXc3RYxhYJ3+ivv4IxFUpjttYkxzvkVxhJl2QFj/EvHH5jnW4IE8C/7d\nqE2v0/SPpw1sXAkcte9n4k7OK1spPNO0N1W9sNgLYX+iWp7PGL0vi9oMcj3pizs5\nHNiuMzE74Afna7yrTlJxXT8L4PHzqCpoOmK43k+SIEgIbAwVRT66kuZMZm9YGsWA\n7z5u45n3gULBGocPaYmfslNbprVclmwAHYk31I2eRKgJ1CsKG6jR4yIoZEUMCDBF\nEcHRhEm3qe3BJXmyRYuWFrlIvACvyUnoiYaguuo1epjZAzy6R7A=\n=dWjW\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-linux64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfEACgkQsNpg+0VL\nrxgcYA/+K4ad2Qp8AaMD2vvMxydSFfjEujTzMOOdnbVI9Mzmu5D03HAKZdrwaZ8d\nrJh91tkTHjZ/KmfTrS2Pdog8jzFYj+3L2tYm5HlFuMeYtufTl0eVP1M2Bk00d9BV\njVikqq4e/qTeyTmXgfhIZeKc42dgNPRovp4AXnEJ63EnW9J8mrHdFvIb823zcjm1\nPUMJ6yYWwGxaKIk81twheobCYEn19PvrpmTjejpHVQp1eHyt8FV0oVIkX/OSoD5D\nzlGFSicqmJB1hARd7cp/5prUEX2z9NWu2sSJudVwEX7ypQ5d2sRAspjdVEdtdtX2\nQRthDyTrXBfn/pTBZnN75b9wrI1qDqkGCIIOo+ldOeqrK3pd1GuOuD5YDG9dgZNB\nSozf22UPwY/4awNbfgWVJBDtJ5e3IJz0Ysu6oknUBjBcusYz/cHxgDvQmhfIS33Q\n1hnhyDKbMTiru0Wc1zbDRZmX34sLnLcJe2gLh8wD6gUE869Vyjlg/QowcSQctPJB\n28KMDgc5S+KJRa82RSESLG9nUMs5jUMaB9MmtnE7lCiDEoJxl14lapyvp9qPRV96\nmAICpWGXgNt8VQKwFRWsEPzyWjM4r6Rtd6t+MHedBQ+an9pEWao14nSYgzI+PGDn\ntySSIx2UIYVSh2sdIZ1jt51vIh3VWkaWq3b/kuKAsTorGSCQFSI=\n=whh+\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-macos-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfEACgkQsNpg+0VL\nrxgJABAAhpNMBJBZOrmfPrl0mR2kaiWCgvmP7dSq+zeUPDpMsvyQqd7/OzPEJwTO\nlN1hYerRHfKY4IplhDa3qmroUftPh97LVVLvFtbEkd40v2TQGKN+8YBbF1LWV16X\nvpBIc19K36dy0QmeYITzHzhKoJLD/kkYo6S0hXdQE7mooHwVOSJ5xibRG5TQdcku\nPyJewSkmAE5Omnz8VRP+fENyDcPoif+i7lqTQm1/FqZz2We4ZtNRbzSLM88wWRQD\nMjqTjBO118svmEXx7XICahQP4FhJrAyq2rvylI5J+C2ZT2E9qoVVPawUSmewfxde\niYHdl3WT3xIDpZxpyanKALFt4+6WW63cHsQQ8BSEAnJAfxwBLfILuU9QHchoKzTP\ngGU1qW4NPCuUoGYLBqAdLc6MkJ9NmQbsIpOfCLOOVo9GYuwwVHxO0Eoy3YSuCqrt\niGbv6s2xmI/ISkb38LfoNezrXZYDDDR1qG/+6oBSEbra3Y0uw5+sGw2QIo+BP1KX\n141ZeD8O19I1FUjimXapay3lVMoLOCsVlW6X95THabi3RWb9hEHYCBqi7BKmRk64\n2hwPCTVNiiScLSoL59sKaeeI5oPO0woTP497KE4vOZwABkwTxTuR7gc5v0OGvuxj\nzFKjliTnugecMTXnSOeAVoxdswUrTAtKc0ZA112+3BGWp8G9Y+0=\n=Nx1M\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-macos-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfEACgkQsNpg+0VL\nrxjlIA/9EmPrz3O/Jri3bIqV2mRHUrq49eLHh5+2n9x2nKBXOvp6xrqBkxHjPScY\ny8HgN1/ZD5q6nVxa0IWIRSHJGxEXerJEiglxfdhwMZkE679PCIzmp5F4LQmfdzMg\nWrzFdlyp6JCBB2e2ojmu2Rxf8i548Q9eEqbwHkU8VdtsWFYvY3/KfJM4ilfT5+H/\njFg3ghhKlpFpzLXuI5MmGhEuwb8Xz8QT3YdICuVHrVCCsFsC4r7xFN333uDM5vCV\nda3G5vQjvmhT6i7OhbMnFBOvgshj7dZU1NAFM0wJDI0WoxRhdA7yFlHSzfE6IgMS\nhmMojLRBXai/sqeGa1My7Os6Hul/v4H2rQfVacj23IGfWcZD+dSpCMaviXg44NWj\n1VZlkVgoxjmHubLD+4GApYF+IuE9iwyby28ya0OZ8YHXKZWGeCMNJxCoWrZyduJz\nVg5YKmsaOvgtFiA04HnCzcZim0n69rDlgTzg2JefkNdramPEzlM+ZCAcmdJj99ki\nZU1WXnafWAvXdL0MXHctEIbLQumIYBV9ye0ysoi7tShnn1JMVz983FWMtr2K0DyA\nx/Gx2LreOkSXWdSntbqlYIUBKaXM4ksknFWg8ux4neMACbcCU0P8IvoeOR4f6OT7\nHBe02l7Z74D4I5t6EpIm7jp6TJgO2wASj7hC7nLDnPxY+Y+C4T8=\n=kdP7\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-osx-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfIACgkQsNpg+0VL\nrxizug//R1i+HdDixIe+AV6TQcGAlH5FTNy9/vLo3HeE7kqdgoIJ0+jbxKEMW+92\nL37HDae6C5/OAnfdQXmlXIOLkeXuDl+CfAcJf/0DWwZB66o02q3veIWF0NeS2lts\nL0Sm4ULfM7pYqj7hcb3nUiHI2Pgk5hAoN8FqdUn4kvz2oGh76YHJ2pjoTUlGOQdR\nNh0ekvP13PFsA/UfM6szRkeD2Sr5SwtpaXGJ/CwZKKfQ+qds74n9Hm2QuxQkYktl\nW2GKbEDgX23Ka/peFpIQJw0OzMhnDhYcqnAB3z+680AQ5XOZ56QvtLTNrfdu5l0O\nTFYbkEOzfCZxSKcH2HLY7paORVtC2THkmdvT/4Zs1NGsgstTmfoYgQbz6M9MSEU8\nFZzcELrRrbb8eLnKiCttgqPBuVB2sBHCZJVmlez/OkEUGPFnoNdoahjnuzwlN8Ox\nIQNR5tJnOSw9WdPf15/MV84JzzcZwXzeiSkeNQ/iXk5yLpr0MgKQEAgtEyzw1RGb\n8SYvFRVNaMr2OTaVsj9alPLMkrXksJu72CK7IoUdzUkkxnpvkkUxjc42GXKzvuH8\nv8zgeofSBKUj+8HQH1UBC1dOt+rcFNsOw+E6YGZRU9tbO8TyX0FA2UVTnkl2nzrI\n4I65N8rI6dvNdp7V2CzIZ/HqnqTy5Q17YKB31BJLgMdFh/kJUt4=\n=FylY\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-win64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfIACgkQsNpg+0VL\nrxhfRw//f6a8sHFuzIzycOAWm9bI8bRBtuIWIw/8Sivf7tabVmPiIpV7ACeAMo1R\nYK52y1H2sjPtiSATvltDTcq2EMoamUVh3uMrod1pjm8uBoO+JZsqwsfNEhuiLXcw\nf9NPI79XOhulQBA00KOq/X2QkVS/XDQtMSNVn+Y7ASbPznCpKY0TBzi51oE5/ytk\nl1ZauxdukMS1LHSl82dT4qtVOs7+7NPL0N/EII3JW/rQk4L8lGxB2RU7iIhWkSH5\nsf8Qd7diBdad/C6EM972DdsaKwBW0XaPRgqr32CusbLwyqPYHRsT+fvXPcKt3plY\nA9B/RV+VfHrUVXNj2+Ka9BLmSJ12JsNdYFFA/I/F5qloR25yI4eSm4xOHLjFZ7EY\nBxQlHqlb5yOhNpM+w4Zatl3PkCVOF30A9ODc4NLU0BVVVKa1ojEWYadsAzioMX6X\nKxNCWeHkeRyZ2Tdvej1T5ZmzDVKJ8PA71EeRa/ZuZKqJOXSP5p7XxomjJQ+z16dW\nvd54+tFOTA25LHlIKfkXfJ+WXggOMBOhnNmR6hGwd7RWeyl806Q3jreWwVjfV6Gr\ntFr7JtaxrgjENcV3fQ33LLbtDiu8hrY1XJ+MoLNK+id3wmPJL8uigX3szpF1sO4x\n+GB3Jzgs/5kYOVQCr/CVXf8G+cueDkVGWdXTdpmv5ZNlsQdOrqo=\n=SEif\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-windows-amd64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfIACgkQsNpg+0VL\nrxhfRw//f6a8sHFuzIzycOAWm9bI8bRBtuIWIw/8Sivf7tabVmPiIpV7ACeAMo1R\nYK52y1H2sjPtiSATvltDTcq2EMoamUVh3uMrod1pjm8uBoO+JZsqwsfNEhuiLXcw\nf9NPI79XOhulQBA00KOq/X2QkVS/XDQtMSNVn+Y7ASbPznCpKY0TBzi51oE5/ytk\nl1ZauxdukMS1LHSl82dT4qtVOs7+7NPL0N/EII3JW/rQk4L8lGxB2RU7iIhWkSH5\nsf8Qd7diBdad/C6EM972DdsaKwBW0XaPRgqr32CusbLwyqPYHRsT+fvXPcKt3plY\nA9B/RV+VfHrUVXNj2+Ka9BLmSJ12JsNdYFFA/I/F5qloR25yI4eSm4xOHLjFZ7EY\nBxQlHqlb5yOhNpM+w4Zatl3PkCVOF30A9ODc4NLU0BVVVKa1ojEWYadsAzioMX6X\nKxNCWeHkeRyZ2Tdvej1T5ZmzDVKJ8PA71EeRa/ZuZKqJOXSP5p7XxomjJQ+z16dW\nvd54+tFOTA25LHlIKfkXfJ+WXggOMBOhnNmR6hGwd7RWeyl806Q3jreWwVjfV6Gr\ntFr7JtaxrgjENcV3fQ33LLbtDiu8hrY1XJ+MoLNK+id3wmPJL8uigX3szpF1sO4x\n+GB3Jzgs/5kYOVQCr/CVXf8G+cueDkVGWdXTdpmv5ZNlsQdOrqo=\n=SEif\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/jq-windows-i386.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfIACgkQsNpg+0VL\nrxgyjw/5AUn0mf7/oT1XSXCRXnYSJX9wIPRptAb7uhAt5jF8CqTN1sQlG9b++EHN\nXahoFR/y6qw97pZK7/dM58TEfJyMi3kGjwUFKHobfvVdpnE7H1ZKnAJ9e50eSFOy\nOexsmJfeDgPcGEocdqA/KRpdNU0V/RtY11bpJE+O20EFwxjLGmiYcDlfOq+Tr/dv\nkVudU3DaedL6fg5D41rnoyTFpyStuOZb+9Alpt7sv04N5QHjcxVHOqMhiKK3L121\n35Q/2VdD+G2LYOh6S3JWUtSJkzGkbQH1SCEQtTKu2LRO8Q01r4QXYTHvJsYmAqfc\nlwaXQ4XlI+3QHCiBx9izzYIfuZSmkzbvI6j9TQ7l7OBYs/GKEGQyLtFCUW4/SaGH\ng+J6f9500N7sFpyM+ErsZG0+r5vvIOG3uJGGeYCykNity9Z7gTF6xtgMXvpJDm/y\nqY8SPlm9DdyLTuCltYbqauS0Ji4ULKgXg6ezwom++vnkaFradV2r2KDfEI7Ou1bV\nBWWpq0O65hN8lg1TT25s7xMFpzi6Wu8CoR0rpfzYt+7N+SEU3GqDnkhhh0UbRrH4\nXojf0bZIIQt48k2CO5hokQuD1b2cyPfqzY2XCxvQgl2x8mAI9F5fsuq57YS46Fiv\nHLa0DCn9dUcN/435aR7UR82wVzmbJF+bv3NsvUhy8Ex2VcsZiTo=\n=kd3z\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.0/sha256sum.txt",
    "content": "91811577f91d9a6195ff50c2bffec9b72c8429dc05ec3ea022fd95c06d2b319c  jq-1.8.0.tar.gz\n894744a9f69f18f8552b5beaf755c77145ac2d76311400e23aee43df488e9c4a  jq-1.8.0.zip\n8926c33326111bcd67a47a970b5a5db933ef9194ad925994934c639c76a0605c  jq-linux-amd64\n1084e6bf5060a463daf77193888d326c83e56bcfbc18a52e6eaa99dbe82a8b54  jq-linux-arm64\naa52ed2f930b46c21ecd95c793d7aa75fd4ce2c63ff1423c4f19c948280ce978  jq-linux-armel\n4bebc752981c879d0b4656236a122b23f45051e992d6d2bf23ad4126c71e9e55  jq-linux-armhf\n5cf3ad973411275d27313a96d6f8e01acfef205515964490072f31812cbb9979  jq-linux-i386\n34069dfcaee4168fdced283e5732de8c558d696cad1910e607d9b68f80211a16  jq-linux-mips\n8a966bf92aca0641b500792599a715f4a126b537a3a2409c4fe2bc7c741e8b78  jq-linux-mips64\n373d5c84bdb4ececde6dbb37483c323470e9baae1e329aec8470533ff93482e7  jq-linux-mips64el\n118ad1e0a4a9bfc5a6677dd25822affd0ffb4990bce1ebe77b819505c4a75bea  jq-linux-mips64r6\ncdd99b2b76dbc025a9d475873f65e85d02d357a68be1f2935d7c9cd7e2f49ad0  jq-linux-mips64r6el\n015fe63efe32802ab57823236f704b18a9d1c4ba89b3cce7bf620613b21abcb4  jq-linux-mipsel\ncb003f147e53c7dcb8ab81745ef6da4b60015b0dbf2122470d0f3965d5e47895  jq-linux-mipsr6\n4b6dd650a13f9ad1c3f4148423fb10a6f25c2b1383854039938f21072f5d59a3  jq-linux-mipsr6el\n76368bb2e54d8fe0cbf6b3dbaf1c83c30e238b2b93a5ddf5403b7333cf7bfc0f  jq-linux-powerpc\n55a70db3bc817a0ab03f33d6e0df2cffc32a45a22b51bbc5d46424383016719e  jq-linux-ppc64el\nc8410cf481a2129bfcd323f6b4355583413e75a49c8a88c82bbf406d07401142  jq-linux-riscv64\n1f377575f90fa323d57eaa38532bddb7d6563236c83cbb27b558b3ea09574a55  jq-linux-s390x\n8926c33326111bcd67a47a970b5a5db933ef9194ad925994934c639c76a0605c  jq-linux64\na594f3740bf570f0dbc43ff102a9034c17719d1bb5b40f0192751234d67f172a  jq-macos-amd64\naaf1efbb376d6e3eaf61f63807c32c1df519f5857dfc4f581826fa2df4b715ae  jq-macos-arm64\na594f3740bf570f0dbc43ff102a9034c17719d1bb5b40f0192751234d67f172a  jq-osx-amd64\nb45fcbb27dcb9e9848ac39889a8bf86457b8d9d31e7c56387c6eab80008fd1f4  jq-win64.exe\nb45fcbb27dcb9e9848ac39889a8bf86457b8d9d31e7c56387c6eab80008fd1f4  jq-windows-amd64.exe\n47e2bcc9c3526ec72fe588136dcd592afaa139bdfb9be1d64244c9dc501b1e34  jq-windows-i386.exe\n"
  },
  {
    "path": "sig/v1.8.1/jq-1.8.1.tar.gz.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfkACgkQsNpg+0VL\nrxjXmBAArxAr5IxcLlEL5V8ZoEx2CpKlSY71qYqxtSAGkJUjh+5QDtZe079nhYLr\nIrrAJ/DpINcy8BHEVnchDKhzeVtRbJZhZ7AyIabMePYPt737NvOHEb34xisIOEzZ\nUNtwqeABG99ePxtcx1TFkeaKtsxZzXX77IsOwGbp+DCy7H4SanZ6t0ohdN+nyPMO\nxeqVKFJRfCbio7XPgokeKNObuWusH1BDKRcvhQtuDCDGonYwHRaUjF90Z8Lj0I7f\nvlxJCdxYstSBzCCQlFR49wfPvHAmqCBy+mJaXJB6Mddwnv7O0+D4PfHHlT3iT1jm\nFi/p/o8Qq1ldxk2JLJoF6sS2BEZzGeYkOT6yALBGHK6KQSAQ/opGaslUjrb4YrCI\n2/AQOJHyFhFVbnolgkAYEk+wBT8f6jRu3VOMj8iAVrzwtzR2Ir+rrlO4fBdXMNLw\nFy7ZiRWSzEAIuZ9i6lb2L07q9hrv7LX1EGCzyR4ynUfT72trBUXiEA+qUkhOGJ2V\nxaKq1AYVeJSvZ3pm7FCDQkhXypZ7Vj0NVbt/zxMqDmWI4sEeEMbA6zoOaLa/hMI2\n91TioiMSPbcQPDiwGRHfoH/vAG/iL44J9EVTBctyOI608qVFQqI+1TjnAusxmB1p\nbllGj9vzSkWr3BP+Huvgygq2AOMpZEruO/BnlqtiBulRvKu8dqA=\n=LC7Q\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-1.8.1.zip.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfkACgkQsNpg+0VL\nrxhvZA//Q1358x2VWqijFo0QKfM1ho5vCmRfd1O7iI60sT/1zXjQoIbDJhKP37f6\nUWpznXSbd6Ou0IoKyskh9s2Rg0Xzpz7UT0j/c+QL+KTiepDOuoo2q6HY8Yba3Aa5\ngad0M6KsUAdU9eabIrPf/DcLpRnNJPb/GIvjKoio7lKpX6e4QKmm2v8RYlH926tL\nOXuiF8kQHL3GlTktg3nK3X3fDmFfJupa1YBoJad3EHLk2AVQZsy8xPCWvq6F1K8V\neberB6rrCiQiEup1HG7rzObIUD6UJZJyI7Ltk/7qRHn099LRHPJ+h9fGizUUWlW7\nu3F/G7Jl6oazrngheUTC4c4kQGPrwpMKsWTmRRbQSYsIUUB6xCHibb339uxOgY+Z\nw1poLh3A0SbAk+RS3nfo/hXU088vbuXciVXIsldvOkFatI0F1OC/9z5CZgioo3DS\nCSAzO5f5z60B1F6Dw9IzmjOTGyzX0Cz2jP+c8kLMiW3JyycP7+m5U+ZDDVvl5Z/o\nZvhiVqvw1yZxu4zpzUsrBgtb5Bn4AMKHWta7RxoujUvPOILvsiwzAOZEUI+Gyqmw\nxsd++FRg9zV+DZyWxtQ7wJIzmdg8NEj+fJkvJfZ42bN3xFaP1Mdqlo4EvJeaD1N4\ndLR5xIZXhpttPtRueVKHjPjJTMBaxKTboecsNSe6PQQx1Twx7l8=\n=GiWw\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfkACgkQsNpg+0VL\nrxizCg//aopfRaQZnCeDT2yR9xPScBVcwe3tybTE2qmPETLTL0qn0QHzUPvW2CZz\ndIcgxsGgYAuaPB29RRwy++exdNZRVSoD6T6GIyIlmdfZzlOj1sUxtVSVogj65Szx\nWXo4QZ6OOAlW7gsy9bH5lrcW3f2MtPKsHKoHDal6eB00fUxuKbmlkqszn3SgaZQU\nX4G76zeSDscXZvqS/7svhjEBAFOdHGIXOzyb9whd1MRtw8AVxoRBbEoNG43ZYgVm\nQ1fPdAmuea4oXdNV4WCnmIm0Un0tNLSAOwCmQ6EQWnrbCjUupwMhpbgJYb99eEc6\ns+sdMwLxWXXct8/pI/vHcsz6PkgC9k6fysLkCBFy/DuNsDJNt4EBbZXIk3WEV3Vo\nhVJ9db9tMP7d7hpv99sFhgHubEsVBuaWRdy1tv+IZoBRXepTR6P/bm/Tox0X0x7Q\n+pusYfkNHHZSc1mA6765s49F4rDzfKrc65Oj9Y10z2SHc9K73dTrSR1Sp6oIGiEl\npVbP3ZJZx0qDFh33SO56CTIJrRUD51uzq2cKHHuzXLghVajU7Eq2lY5cgvJbHnLT\nJKWmhuUUsJwc7VfNiwgKE9gX62KurDPl26Ops86rPV2LZU7bOOq1+xQ6yDWnV2Ca\neg5/gIQ8Xmy0jad+KBAaJRpzuQ/HR4y6Q+GXbASCo85QW3MLl8Y=\n=UtSR\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfkACgkQsNpg+0VL\nrxh4vBAApGt06jJ/AyzrKq3NYCLlsV69sHXcucYR2lqE7uzMpLGITtTNdfe1DP09\nr9v/KOa50rO8v53AGQLFbK9++6IUsCGqwklhQzajtIOlkquzgoC69opECJ5tlBsN\nfJU6WRqXOXwxyVM29i4dlRb0qXrLkI+2j+c04Lb6RFkkCTrskVRp8neZgjc/a7gg\nF+44V+/RcCktndhyqTRqhlKcoHsOemQEaokgIVl8kG4cYVCXj2Ul10IKHlLvkGUE\njPa9RiDgP4Y+6DxiDNx33gvCb7SWkyFlGkygHDqzRQVKh8nNIyfZRMedtJiiZOmx\n6xLkpkBOCOZScHPOxTxLKPCFdoQEG/RQpMoehq2oVGBdp9BMp3x+unjBDi9TXtg6\nvtkhs5+G2Vd0b2LGACvqKhlFWbpDpZpYqo8NvwjZZh1AyR6QrQxjw7mdRSzQuzT+\nvyzn/ge6kFdqvWCUs9KJd86e3mzrc23i8mWOfpF7ydE/7HPKZJP+uzfJUrAwfY9k\nUKfRPS8MgAJ0PFUhW9kPZaPmmcUWLppn5cHqcdZ0lC0mTPidnZ4J1Fv1EyR3ipH6\ni5UGQbNpQ4Xc/R8jg0TIWYWht3hN1LAub3jM+mQYHRb+p08lpVGzccQPXIf4RlRJ\ncNwRQWkYaRorRTK5VzVmVslq5cdP0Bmn8Moa2B1bxzRQfZr/G2k=\n=TT0m\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-armel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfkACgkQsNpg+0VL\nrxh5Pw/7BP2io7rIy0OxmVBKSGvOR4ZZ6PIo6ws4hSiHB1wNXBUk3A9Y+5ctDFXd\nWrnWhxvI8oodVOmLtZ85wIIllqiB6pSaU+qKiQYvSwq4DBK0GovMxJAaq+jS9+kP\nv97KLeORhlP6EwOFXoE7PK4/pSktDC6XB45z2fwH4cfvfoOHNdcMMLm3Bql55ElB\nD+ef4lTmM2lOrz7+J+q2jtXLYEbbl0tlbbE3JEEYR/2vvO3D+jBivCt0tSZYEx1p\nEbvICvs2aJz6aKkLy9FsFp/lyQnDZZW8oqswbIjEKf4JEj9VztIDcfz3GkiIqDKW\n4l2NuMxnSrW9Wx7vNzUHhOqk7ragp5iA/WiOyVkxX7wgoS8lvWcoQWTVPCM4Vj6p\n4mc1X6ABiv1UMWYgzfGtjO7MBlm7VTmw9qVF3vMIOIW16UVdEv9o6o+uzooInX58\noUCVIFwjKtoPL1ne7vROqynqyjDUD7GsQ16ky/or/nOPKugNz4VlHriOTeXuEU5Y\n7IckJ3/kGRMlZDdPhvclxtwfvjb6rSf298dG4k5LownvjWTPfkvIf2OJvkUuCyWz\n4lMu/pNqDG5Zae5x+0DIzwTBo8Hn80d5WJZEuAj4yAAyXclibCvLTNw0QYQFaxfn\nHYy77L0XOVyzHrwIjG9lv+7R0RRz95t0xuUfF8SUY90y/RTQBPQ=\n=Qe0M\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-armhf.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfoACgkQsNpg+0VL\nrxgK3BAAhfzfKs28tG9zKbQZCuKMjnBeym3dbl8KKbyj9B8m/hMo/qJ5NaLyrwYS\nSKD+UtKjDkvWwXfZUCgR3z3zYcsi/LrHUi6IRsrdh42VTAufDO+gR62yaBRJg5TU\nQlZWDtH/24W4T9HhFmmN0UPwusDvurlLqRnghQqxY5fZaRVw39nP/voQk5MWeTQv\nmLVTMnb+bCBrUwyX22OAnCextl7qreCOzrP7IyjuH65cNQCHD8VB5CU4L8T/3KW6\nBF3eev7QTC8LTtJH+volYXVieu7GqZjTWwIHYL4FrplI3kAjITZ6Gia34sCqbMUl\n1LHyArm8MgqB18OVjWADUbXRFhf5EjUtA84i+Jn+C4FS55gb6HFP10j2Fr0xSosq\nL5NBUr9VnNeX/kQ9H5KWMROT5bf/QIcC/0zUBMtlTrhe0yEvMVqJM8AFYWPfGR8P\n0cJZAPA2PjX8fZZR7+BBd4barcIOBFrvGcyOmDLGYR26KSxCgbsRBOd9hVBYKGTj\nqr+f48pGZnSOyDkgcA6+3zx5Y1ktAZNEeZUDxVni3DmqYdA6jOoNdYaUqNpF8PNC\nFA2xN6dIx7u9dKH2Vnk3MOpU1691NBaLXFX3oFHGi5HYKu59oNDhvl1zELUB27LC\nCKkOfd8nDhmmI57RIMzUsMH3UqEIbAo18KPkWOn4flPevrIgLJA=\n=zhxS\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-i386.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfoACgkQsNpg+0VL\nrxgVBBAAq4nw+mrtPZKTX6JW51/edFkKfBmn3WGC+OszvkCN3Wv/RaouCwjLcgAo\nUY0NB3mtYBpjLU01LgPBTwcFkjJCkY6C70XH6ImaUk5z3TRwdB1LKYFVi/bH9VTn\nQN4VNaYy9OiGdwu8SliC2ulVgCdfWuyvPnu4maQ6XZEdyJ2bclVQi8zmOnY5mDs8\nfLOagioPNlLPZMEL8yDXR56gioxBMuOlDfVPCKl6kAPdAWp57olb29JhJ00lcW11\npdIBFwePtD1wpoxHrokSDpU+a2l2cWs9IUsWHzlwKUl+fio3rbB4nPo2ajYCFivm\naFDeWPV6O4sy8MgqTZAWWj96QhrytGwt+VytdFLWl43U1ocjcBWTlv9xXOP7plgr\nM38kBrrox9Dea46OJAHmVdsNTYJKj9+U6yWY+NJQ2T2y5qMW8tXbeTzKsj6r2KzW\nnwFuCkXSeXir+Xpy1JAkUHLj46rERWhYbcH2T2rNE+iWnjd4PXNZ+H1CBhUOgM8X\nSGe3pn3bo/BchXPCTx/mkbvErpPL+KzEFd/kMfzZT6HvDxFUy93555hG+cCV4MMI\nFa1d7PwayH0OAe6mOoRK4FG8xc9QPoF6XdOwwK0cJcw0vEYPd3x9U909ze9trRjF\npeSBgyzENwINL7+0smADRHT2JaTyMV5B8QRHS1+hkerJvauXCzI=\n=lKCG\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-mips.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfoACgkQsNpg+0VL\nrxhnsxAAxOChJU0wE2QSZB2VwMk887xMnlQp7/KdqqYxLGMUgYF5vrEbszefork1\nM/zWCCq+fGR4pklg4qvNiwU3ipFPBtumwxKJnTvvMhQ0Xdgd5xDCtyLP/wlBVOTH\niREGGzldbduM/xtWtVWE82KPE5jVrNDJJSIXch2gkoltKlFX+ry2+lATgjhgXc39\nVIo4tfV1/T+ceRnvG9kEmmO6Qxev9XlKFPlz4yCVx4BV4pHhnv6vQ5qyh5rTtHPT\nsDePmRHc0XRoJz1bImEEmcYXz/AtUcbOW6twt50icQzUZQIV9NyVdXeul1OH66vy\nnoNXDitRmn29w8vIAQfzvFp+/C7vyp1Y7IKHDLQPUQS95ZJQPFSO6kAjaWH5f4WR\n5xo2A3HMFWzuJQa66FTIout6K0SHxHqYD9n+wdhikq6ZFAX1XuzvkncJgRpG2rLU\nKEfSfXoaS1CMA29ZE8ELOflydJM03sxaTNuQ4FrzDek3kbGpfsczA48oOia9GgGy\npXCrmH5OP5nHfCGF0JtIZsWTu9QVjNmHlanpyUi2N3Cft+OZbjJEKWTIF+Ea6t9X\n6uVGy4WeJFS8R1p58jwY9490S6mvfhPlim/tfTJoutZxMNyHza5oHFSfwOeh3p7a\ndb9HeFAt0c4XIHXlT6q1W22Gk2XxHW8DY/o3/EyLMP+H5OxqK6k=\n=UCEb\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-mips64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfoACgkQsNpg+0VL\nrxjjPRAAzhtjW4Qqe1ZYoNOyAs1Gik1cJjAJpTWOQh7deFhHb6GdhelOr2olRvMn\nlczl/iAdXtJoMxXIBNkHWD15nh10UjSBfE4D+VzNwyhvLfJ9sLHUD3s5CiUTtwdj\nl5clbz9PYp0pTw92hE0WuXMfB2Kg0pAmsIsyHTK9bNEMukGNe121SnX6LZIo/dOB\nAp8hxMWVvarpdCAD/hsMfkP5lWtzWU2vHgaCpuLBUgyORYYIBupA4hRh6r91mEJd\nbTqwpRR9xt1sOHRNfBpUVStLK1ixv+0tvVnhM86Spr27Yxjf7qhUnoQxrkK9Etx2\n8HqX7qttayNNeDCY1nvC0vWanGXKzERu3e4kH4DtBe6zVC27T9BUCmUbrULt9eTx\nF1FICi5lScZ8K4FLPDvpkdVsfOpt5bXiXo9lbSzRLzojODkN0tSCPWqDktIFiAii\n9KL/b+InONjwyYQbNoRQf+AFcNttaEdMyiFbc3RuCeF5alHhezWnK2SBk2BUPGvk\nKhICiYRPkNuCAU1QFeTWDQbHfyRzn+sgq9rBqdh76ia5SRE21Pe1hnJGhjU3P+Mz\nTGems2qPYPxIhv2aXTeqONvTz6yd8QTvu/XD2DRxNHWpbcBec/mXYYQmWb2V9TeQ\n4aAxBOMbcsQzsIlHcKrxSrcGJTTLE0gTewylQ97TMTiXGsZ8jsU=\n=rKcg\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-mips64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfoACgkQsNpg+0VL\nrxhfUA//cW18nU9/jk981v6Wk6CUp7gAdRZvu65OrlEKwpjvVf4CYJEAQsxmOgLp\nR0Oj2plJ94Xo4BDbCjXULghfLjOWikQuIeDNVfLMV/coe3J25LjgK7ooO9/fIeFQ\ndLDfrjXHVl5WOmPcwDLeXnKHc5X8vd9hanxQcJqGKy1mqgcyNqUth4tomXb5BdGe\n9vBaNYiL3yKw3+OXtR7TNL6c8HgGQdXmkB2wcRCZvwCGxP8RD6avrILsyJs91YER\nESh/CwOtHE84LjM7JG+MmTZbiE5XAisiEw0Af7BuNT+LpZoD0xTy8Zegg91SjD5b\nHzB36qfITLlLqm44KjhjGh+ya8xyfCnkh+mvHMatXDPN08TucZ0O+WLiWUQdZlXZ\n0exb8Y4xc+92huSptZqwO6Ykrmqva1NGk9cKWlpeoOZ2hcR9vhaaBddgzS/1vev6\nEOBN0OnCSvUqznASlCkXTkPjTpAP5reaw1uSMKygc1dag3S9T8ncrDK73MAJU0mW\n4saT/fGMrDMMSGCDo5NKmm69PQvf9PT/UDI5iO7TKt4G+O2fuA01QNebZfC7nbkt\nZBBiO437I4I9Ut9uTG/aPj5/SVjzVfpLUeR62ZXVlbdb2yy+37+62xlL3w0jSkT3\nUGTgK4wLCf+WwKPl5mqsHU0waIKZHu/zw+SKkGzcVpr+EXTdTiI=\n=cTGP\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-mips64r6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfoACgkQsNpg+0VL\nrxgclA/+NcP0PjvBCWAz7S++K8a40f+8gv19guXn+fD4m8+ko3XTpLN12vmeUs9r\nimfehNYynFymgUbheM5rwZMzVM+a3jis7CnsiVxdoeh13sk8hhj9V0Apl3R/B6n7\nx50o+t7nXW2UJ5F6W64Iemekgv1lstvmPa6aFWmsqoJ/mweh538SOInLz17aVs4A\n2TsDdqe5Bnf/O2MIYIzA18W0+RDW88NnyZpKzpSJndTvkvoizUWzqTmuq1t7ny39\n5FGTIcfI3ertzTnqYqgSijuzD4YHAqw9QXytIqE6OC55Mqe5xX6sli38hYGMjJh5\nPip6zIJcTXOOZ3s4rGKx6b0VlhOPyUszPJ8NFklJ+t9i5mM911R36tCuyZBnKrTp\ncZYwGacBcGXFzHEWd/yp7bsRPQJKDHy9Y7Rq+vgGwXXihYJcFVO+D3m56saiEp5v\nji6e8cwRXW2wKAwScK5YPpIUWSl4SOvc6RGD8FSvYsk4Fnm88Hj+rAw92tAzAeIc\nOad4ok0jLlwBqzIlOI6m4FwxcQjV9GjqvJowPEyRhvU/3B/NM+m5ILoZYbR4DNeF\nZ2KVBYH/r8jnRmLCU3o3dFae1vxhw5croF1mpdfEW4NjSjU/HMmZ2aRwboLsF6+A\nmP2NjvkthsYSGPogo5MdkwtNqnvZ3eiQMwvT1hZ61POnZSc70wA=\n=Bd21\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-mips64r6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfoACgkQsNpg+0VL\nrxikKA/6Ay8GgKRAVJjy+om+268kM8bA7ai0S8XmHvaCrcV+UwvS/XPUeV8HQseS\nObl9Lu9MBJFdL1SCeDSGXSMJ556t+ZLc5Y31YHiaVVHI+4DGsItXYb9lVS/FzZ8w\nOQkNKPAT4BRgluManUGraBM8m3QPdVW/UcguLs/btotwAaTDYBUsCXY8TnT5wbUI\nnSyOnVHChhwa+eexNUPahn2wlbVmxapxxta2AQC9EADLdfHQs7yBpkbsUT1OJcFR\nJ0fvelkxwjWF9YkU3ICTz+ZGLH8k1Cido047Sx4kX9IcWufm55piH/KlTIPhZyrm\nFWUUus5+pdPyyZWI8m2Y4m1ctyAGuGcZTOcN1RhRFhvcOlrMh/4fs20O0Tq2Zvqo\n0sSVE3GBB4gBc2UEaqI3GQa7QjnTqbbQyJm3Th+BN3WKXGENB96Q8QH7oY3iIklT\nkov0sTvx4XskyeiHPR2gyvl3QkpOE1aazaYXYyesUWcNal8P9aW/7QUPz+eYviNJ\nFTfHkdJoBf9bLX0RNNhTek8FsQYLGdTuA9qjbbg5z6QZ1AzmsUkwlEEFhBW7YWQe\nsX5FQo1VWx4UUY0crdilt1PfTshOGPiXL9XLU82tLhy9baVJPs6LfsrXo2lz73b/\nXO3upRrKrpduykvxserln5aQBv/zjR81vIJjYOYG1vRjey3TkEM=\n=UeIm\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-mipsel.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfoACgkQsNpg+0VL\nrxgZ/BAAlltGoXK0MpmzkSElskkZeTb1rtyIITmpl6w7dNkZCBpx0oIuGMIPwOud\nCy4s8PTZFU23k3geDBqksEo54RBxUPJi6HS8JfypbOICuAKk1yg0vaVsqA2t3+o3\nS18ihUvkcULgLCbzWxs1kdWvc+Ay8LDRUh9fgNOmeRt0wBl5UGQihN8lsF444Oif\nB4BvB7Z2rGuMt6mZAnpc25QApkjg8iDaE3SpJLIiX6hxUypZ2B/qBprelsi1Gy8+\nuMad4U7+qBR9yKI5MoW5ySKGY/Es/DtAXHK9BWC/QBN182Mp5tjIt5ssENfKUoum\nuKAcQd3y9yidbYLJSyHd+Si1jtBflHgsVL+L7dFpjsYnmaUY5s55LiNIh0bunivl\n2omI8aplHUznIz8Cvsm8EGyYFdFzBbIgkYD3MIiqINroWAMXapMYqrC7zivBw+xp\nh9Uua6q7ZWaf6jgCecotplv5JNh5XhjzH7HZhz5pWbx+B+kqLx+c+R7JqtBFuP1C\nO7b8A4yaCLjwmS0OZjsgeN52jnjV5BUK7bKH4MB5lJ44T1S22JJ9qYDVb/3KlwSA\nfhIZFD72rkT1WN2F0VbqCvMdYdjE2+3CpTZ2JBuTPw6Bw2v6W1Gx2VCAaxPPF5F2\nJ1vlcFQJs29wg6Oj6vMB+KA/dbhiuoau/3yI2kwTIvKs4FuzapA=\n=Rw8v\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-mipsr6.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfsACgkQsNpg+0VL\nrxim5A/+J4NVXvavvOcEYclpqyNbr7ihVXFESF7RzPUTNeISsc1wd8GpMUTdfUDK\nVK2nc2o2XMxnwDlNzitGk8i3eudqmQxShjLStE2YkhsU6bsLuPUaUeeksQmebKWi\nAcgZlk80xQYbnAJut942jrOpDNspqdlPB3WrY0VvPlrxL31bBc3SnmIbEx5JNJom\nAM846DVxZUoHDAdv3PtEPLDVVvShdzpXwg4X+CLpjfixIB4GRFZWG1kYHIHF5dQV\nA2ZvTChX+Mng79IM+5Y+/WQTYY1A2iRNoMVAqII2Km53/m/ikQoNeRL8pCrfQWIB\n12A6hHQ9yhBUaF/irRcyod42eqEvyV2UlqFQ5XbW1SMEw49hfL52Xscga74EXisc\n3+m9sBR2g7GmHj3VVQlqCJVh24BXar/JyVlVtvGMpyXXM5lM7PoxtZeT30onpLGe\nGBxbd2Dlzza4eFol9aWZDOjybxmsXLdJ13JL4aMy6H/hSyZTQJ8vte6AnHLDsE+1\njr1U2hXsEMfZRAFoSYVdj7GW4jOjUzr5F+3flRyYKOfch1GoQNt6gCCNyNifqvZO\ncWWWuI5pHT70fz3JDbWPxklPkJt9qF+fiz6yeIJ/XpOcDfGrLxxaWbkcZkJqXhVB\nmKD7HmGVoy8cj38WMmmK1pyEk5Ct3H+BzkzdeSOvokQVJkJc+Vk=\n=l6+/\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-mipsr6el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfsACgkQsNpg+0VL\nrxi0dxAAhfMe4ciVKuin3ctslLmGJM67fHTvmOWOZIfjfBDzvezsM8LDfxqRHyUo\npB7MF+Utq+Mqt8leaqIMswFxXbrCa2VT3FjF2/VUuq/FNtSlLOwYGPUg0HOGjZpY\nriFL9Pr85o+3Op+HvVa63l01dqI+eiPKRKo/gaI+ay1rQ81q3wiJx07lFFdKa/Oz\nqSaznsn42AWD8yHYTETAIisZKTQUzA6blJ47DvECqed60ka8ws25buB5OXvXYzTa\n79ThTjB7W7+7mHUN3dJXyZ1rso79/LMy0Zoc7IuHJyYBNtdVpzQ4iwKoL56bsy26\ngRU4zEkTOIBw4l58VSyGBvAZOgjQFn71iIiz5wn6jQpezCkA/vi84TiwP4472wQP\n9Q/Bj32oHP+mdQwg6cCiRmitvN6uJhg1WNdYgNiB7MVM1GeRRHndI2Y9OPxCARDO\nGCmZ2lha4bKgP308n3rGtf8zHtFf95pYRfGsMq1b9o5hV8kMALW0kwFljvaXEieO\nqvSBoapUs5hQ5UIqLQ9m644ctbJRagfXqnnslKp4+coxDyoUfbENc1zQNiIFHai9\nffcZhkPgKRgKiNaZwj81fGjlwM4vQ9MsiMQrAZcoucEXtJSIzom8pbiyAwfNaPO+\nXCaxBRTGMEzZ0h7+6ZQEv3HTFV0vK55qPaTlx7zHkgQDJ6ARxbk=\n=lzcq\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-powerpc.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfsACgkQsNpg+0VL\nrxhrdQ/9FxbTPxmMQuNCM6iNL8UcvItJHGHDeLZaL1YdsS3h1a2gGjmukH3TM3Cb\naIsPVl6mhyo4DRH560eawrtmYP5Y0TcdcSzL7ufKpIAUVDQmYo5PsiCpq/X8rS8C\ncWrTez4cElUl60IUzFqt7/B7xTSNQF3qw7tr1fD0VESxDSo8SnLRGpcRhgp63Ihv\nFM0MP4zaTTWgQCoqr2OZ2vmEyHOx4XDyz1THDg6lA8YBqvJ0E0n8YluCVCSNvCre\nncuk4WX0FOuLSGA4neYQKHxChG4kr9PmuEp8+O50EdxUtG31jsDARspaFilBumzh\n2eJ2Y35TVsnRJiu59Yo4KP/PaaGMmL8CnlYAcY+qxA0hb3f/zj1e8TbpDr9SV3r8\n3Pd2Psg5TQmtZYPtTYvzKaapzPwtIomSQDFOv7dxUU8ZuEbGKLfAECyAa5t6lejg\n6AaRb1UIz22rszUPNyimz3r0kadguIde2Pr2FsJV2yVLRkK4+yJCZtQ18vAmfeqP\n/qXW9PLxfTCsqxkixAwyDlwm2QpTBg/xnMWOHF2m3TxvHoJfny9hF9rIY8Ocg4NJ\n62zFHBwnSUYl8ibcR6bGE2dED9E282scPphS4cxifR0jqKHm5b6uQbK3R0brSDDd\nAMiwRgMKIvJBaNAda3+XD4NXQ1iFtwHthPvI3fWlZQIf7j0N7OE=\n=6erF\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-ppc64el.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfsACgkQsNpg+0VL\nrxikjxAApfPUif6FPbDNTMY1QE1IaKqXbN7kd0YYplC/mTAIcctA0yh0KQWH8Z86\n0SG+HrYK+JUM34pps1FF+NYnKzV6lBwrcHM1jX0WgtiTw8OEH5OlFyiAzkixAiFi\nFh/sWhaIw05Q81KwrparlXzVJlpYGJ7lrr2qF4EMN+KTOOKs8oujS2XRa7DSqE5v\nXfc9Ixk2FFxNygI1I+nsV5NPvPb7a5/Ld9gALpl6XXKMbDsHLVIM6GSQSfSwnEqm\nrXgF3mhuX6iTVwDsOFlYhA2yHXXxDYiFi5IyxFmaTXv4/892pkICx1XRoN/D5rkB\n94aG2/qmAs/qPnO7XTSkyFB/eLp0lgEBFmuTtNRP5l5SgN026LBLeiNFvoViN9kC\npUUVliAGth2MGlVigYlpWtZq0nNWgslLI4XXBfBcKssKoalmU0jMIMrI0fAMZZn2\nuvn/Ev0ZXvedlwMSUmDxO+5i+izyTBsdLurYYMpoc4GldDTYCNo7NXgFNJ88Jymn\nMKfPeBHrtT0Hn6AfeyR5xy2dMp8Cm5utfAEirjRB863RPxfGUcxs1kTIscwhnXAh\n/om4/FLnZB3sYh8iFv93/rrlj2I2tEZK+btYeRjE8HM2snizm+VAviBT9k8C/T94\nBb2gcMReFqVEssh1eChEhcNJuHdzjs/QpcbbQM+8WhSTHFbo9x8=\n=WNcQ\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-riscv64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfsACgkQsNpg+0VL\nrxiTRw/+IGBpjEdSptrrFrnfXfKYss036g+ej6AK5b5VWNpjNTN2LUvJXj3A+WnK\nPE6trAbcIvF3mW/G8TCKEe+ZFp/2vwoNVoRCLluK6wDwRYPVCAGtro+9+JZUM2HL\nYAKkXavkIC2QKSA+6i7IBAXshRiuC7t7Qrxr1FRnjYWP7Mp/62Olo37H2XSqYgv0\nzjr1jfs3dB/DlPzY0fCnTHDkxgFI5Rrw0AdIwMsKAoPHgnDUlneSZqKYvYnKh92d\nljNJK9RkbuHLqJE7A6nzWX8FXu8v4S26kzVX2j+arw5KQe4GgUn1ll9wNN8VtCFE\nw/HxJdZfy5RCVOOgfVr5HyLmskEdxnNLRKYWvkHK/UQaFFlPRKKROKlEGS2PLJ+a\nkD6MixVyJNdKnwikBZk4QSsGvybX3kuoDmCU3fzwrKSPW3oEkRrd2sy3i3Rh4TH0\n6zBk36LaU7piJsHsi9a16mNNos9DiQtXdivgZDZHTIQCO8K3M0Uqgbgax0FQfTsE\nMTlYAgEX1No6jcl/0koZnqCwQlRl5PZWKT41Ul1ntqKEGPIaZP4eME35bFUcgqeD\nA0UdFOsAm/1+af3PD4rR4s+9JEoUbdBBIhweajVz++/kS0DMEEW75W//gMDzhCLc\np3okQYSdTtta0y2xjNFaSis+aUehDrnDGee7/aQA19S47iUpZAs=\n=1f7S\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux-s390x.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfsACgkQsNpg+0VL\nrxhC9A//aqqfv+VEdVTlHohl47DPuxZQoj5180pC1iXNRMN9gR5LmGXbHyrgQWW7\n8mAVuFi9KC1SnmDeqSelp4Nb/RrlZtBSGP4Jc8gyvzRdewm2ozP7H26AtBu1/0fn\nCa/TRxz+nMAQh1rlp7K7PFXYcWaPwuRIz18yJIU8UQ3EIXgtLCp77eKNEYqLWZvl\nmZzInSwlxA2r4w+Ptoaozq8GahH65rTvqTBDpRXizktHA0IrSkEKl1Z9f2yJcPo4\nkiBFdLz9kfnQLVdS+XiLN+CFb3qf6lLYdOMwW+1JOQyv2oH6dPtFReCEmOrnYpwl\n/pifCL2yH6RkKQnLQTLsyKWHMjRhMzn6uQz1Jxv2ioiqnUYXKk7aBvs7gDrnHwlM\neWWnq2i5BA7Nk/DvovSHEg7NZaa3+bCBojqUaTx+DD/2L5j9V73CuteBxv9TFQfJ\nG3wwS6tL3PmErbrEFYwv0eqk5qfA1m7u90M+lpEQJg37qXNU+Hw+ethpuEsVYPkf\n9t/NSTXs/rMIX0X2hVSC6C6/klzgJ75EHaRUFafJ/ZouMXJrlpK846eHf7vT8WVi\nX9oDPprPT+YvVW5F0EJygq9Wnttj+7/JHYGBU6DxXIOebXWXo2cxK8Tp9X/x4rzb\nPDEPy9zqB44fpkYtIW8YWIKopRiaaI5ag0OVHpzq4KxbyfCzgvY=\n=JnMG\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-linux64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfsACgkQsNpg+0VL\nrxiAlhAAwRvgfO4ty3SLc3Qz9j9T4N2k0MrQC6aBqG60yn46PonWcINinz2QpKhE\naCTBav5DOxcAoNtXH3f95+ALyWQtVVQ8kPxbR1HF2rnYePjYC64Y2uAFOt+ugQKh\nqlefeIJ7KT4QrvMqQ2Pdp3AOg1jJoX1Gv7c8AMmdB2KK9s+o0nOZ5/u/K/T1WcKL\nTZOZPafqdggfMKR/eczMMXsk4rK3E1hE7jxM/vhq5FOOlupo0E6lr5gCtOQbCupH\n2XsbawZdEohp4MvrryfKg365QfRWoOEMz0nlH5hAq2X3jEQgzZZFL1kVMzANF+9K\nX4HKF0Bjs/D3po1cBSQG3fi2Pyysm7Ams9ubiX2fiB8UfCuI1+oPlZ6F3zg9JDST\nXf8MbIxPlZuP3T7f7PLox2wm5SyDE64fXi/yRAih0QL9I1pSw6Y8aBAfdrcRdafk\nuzGA0UL7rpNhBrtRC7t4PgRJrKlN1l26XrqsxMBw3XrAjR2hm43H+686uAmjqDGL\nP5jZmfZXS+dc6zP5oSBm1monrvG1KnxLD57ilqfULbE2NXP1fhjaJYjrdClY/5Rx\nQOzxvOPtMHBVRvHsq2Ar5yPjMN0dW5wc47Um2j4w2JxSfT98YRP8TNoztmrkHcJ0\nLpyKh5T+WSlq7Dsu2OY3KgXkOwF3o5BGuZaIIr0G4adW3rXwtOA=\n=KebY\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-macos-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfsACgkQsNpg+0VL\nrxiBEQ/+PCUBjQy0wrxgOpFnXRlp0VswmJiBIBWDo6cwg7Ohb4lz0lZsaq71KoOL\npt3OdrkoKchPSMCDxiPU3GIDkacdOvXcFEodB336+RGO0ki4nZRokq/M8eo0wZMu\nWuSunHp1cLgQMcuG6Wm05IF6B5h/Ll9UWyEmOPiKnL59okVWM276N8svICldJEB9\nPDngtFy6mXRV3Xc+LVqSpmkKGXUWjUSPasNz6CLu/zK/9hQtXEWLK7D4na653Xnd\n3a2XZmZnXOH3c2vGTA05eK2WDOtaU4p4aS4G1qKZPT6ixpw9crg1D+Puqid6tDkI\nqQFgN6MjPh6T+N9chg7Dc59IOBLBvuaYSOm+zUPrb7/PxXqdAqh3OVlvddndT9j/\nHggc0yMp7UzJg6IYUMoUQekCIUqxLTDkQutoYDep/jqzqkOvvxQmP6wXslk+GNAk\nKM/gIlW6klmdSa869bQS1StyUKqv8EQGpZy2mv+Y81G0RkU8Px/qj/Kq+CS/e/5s\nBnMvP1UnDqr2pwe2/KWmeQxbMJLuJ5sVB0ZtFMbHHta5rnLYXk5vQFDVF+AqigHw\nOS9UPakiua916fPHhlWxAeq5l/GsQPlCE/l+cSXIjjsrcaQj8pVV+sc7PcznBiH1\njszIXhxwCJ7gKYKnGbLJ5dLxS2sra9ujxktouHCBEtispR/9QpI=\n=Qp9I\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-macos-arm64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfsACgkQsNpg+0VL\nrxjLkA//WPyTXeDRiIei5i23ScntpilJcP/GeEHNzNl7ucml4DMzQpel7bnpcBHy\nciTJ2JLA73NHJIeEiMFavq9gQRCaEG/1gn4Mv67WQcVitQcpmPsrYfTKcjrzHsc6\ngNOc9QVONJeFqQlgFEv1GbAyC0uZjwecq4zBTpefZvXm7bZQaWCLpNphL4DStSbU\nAGnHhpuBriVvLg9C1l1nS14GoLLf/rH+0p5tboYbyd84OPWC+gmAAq+fuW5NlV8r\nCFs1r0ZyiXSAuKtDmL/axyOgLj6hds0IeXuGYi/AcmhaaHlrtxZF1atZZ8GBdHC5\n1Hjwgpn/+Qjh3muM6/mulsS4HFKdmrVj10rpNspMU5HLjGafSQEyiylXz7F9EM0M\nbexMaJ/dMMZrnGTMl6wt2SudiHNO+e2XAhvMqoeEraHekC2joZZPKAHpYrxjUdMc\n1eOpUVMmRCtR46SXWbzO3BNJg2W8K3gKPr5nm4/MMVcisxbQy9tC9U21EW2IONB9\nNNgQNc7Dl72bcLZPKfXRBt/1Vp5rCAjsiRSxMsYB5UgIHRYKkVFX6zMHApWSkBt2\nAXjfw0ghJ7LWSFh0CwhN1hUjMYxafLZ27WvO1wTErxnoAhlwlC1zigm66R5o12Co\n4CzivuE2nM8yGIcacem+P0j0aSVhvRAzKzBul0tE3yxldG1DfZM=\n=XwMi\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-osx-amd64.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfwACgkQsNpg+0VL\nrxhXKg/+JtQ6RPBYpeCEP7DQOBW7iMrCbhmqwnBpyF2mvDwtEzICdm8YHbfJXxcR\nfCsMbafYDtL0XdKjPC/Y08hvoj2c3tB4bUI/CTWv16XQRRvrb9JKsrtyQ8NybOkC\nwkaQ495/8vAHi3FMsUuCCe1PxwPZ10tl0K+s2ERwKjjPkmf2JejdYxXVrrpfClJW\nGlcXItQsTNDTaT82Jj+pAmND0ReSBcgRQi4sFDnfmRKhaqKPF2MApWuCKTF4mtZe\nibgsYVohQ7M5yD9G5fitnN7nHAIhv+LeL4USJis5U7HAQVDvGNqJ9YkoIh2dutBj\nV370l1RSY6/EzvhN4pN9E5xBF4go2T83SV6pbLc8PPx09Er2r3TyhKroOaY3DLJD\nUjwUkQK5wirNnEa4o2LNookE4jLOxcg6L/teKPSJNjoB41sQCcY1oUsSbI2M2xQL\n9WOxyYUbjzKdeXxQLExTFcT9uNJ8WC3H5LO+5Pbl8xV+Z+ZBf1m7q6JtPRGmm3X2\nWiPrm3zieoQEqu4j3cVF/+6oUwG6dWgTUOaogQp+Oc5CC3SuWJ00KFly9mZVG1Un\nSfRvOxBWanNqiFFmjj+LdCXQx4kOnSybtp16uogP1P8462wu3cdJjwL0qTbcQU/H\nmxNtXaEkaKxDim8SWs+M9Vkr2X0NizRiH1P0hHBWef3MNEKhzTI=\n=KFTr\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-win64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfwACgkQsNpg+0VL\nrxiSMxAAnpXJxH+3/6kN6lD4bjNUYiFPo6R3BI7t05jm6UGVcYwcB4YC1CAFz/6F\nLt85WVrsmnnvec/eb3/4yhnQL4OsbQrSX/YHLjmVuc4od3JMiXK2S8cH4RZunUnj\nWLEXfzBYGeb9jAM9NW15jEojbO3hboWgqlkGq1VCO8kFzqByGji1EvbayGF71ZSV\n2tNEofxom+L7fC7HKH1dYZN9lzYr7LJZM2R2xGAGo90uxIz6PINr8wZ4X58crLFA\n+pjppPBD76xBqE+o7/Ey2xxxLq+E5MkdNLgurcFBPO1xhBPTFOeNcDZDyyUE8u0V\nNx7bjlOUinQznZAmE+1KDmhfksp7x0fiaofpzS0g5RFH+u0Ygrc7FBFOQdnzOE2Y\nH5i8lvA5/ovad5TA3IaUracPKfH+oA781iubH0DRnu0czRSsciKhJrY7diCNFwAm\nMXFZljuqrZVZGSDLyltwvyCaVeyqzTYqWsaXsz5joWWwQ73KqxB74fDn4KGiHI9t\nKul493ZO5JUykv/Mtyi8M+eHjrBIQeDKVWt0XZiMXthi2Ip+orW5qw9hfbZS1seA\nru9jg/m3XNikapGugMSN9yxGNT/hj9Czthwm1sNWbxNs2IBKKLwGDTgRVc1uZ+qb\n2HmccMngPUIdWSe04068ZjDbMtt2CIiLDkd+xSQXpifOzP+uTck=\n=EoqF\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-windows-amd64.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfwACgkQsNpg+0VL\nrxiSMxAAnpXJxH+3/6kN6lD4bjNUYiFPo6R3BI7t05jm6UGVcYwcB4YC1CAFz/6F\nLt85WVrsmnnvec/eb3/4yhnQL4OsbQrSX/YHLjmVuc4od3JMiXK2S8cH4RZunUnj\nWLEXfzBYGeb9jAM9NW15jEojbO3hboWgqlkGq1VCO8kFzqByGji1EvbayGF71ZSV\n2tNEofxom+L7fC7HKH1dYZN9lzYr7LJZM2R2xGAGo90uxIz6PINr8wZ4X58crLFA\n+pjppPBD76xBqE+o7/Ey2xxxLq+E5MkdNLgurcFBPO1xhBPTFOeNcDZDyyUE8u0V\nNx7bjlOUinQznZAmE+1KDmhfksp7x0fiaofpzS0g5RFH+u0Ygrc7FBFOQdnzOE2Y\nH5i8lvA5/ovad5TA3IaUracPKfH+oA781iubH0DRnu0czRSsciKhJrY7diCNFwAm\nMXFZljuqrZVZGSDLyltwvyCaVeyqzTYqWsaXsz5joWWwQ73KqxB74fDn4KGiHI9t\nKul493ZO5JUykv/Mtyi8M+eHjrBIQeDKVWt0XZiMXthi2Ip+orW5qw9hfbZS1seA\nru9jg/m3XNikapGugMSN9yxGNT/hj9Czthwm1sNWbxNs2IBKKLwGDTgRVc1uZ+qb\n2HmccMngPUIdWSe04068ZjDbMtt2CIiLDkd+xSQXpifOzP+uTck=\n=EoqF\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/jq-windows-i386.exe.asc",
    "content": "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEkwealRHvwLfWzb+1sNpg+0VLrxgFAmiLcfwACgkQsNpg+0VL\nrxiN8RAAuOpoknd+8RgjTvhJSkG0It4HwoHU/fqzVbWI2LwC0hRVrpZo0YZaLeIk\nwOpea2J0IoYo9y16ERdy3kpD0Ckyf8TTpGhMLeOwP0VyRd+6nT3dFTGG9StvzonB\nF/WI9b0DnykPbDdw2FgJrFXM2JfXD55RZKfu0nXlFui+tUrZ0xx8TNVnYSk/RKyM\nIwzEH8JsgWbhWCN83foUv61VpWtB64YmR+PtpK5UxHDTH6yClMX4/9jQUVdz+mxO\ngrvlgD8me1wkeco6OMBGgj/Vl0aEBHLs8jPYVRSQ63+y+lEJJf5Ec7XraSypac4t\nT1xaOwu9ujnkUfLVwVRCRO6QBVMpFmirKbo2K6A6XtjaGWKupqW6nsNXAZx4ox8V\nuuzi+yCXD069vnk3tgjJJwto7UorWfI+fc2JcSYUoZ6fkpWdknyqXUkif/BDSDmS\n1FC/FHHwDo9mdhwWEN+IoqHO4pVUJvl6muu9fnOxMhLDGH9t2AmfyIzIWCcBiNCq\nSa1qGHLogfbYPeFB2lqULTP1lY9FEvkFYDqgZRRZ+KSv6s8ktD/JRZm+AmLBQI+Y\nMdYHiessm0UwtHwQWVrEpYRQ6gZKq9T2sk1llEfMm05TPUkKSD4/zHwfPTEY+CVt\nxQCvJRe1xktg9c4GH6o1Lse+AsHD1yjO5cW7H2VRKLp3Qn3GtN8=\n=5Ar7\n-----END PGP SIGNATURE-----\n"
  },
  {
    "path": "sig/v1.8.1/sha256sum.txt",
    "content": "2be64e7129cecb11d5906290eba10af694fb9e3e7f9fc208a311dc33ca837eb0  jq-1.8.1.tar.gz\nebf8ef4817fdc05bbf22f54115958707396c3e62842fbbb617b766cd40b51f59  jq-1.8.1.zip\n020468de7539ce70ef1bceaf7cde2e8c4f2ca6c3afb84642aabc5c97d9fc2a0d  jq-linux-amd64\n6bc62f25981328edd3cfcfe6fe51b073f2d7e7710d7ef7fcdac28d4e384fc3d4  jq-linux-arm64\nb98e283ff26cd7478f6fb18cc081ca0e0cb2e9980300f0bfc8bb26854d347eb2  jq-linux-armel\nac304e50cf7cd24933d83dc7d0e4f79892a71a92fb02336d4ecaffa8933760bd  jq-linux-armhf\nee8489cb8acfddf2e6d2ab4308877b5cbb6ec6b55beedb7c6d5a4fafb2879c86  jq-linux-i386\n6ee8cc51b6abbcedcd60de1eca61ec74b02cbe222d02ae4622801bd0c19895d3  jq-linux-mips\n91815e1000be7765e568f56b2a1f14cad58820ee772d952b514fa02085c252e3  jq-linux-mips64\nabd7cda5556a4b8dd1f0bffeefae7142edd8b371f0ad232f4b786071eccbfaa4  jq-linux-mips64el\n99d16b9c05c7ff8345be7b45b2eb99eec4f185c931d03c8bd7ae86ed8d56442a  jq-linux-mips64r6\na1aa419dc2b99b354d7e3d1cb9b7359042f3da4e3d3afc4e4b94d1561f5e401e  jq-linux-mips64r6el\ne4c10ea6b02e07d0099b624134f06849675b59e353386b0059ae15c0631c9ad6  jq-linux-mipsel\n1171742caf57106569857a9bb3d0b39243d3bd03504d22622150736b2844c4f0  jq-linux-mipsr6\n6bd590582a88ccb86df4725e071fd43becdc90e764dac7edcd7cb1b6e7fec848  jq-linux-mipsr6el\ned48a57845d0771e2a35c2e8a0b88e26ec884c0b7186c6e390fc4fab965ed835  jq-linux-powerpc\ncb10b38f4e5ebb3904f383f24944a6c03a373b4b125d2928ccf52f8ea78f6f73  jq-linux-ppc64el\n3d7274ea14254f0220b6a6d1b8756a957f739b6a20e3886358377e8ea6687cf6  jq-linux-riscv64\nb792df2f5cced0404a5fd3796d7d47625dc087b3e3dcaa81017088590bb2f3a1  jq-linux-s390x\n020468de7539ce70ef1bceaf7cde2e8c4f2ca6c3afb84642aabc5c97d9fc2a0d  jq-linux64\ne80dbe0d2a2597e3c11c404f03337b981d74b4a8504b70586c354b7697a7c27f  jq-macos-amd64\na9fe3ea2f86dfc72f6728417521ec9067b343277152b114f4e98d8cb0e263603  jq-macos-arm64\ne80dbe0d2a2597e3c11c404f03337b981d74b4a8504b70586c354b7697a7c27f  jq-osx-amd64\n23cb60a1354eed6bcc8d9b9735e8c7b388cd1fdcb75726b93bc299ef22dd9334  jq-win64.exe\n23cb60a1354eed6bcc8d9b9735e8c7b388cd1fdcb75726b93bc299ef22dd9334  jq-windows-amd64.exe\n414ec99417830178bd2f6e77fc78b34de3b12fc6b6c3229f07038c5811307124  jq-windows-i386.exe\n"
  },
  {
    "path": "src/builtin.c",
    "content": "#if __SIZEOF_POINTER__==4\n# define _TIME_BITS 64\n#endif\n#ifndef __sun__\n# define _XOPEN_SOURCE\n# define _XOPEN_SOURCE_EXTENDED 1\n#else\n# define _XPG6\n# define __EXTENSIONS__\n#endif\n#ifdef __OpenBSD__\n# define _BSD_SOURCE\n#endif\n#include <sys/time.h>\n#include <stdlib.h>\n#include <stddef.h>\n#include <assert.h>\n#include <ctype.h>\n#include <limits.h>\n#include <math.h>\n#ifdef HAVE_LIBONIG\n#include <oniguruma.h>\n#endif\n#include <string.h>\n#include <time.h>\n#ifdef WIN32\n#include <windows.h>\n#endif\n#include \"builtin.h\"\n#include \"compile.h\"\n#include \"jq_parser.h\"\n#include \"bytecode.h\"\n#include \"linker.h\"\n#include \"locfile.h\"\n#include \"jv_unicode.h\"\n#include \"jv_alloc.h\"\n#include \"jv_dtoa.h\"\n#include \"jv_dtoa_tsd.h\"\n#include \"jv_private.h\"\n#include \"util.h\"\n\n\n#define BINOP(name) \\\nstatic jv f_ ## name(jq_state *jq, jv input, jv a, jv b) { \\\n  jv_free(input); \\\n  return binop_ ## name(a, b); \\\n}\nBINOPS\n#undef BINOP\n\n\nstatic jv type_error(jv bad, const char* msg) {\n  char errbuf[30];\n  const char *badkind = jv_kind_name(jv_get_kind(bad));\n  jv err = jv_invalid_with_msg(jv_string_fmt(\n        \"%s (%s) %s\", badkind,\n        jv_dump_string_trunc(bad, errbuf, sizeof(errbuf)), msg));\n  return err;\n}\n\nstatic jv type_error2(jv bad1, jv bad2, const char* msg) {\n  char errbuf1[30], errbuf2[30];\n  const char *badkind1 = jv_kind_name(jv_get_kind(bad1));\n  const char *badkind2 = jv_kind_name(jv_get_kind(bad2));\n  jv err = jv_invalid_with_msg(jv_string_fmt(\n        \"%s (%s) and %s (%s) %s\", badkind1,\n        jv_dump_string_trunc(bad1, errbuf1, sizeof(errbuf1)),\n        badkind2,\n        jv_dump_string_trunc(bad2, errbuf2, sizeof(errbuf2)), msg));\n  return err;\n}\n\nstatic inline jv ret_error(jv bad, jv msg) {\n  jv_free(bad);\n  return jv_invalid_with_msg(msg);\n}\n\nstatic inline jv ret_error2(jv bad1, jv bad2, jv msg) {\n  jv_free(bad1);\n  jv_free(bad2);\n  return jv_invalid_with_msg(msg);\n}\n\njv binop_plus(jv a, jv b) {\n  if (jv_get_kind(a) == JV_KIND_NULL) {\n    jv_free(a);\n    return b;\n  } else if (jv_get_kind(b) == JV_KIND_NULL) {\n    jv_free(b);\n    return a;\n  } else if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {\n    jv r = jv_number(jv_number_value(a) +\n                     jv_number_value(b));\n    jv_free(a);\n    jv_free(b);\n    return r;\n  } else if (jv_get_kind(a) == JV_KIND_STRING && jv_get_kind(b) == JV_KIND_STRING) {\n    return jv_string_concat(a, b);\n  } else if (jv_get_kind(a) == JV_KIND_ARRAY && jv_get_kind(b) == JV_KIND_ARRAY) {\n    return jv_array_concat(a, b);\n  } else if (jv_get_kind(a) == JV_KIND_OBJECT && jv_get_kind(b) == JV_KIND_OBJECT) {\n    return jv_object_merge(a, b);\n  } else {\n    return type_error2(a, b, \"cannot be added\");\n  }\n}\n\n#ifdef __APPLE__\n// macOS has a bunch of libm deprecation warnings, so let's clean those up\n#ifdef HAVE_TGAMMA\n#define HAVE_GAMMA\n#define gamma tgamma\n#endif\n#ifdef HAVE___EXP10\n#define HAVE_EXP10\n#define exp10 __exp10\n#endif\n#ifdef HAVE_REMAINDER\n#define HAVE_DREM\n#define drem remainder\n#endif\n\n// We replace significand with our own, since there's not a rename-replacement\n#ifdef HAVE_FREXP\nstatic double __jq_significand(double x) {\n  int z;\n  return 2*frexp(x, &z);\n}\n#define HAVE_SIGNIFICAND\n#define significand __jq_significand\n#elif defined(HAVE_SCALBN) && defined(HAVE_ILOGB)\nstatic double __jq_significand(double x) {\n  return scalbn(x, -ilogb(x));\n}\n#define HAVE_SIGNIFICAND\n#define significand __jq_significand\n#endif\n\n#endif // ifdef __APPLE__\n\n#define LIBM_DD(name) \\\nstatic jv f_ ## name(jq_state *jq, jv input) { \\\n  if (jv_get_kind(input) != JV_KIND_NUMBER) { \\\n    return type_error(input, \"number required\"); \\\n  } \\\n  jv ret = jv_number(name(jv_number_value(input))); \\\n  jv_free(input); \\\n  return ret; \\\n}\n#define LIBM_DD_NO(name) \\\nstatic jv f_ ## name(jq_state *jq, jv input) { \\\n  jv error = jv_string(\"Error: \" #name \"/0 not found at build time\"); \\\n  return ret_error(input, error); \\\n}\n\n#define LIBM_DDD(name) \\\nstatic jv f_ ## name(jq_state *jq, jv input, jv a, jv b) { \\\n  jv_free(input); \\\n  if (jv_get_kind(a) != JV_KIND_NUMBER) { \\\n    jv_free(b); \\\n    return type_error(a, \"number required\"); \\\n  } \\\n  if (jv_get_kind(b) != JV_KIND_NUMBER) { \\\n    jv_free(a); \\\n    return type_error(b, \"number required\"); \\\n  } \\\n  jv ret = jv_number(name(jv_number_value(a), jv_number_value(b))); \\\n  jv_free(a); \\\n  jv_free(b); \\\n  return ret; \\\n}\n#define LIBM_DDD_NO(name) \\\nstatic jv f_ ## name(jq_state *jq, jv input, jv a, jv b) { \\\n  jv_free(b); \\\n  jv error = jv_string(\"Error: \" #name \"/2 not found at build time\"); \\\n  return ret_error2(input, a, error); \\\n}\n\n#define LIBM_DDDD(name) \\\nstatic jv f_ ## name(jq_state *jq, jv input, jv a, jv b, jv c) { \\\n  jv_free(input); \\\n  if (jv_get_kind(a) != JV_KIND_NUMBER) { \\\n    jv_free(b); \\\n    jv_free(c); \\\n    return type_error(a, \"number required\"); \\\n  } \\\n  if (jv_get_kind(b) != JV_KIND_NUMBER) { \\\n    jv_free(a); \\\n    jv_free(c); \\\n    return type_error(b, \"number required\"); \\\n  } \\\n  if (jv_get_kind(c) != JV_KIND_NUMBER) { \\\n    jv_free(a); \\\n    jv_free(b); \\\n    return type_error(c, \"number required\"); \\\n  } \\\n  jv ret = jv_number(name(jv_number_value(a), jv_number_value(b), jv_number_value(c))); \\\n  jv_free(a); \\\n  jv_free(b); \\\n  jv_free(c); \\\n  return ret; \\\n}\n#define LIBM_DDDD_NO(name) \\\nstatic jv f_ ## name(jq_state *jq, jv input, jv a, jv b, jv c) { \\\n  jv_free(c); \\\n  jv_free(b); \\\n  jv error = jv_string(\"Error: \" #name \"/3 not found at build time\"); \\\n  return ret_error2(input, a, error); \\\n}\n\n#define LIBM_DA(name, type) \\\nstatic jv f_ ## name(jq_state *jq, jv input) { \\\n  if (jv_get_kind(input) != JV_KIND_NUMBER) { \\\n    return type_error(input, \"number required\"); \\\n  } \\\n  type value; \\\n  double d = name(jv_number_value(input), &value); \\\n  jv ret = JV_ARRAY(jv_number(d), jv_number(value)); \\\n  jv_free(input); \\\n  return ret; \\\n}\n#define LIBM_DA_NO(name, type) \\\nstatic jv f_ ## name(jq_state *jq, jv input) { \\\n  jv error = jv_string(\"Error: \" #name \"/0 not found at build time\"); \\\n  return ret_error(input, error); \\\n}\n\n#include \"libm.h\"\n#undef LIBM_DDDD_NO\n#undef LIBM_DDD_NO\n#undef LIBM_DD_NO\n#undef LIBM_DA_NO\n#undef LIBM_DDDD\n#undef LIBM_DDD\n#undef LIBM_DD\n#undef LIBM_DA\n\n#ifdef __APPLE__\n#undef gamma\n#undef drem\n#undef significand\n#undef exp10\n#endif\n\nstatic jv f_negate(jq_state *jq, jv input) {\n  if (jv_get_kind(input) != JV_KIND_NUMBER) {\n    return type_error(input, \"cannot be negated\");\n  }\n  jv ret = jv_number_negate(input);\n  jv_free(input);\n  return ret;\n}\n\nstatic jv f_startswith(jq_state *jq, jv a, jv b) {\n  if (jv_get_kind(a) != JV_KIND_STRING || jv_get_kind(b) != JV_KIND_STRING)\n    return ret_error2(a, b, jv_string(\"startswith() requires string inputs\"));\n  int alen = jv_string_length_bytes(jv_copy(a));\n  int blen = jv_string_length_bytes(jv_copy(b));\n  jv ret;\n\n  if (blen <= alen && memcmp(jv_string_value(a), jv_string_value(b), blen) == 0)\n    ret = jv_true();\n  else\n    ret = jv_false();\n  jv_free(a);\n  jv_free(b);\n  return ret;\n}\n\nstatic jv f_endswith(jq_state *jq, jv a, jv b) {\n  if (jv_get_kind(a) != JV_KIND_STRING || jv_get_kind(b) != JV_KIND_STRING)\n    return ret_error2(a, b, jv_string(\"endswith() requires string inputs\"));\n  const char *astr = jv_string_value(a);\n  const char *bstr = jv_string_value(b);\n  size_t alen = jv_string_length_bytes(jv_copy(a));\n  size_t blen = jv_string_length_bytes(jv_copy(b));\n  jv ret;\n\n  if (alen < blen ||\n     memcmp(astr + (alen - blen), bstr, blen) != 0)\n    ret = jv_false();\n  else\n    ret = jv_true();\n  jv_free(a);\n  jv_free(b);\n  return ret;\n}\n\njv binop_minus(jv a, jv b) {\n  if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {\n    jv r = jv_number(jv_number_value(a) - jv_number_value(b));\n    jv_free(a);\n    jv_free(b);\n    return r;\n  } else if (jv_get_kind(a) == JV_KIND_ARRAY && jv_get_kind(b) == JV_KIND_ARRAY) {\n    jv out = jv_array();\n    jv_array_foreach(a, i, x) {\n      int include = 1;\n      jv_array_foreach(b, j, y) {\n        if (jv_equal(jv_copy(x), y)) {\n          include = 0;\n          break;\n        }\n      }\n      if (include)\n        out = jv_array_append(out, jv_copy(x));\n      jv_free(x);\n    }\n    jv_free(a);\n    jv_free(b);\n    return out;\n  } else {\n    return type_error2(a, b, \"cannot be subtracted\");\n  }\n}\n\njv binop_multiply(jv a, jv b) {\n  jv_kind ak = jv_get_kind(a);\n  jv_kind bk = jv_get_kind(b);\n  if (ak == JV_KIND_NUMBER && bk == JV_KIND_NUMBER) {\n    jv r = jv_number(jv_number_value(a) * jv_number_value(b));\n    jv_free(a);\n    jv_free(b);\n    return r;\n  } else if ((ak == JV_KIND_STRING && bk == JV_KIND_NUMBER) ||\n             (ak == JV_KIND_NUMBER && bk == JV_KIND_STRING)) {\n    jv str = a;\n    jv num = b;\n    if (ak == JV_KIND_NUMBER) {\n      str = b;\n      num = a;\n    }\n    double d = jv_number_value(num);\n    jv_free(num);\n    return jv_string_repeat(str,\n        d < 0 || isnan(d) ? -1 : d > INT_MAX ? INT_MAX : (int)d);\n  } else if (ak == JV_KIND_OBJECT && bk == JV_KIND_OBJECT) {\n    return jv_object_merge_recursive(a, b);\n  } else {\n    return type_error2(a, b, \"cannot be multiplied\");\n  }\n}\n\njv binop_divide(jv a, jv b) {\n  if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {\n    if (jv_number_value(b) == 0.0)\n      return type_error2(a, b, \"cannot be divided because the divisor is zero\");\n    jv r = jv_number(jv_number_value(a) / jv_number_value(b));\n    jv_free(a);\n    jv_free(b);\n    return r;\n  } else if (jv_get_kind(a) == JV_KIND_STRING && jv_get_kind(b) == JV_KIND_STRING) {\n    return jv_string_split(a, b);\n  } else {\n    return type_error2(a, b, \"cannot be divided\");\n  }\n}\n\n#define dtoi(n) ((n) < INTMAX_MIN ? INTMAX_MIN : -(n) <= INTMAX_MIN ? INTMAX_MAX : (intmax_t)(n))\njv binop_mod(jv a, jv b) {\n  if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {\n    double na = jv_number_value(a);\n    double nb = jv_number_value(b);\n    if (isnan(na) || isnan(nb)) {\n      jv_free(a);\n      jv_free(b);\n      return jv_number(NAN);\n    }\n    intmax_t bi = dtoi(nb);\n    if (bi == 0)\n      return type_error2(a, b, \"cannot be divided (remainder) because the divisor is zero\");\n    // Check if the divisor is -1 to avoid overflow when the dividend is INTMAX_MIN.\n    jv r = jv_number(bi == -1 ? 0 : dtoi(na) % bi);\n    jv_free(a);\n    jv_free(b);\n    return r;\n  } else {\n    return type_error2(a, b, \"cannot be divided (remainder)\");\n  }\n}\n#undef dtoi\n\njv binop_equal(jv a, jv b) {\n  return jv_bool(jv_equal(a, b));\n}\n\njv binop_notequal(jv a, jv b) {\n  return jv_bool(!jv_equal(a, b));\n}\n\nenum cmp_op {\n  CMP_OP_LESS,\n  CMP_OP_GREATER,\n  CMP_OP_LESSEQ,\n  CMP_OP_GREATEREQ\n};\n\nstatic jv order_cmp(jv a, jv b, enum cmp_op op) {\n  int r = jv_cmp(a, b);\n  return jv_bool((op == CMP_OP_LESS && r < 0) ||\n                 (op == CMP_OP_LESSEQ && r <= 0) ||\n                 (op == CMP_OP_GREATEREQ && r >= 0) ||\n                 (op == CMP_OP_GREATER && r > 0));\n}\n\njv binop_less(jv a, jv b) {\n  return order_cmp(a, b, CMP_OP_LESS);\n}\n\njv binop_greater(jv a, jv b) {\n  return order_cmp(a, b, CMP_OP_GREATER);\n}\n\njv binop_lesseq(jv a, jv b) {\n  return order_cmp(a, b, CMP_OP_LESSEQ);\n}\n\njv binop_greatereq(jv a, jv b) {\n  return order_cmp(a, b, CMP_OP_GREATEREQ);\n}\n\nstatic jv f_contains(jq_state *jq, jv a, jv b) {\n  if (jv_get_kind(a) == jv_get_kind(b)) {\n    return jv_bool(jv_contains(a, b));\n  } else {\n    return type_error2(a, b, \"cannot have their containment checked\");\n  }\n}\n\nstatic jv f_dump(jq_state *jq, jv input) {\n  return jv_dump_string(input, 0);\n}\n\nstatic jv f_json_parse(jq_state *jq, jv input) {\n  if (jv_get_kind(input) != JV_KIND_STRING)\n    return type_error(input, \"only strings can be parsed\");\n  jv res = jv_parse_sized(jv_string_value(input),\n                          jv_string_length_bytes(jv_copy(input)));\n  jv_free(input);\n  return res;\n}\n\nstatic jv f_tonumber(jq_state *jq, jv input) {\n  if (jv_get_kind(input) == JV_KIND_NUMBER) {\n    return input;\n  }\n  if (jv_get_kind(input) == JV_KIND_STRING) {\n    const char* s = jv_string_value(input);\n    int len = jv_string_length_bytes(jv_copy(input));\n    if ((size_t)len != strlen(s)) {\n      return type_error(input, \"cannot be parsed as a number\");\n    }\n#ifdef USE_DECNUM\n    jv number = jv_number_with_literal(s);\n    if (jv_get_kind(number) == JV_KIND_INVALID) {\n      return type_error(input, \"cannot be parsed as a number\");\n    }\n#else\n    char *end = 0;\n    double d = jvp_strtod(tsd_dtoa_context_get(), s, &end);\n    if (end == 0 || *end != 0) {\n      return type_error(input, \"cannot be parsed as a number\");\n    }\n    jv number = jv_number(d);\n#endif\n    jv_free(input);\n    return number;\n  }\n  return type_error(input, \"cannot be parsed as a number\");\n}\n\nstatic jv f_toboolean(jq_state *jq, jv input) {\n  if (jv_get_kind(input) == JV_KIND_TRUE || jv_get_kind(input) == JV_KIND_FALSE) {\n    return input;\n  }\n  if (jv_get_kind(input) == JV_KIND_STRING) {\n    const char *s = jv_string_value(input);\n    int len = jv_string_length_bytes(jv_copy(input));\n    if ((size_t)len != strlen(s)) {\n      return type_error(input, \"cannot be parsed as a boolean\");\n    }\n    if (strcmp(s, \"true\") == 0) {\n      jv_free(input);\n      return jv_true();\n    } else if (strcmp(s, \"false\") == 0) {\n      jv_free(input);\n      return jv_false();\n    }\n  }\n  return type_error(input, \"cannot be parsed as a boolean\");\n}\n\nstatic jv f_length(jq_state *jq, jv input) {\n  if (jv_get_kind(input) == JV_KIND_ARRAY) {\n    return jv_number(jv_array_length(input));\n  } else if (jv_get_kind(input) == JV_KIND_OBJECT) {\n    return jv_number(jv_object_length(input));\n  } else if (jv_get_kind(input) == JV_KIND_STRING) {\n    return jv_number(jv_string_length_codepoints(input));\n  } else if (jv_get_kind(input) == JV_KIND_NUMBER) {\n    jv r = jv_number_abs(input);\n    jv_free(input);\n    return r;\n  } else if (jv_get_kind(input) == JV_KIND_NULL) {\n    jv_free(input);\n    return jv_number(0);\n  } else {\n    return type_error(input, \"has no length\");\n  }\n}\n\nstatic jv f_tostring(jq_state *jq, jv input) {\n  if (jv_get_kind(input) == JV_KIND_STRING) {\n    return input;\n  } else {\n    return jv_dump_string(input, 0);\n  }\n}\n\nstatic jv f_utf8bytelength(jq_state *jq, jv input) {\n  if (jv_get_kind(input) != JV_KIND_STRING)\n    return type_error(input, \"only strings have UTF-8 byte length\");\n  return jv_number(jv_string_length_bytes(input));\n}\n\nstatic const unsigned char URI_UNRESERVED[128] = {\n  // 1  2  3  4  5  6  7  8  9  A  B  C  D  E  F\n  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00\n  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10\n  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, // 0x20: - .\n  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 0x30: 0-9\n  0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40: A-O\n  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50: P-Z _\n  0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60: a-o\n  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, // 0x70: p-z ~\n};\n\n#define CHARS_ALPHANUM \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\"\n\nstatic const unsigned char BASE64_ENCODE_TABLE[64 + 1] = CHARS_ALPHANUM \"+/\";\nstatic const unsigned char BASE64_INVALID_ENTRY = 0xFF;\nstatic const unsigned char BASE64_DECODE_TABLE[255] = {\n  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,\n  62, // +\n  0xFF, 0xFF, 0xFF,\n  63, // /\n  52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // 0-9\n  0xFF, 0xFF, 0xFF,\n  99, // =\n  0xFF, 0xFF, 0xFF,\n  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // A-Z\n  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,\n  26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,  // a-z\n  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF\n};\n\n\nstatic jv escape_string(jv input, const char* escapings) {\n\n  assert(jv_get_kind(input) == JV_KIND_STRING);\n  const char* lookup[128] = {0};\n  const char* p = escapings;\n  lookup[0] = \"\\\\0\";\n  while (*p) {\n    lookup[(int)*p] = p+1;\n    p++;\n    p += strlen(p);\n    p++;\n  }\n\n  jv ret = jv_string(\"\");\n  const char* i = jv_string_value(input);\n  const char* end = i + jv_string_length_bytes(jv_copy(input));\n  const char* cstart;\n  int c = 0;\n  while ((i = jvp_utf8_next((cstart = i), end, &c))) {\n    if (c < 128 && lookup[c]) {\n      ret = jv_string_append_str(ret, lookup[c]);\n    } else {\n      ret = jv_string_append_buf(ret, cstart, i - cstart);\n    }\n  }\n  jv_free(input);\n  return ret;\n\n}\n\nstatic jv f_format(jq_state *jq, jv input, jv fmt) {\n  if (jv_get_kind(fmt) != JV_KIND_STRING) {\n    jv_free(input);\n    return type_error(fmt, \"is not a valid format\");\n  }\n  const char* fmt_s = jv_string_value(fmt);\n  if (!strcmp(fmt_s, \"json\")) {\n    jv_free(fmt);\n    return jv_dump_string(input, 0);\n  } else if (!strcmp(fmt_s, \"text\")) {\n    jv_free(fmt);\n    return f_tostring(jq, input);\n  } else if (!strcmp(fmt_s, \"csv\") || !strcmp(fmt_s, \"tsv\")) {\n    const char *quotes, *sep, *escapings;\n    const char *msg;\n    if (!strcmp(fmt_s, \"csv\")) {\n      msg = \"cannot be csv-formatted, only array\";\n      quotes = \"\\\"\";\n      sep = \",\";\n      escapings = \"\\\"\\\"\\\"\\0\";\n    } else {\n      msg = \"cannot be tsv-formatted, only array\";\n      assert(!strcmp(fmt_s, \"tsv\"));\n      quotes = \"\";\n      sep = \"\\t\";\n      escapings = \"\\t\\\\t\\0\\r\\\\r\\0\\n\\\\n\\0\\\\\\\\\\\\\\0\";\n    }\n    jv_free(fmt);\n    if (jv_get_kind(input) != JV_KIND_ARRAY)\n      return type_error(input, msg);\n    jv line = jv_string(\"\");\n    jv_array_foreach(input, i, x) {\n      if (i) line = jv_string_append_str(line, sep);\n      switch (jv_get_kind(x)) {\n      case JV_KIND_NULL:\n        /* null rendered as empty string */\n        jv_free(x);\n        break;\n      case JV_KIND_TRUE:\n      case JV_KIND_FALSE:\n        line = jv_string_concat(line, jv_dump_string(x, 0));\n        break;\n      case JV_KIND_NUMBER:\n        if (jv_number_value(x) != jv_number_value(x)) {\n          /* NaN, render as empty string */\n          jv_free(x);\n        } else {\n          line = jv_string_concat(line, jv_dump_string(x, 0));\n        }\n        break;\n      case JV_KIND_STRING: {\n        line = jv_string_append_str(line, quotes);\n        line = jv_string_concat(line, escape_string(x, escapings));\n        line = jv_string_append_str(line, quotes);\n        break;\n      }\n      default:\n        jv_free(input);\n        jv_free(line);\n        return type_error(x, \"is not valid in a csv row\");\n      }\n    }\n    jv_free(input);\n    return line;\n  } else if (!strcmp(fmt_s, \"html\")) {\n    jv_free(fmt);\n    return escape_string(f_tostring(jq, input), \"&&amp;\\0<&lt;\\0>&gt;\\0'&apos;\\0\\\"&quot;\\0\");\n  } else if (!strcmp(fmt_s, \"uri\")) {\n    jv_free(fmt);\n    input = f_tostring(jq, input);\n    const char* s = jv_string_value(input);\n    int len = jv_string_length_bytes(jv_copy(input));\n    char *result = jv_mem_alloc((size_t)len * 3 + 1);\n    uint32_t ri = 0;\n    for (int i = 0; i < len; i++) {\n      unsigned c = (unsigned)(unsigned char)s[i];\n      if (c < 128 && URI_UNRESERVED[c]) {\n        result[ri++] = (char)c;\n      } else {\n        result[ri++] = '%';\n        result[ri++] = \"0123456789ABCDEF\"[c >> 4];\n        result[ri++] = \"0123456789ABCDEF\"[c & 0x0F];\n      }\n    }\n    jv line = jv_string_sized(result, ri);\n    free(result);\n    jv_free(input);\n    return line;\n  } else if (!strcmp(fmt_s, \"urid\")) {\n    jv_free(fmt);\n    input = f_tostring(jq, input);\n    const char *errmsg = \"is not a valid uri encoding\";\n    const char *s = jv_string_value(input);\n    int len = jv_string_length_bytes(jv_copy(input));\n    char *result = jv_mem_alloc((size_t)len + 1);\n    uint32_t ri = 0;\n    for (int i = 0; i < len; i++) {\n      char c = s[i];\n      if (c != '%') {\n        result[ri++] = c;\n      } else {\n        int hi = 0, lo = 0;\n        for (int j = 0; j < 2; j++) {\n          if (++i >= len) {\n            free(result);\n            return type_error(input, errmsg);\n          }\n          int *d = j == 0 ? &hi : &lo;\n          c = s[i];\n          if ('0' <= c && c <= '9') *d = c - '0';\n          else if ('a' <= c && c <= 'f') *d = c - 'a' + 10;\n          else if ('A' <= c && c <= 'F') *d = c - 'A' + 10;\n          else {\n            free(result);\n            return type_error(input, errmsg);\n          }\n        }\n        result[ri++] = (hi << 4) | lo;\n      }\n    }\n    if (!jvp_utf8_is_valid(result, result + ri)) {\n      free(result);\n      return type_error(input, errmsg);\n    }\n    jv line = jv_string_sized(result, ri);\n    free(result);\n    jv_free(input);\n    return line;\n  } else if (!strcmp(fmt_s, \"sh\")) {\n    jv_free(fmt);\n    if (jv_get_kind(input) != JV_KIND_ARRAY)\n      input = jv_array_set(jv_array(), 0, input);\n    jv line = jv_string(\"\");\n    jv_array_foreach(input, i, x) {\n      if (i) line = jv_string_append_str(line, \" \");\n      switch (jv_get_kind(x)) {\n      case JV_KIND_NULL:\n      case JV_KIND_TRUE:\n      case JV_KIND_FALSE:\n      case JV_KIND_NUMBER:\n        line = jv_string_concat(line, jv_dump_string(x, 0));\n        break;\n\n      case JV_KIND_STRING: {\n        line = jv_string_append_str(line, \"'\");\n        line = jv_string_concat(line, escape_string(x, \"''\\\\''\\0\"));\n        line = jv_string_append_str(line, \"'\");\n        break;\n      }\n\n      default:\n        jv_free(input);\n        jv_free(line);\n        return type_error(x, \"can not be escaped for shell\");\n      }\n    }\n    jv_free(input);\n    return line;\n  } else if (!strcmp(fmt_s, \"base64\")) {\n    jv_free(fmt);\n    input = f_tostring(jq, input);\n    jv line = jv_string(\"\");\n    const unsigned char* data = (const unsigned char*)jv_string_value(input);\n    int len = jv_string_length_bytes(jv_copy(input));\n    for (int i=0; i<len; i+=3) {\n      uint32_t code = 0;\n      int n = len - i >= 3 ? 3 : len-i;\n      for (int j=0; j<3; j++) {\n        code <<= 8;\n        code |= j < n ? (unsigned)data[i+j] : 0;\n      }\n      char buf[4];\n      for (int j=0; j<4; j++) {\n        buf[j] = BASE64_ENCODE_TABLE[(code >> (18 - j*6)) & 0x3f];\n      }\n      if (n < 3) buf[3] = '=';\n      if (n < 2) buf[2] = '=';\n      line = jv_string_append_buf(line, buf, sizeof(buf));\n    }\n    jv_free(input);\n    return line;\n  } else if (!strcmp(fmt_s, \"base64d\")) {\n    jv_free(fmt);\n    input = f_tostring(jq, input);\n    const unsigned char* data = (const unsigned char*)jv_string_value(input);\n    int len = jv_string_length_bytes(jv_copy(input));\n    size_t decoded_len = MAX((3 * (size_t)len) / 4, (size_t)1); // 3 usable bytes for every 4 bytes of input\n    char *result = jv_mem_calloc(decoded_len, sizeof(char));\n    uint32_t ri = 0;\n    int input_bytes_read=0;\n    uint32_t code = 0;\n    for (int i=0; i<len && data[i] != '='; i++) {\n      if (BASE64_DECODE_TABLE[data[i]] == BASE64_INVALID_ENTRY) {\n        free(result);\n        return type_error(input, \"is not valid base64 data\");\n      }\n\n      code <<= 6;\n      code |= BASE64_DECODE_TABLE[data[i]];\n      input_bytes_read++;\n\n      if (input_bytes_read == 4) {\n        result[ri++] = (code >> 16) & 0xFF;\n        result[ri++] = (code >> 8) & 0xFF;\n        result[ri++] = code & 0xFF;\n        input_bytes_read = 0;\n        code = 0;\n      }\n    }\n    if (input_bytes_read == 3) {\n      result[ri++] = (code >> 10) & 0xFF;\n      result[ri++] = (code >> 2) & 0xFF;\n    } else if (input_bytes_read == 2) {\n      result[ri++] = (code >> 4) & 0xFF;\n    } else if (input_bytes_read == 1) {\n      free(result);\n      return type_error(input, \"trailing base64 byte found\");\n    }\n\n    jv line = jv_string_sized(result, ri);\n    jv_free(input);\n    free(result);\n    return line;\n  } else {\n    jv_free(input);\n    return jv_invalid_with_msg(jv_string_concat(fmt, jv_string(\" is not a valid format\")));\n  }\n}\n\nstatic jv f_keys(jq_state *jq, jv input) {\n  if (jv_get_kind(input) == JV_KIND_OBJECT || jv_get_kind(input) == JV_KIND_ARRAY) {\n    return jv_keys(input);\n  } else {\n    return type_error(input, \"has no keys\");\n  }\n}\n\nstatic jv f_keys_unsorted(jq_state *jq, jv input) {\n  if (jv_get_kind(input) == JV_KIND_OBJECT || jv_get_kind(input) == JV_KIND_ARRAY) {\n    return jv_keys_unsorted(input);\n  } else {\n    return type_error(input, \"has no keys\");\n  }\n}\n\nstatic jv f_sort(jq_state *jq, jv input){\n  if (jv_get_kind(input) == JV_KIND_ARRAY) {\n    return jv_sort(input, jv_copy(input));\n  } else {\n    return type_error(input, \"cannot be sorted, as it is not an array\");\n  }\n}\n\nstatic jv f_sort_by_impl(jq_state *jq, jv input, jv keys) {\n  if (jv_get_kind(input) == JV_KIND_ARRAY &&\n      jv_get_kind(keys) == JV_KIND_ARRAY &&\n      jv_array_length(jv_copy(input)) == jv_array_length(jv_copy(keys))) {\n    return jv_sort(input, keys);\n  } else {\n    return type_error2(input, keys, \"cannot be sorted, as they are not both arrays\");\n  }\n}\n\n/*\n * Assuming the input array is sorted, bsearch/1 returns\n * the index of the target if the target is in the input array; and otherwise\n * (-1 - ix), where ix is the insertion point that would leave the array sorted.\n * If the input is not sorted, bsearch will terminate but with irrelevant results.\n */\nstatic jv f_bsearch(jq_state *jq, jv input, jv target) {\n  if (jv_get_kind(input) != JV_KIND_ARRAY) {\n    jv_free(target);\n    return type_error(input, \"cannot be searched from\");\n  }\n  int start = 0;\n  int end = jv_array_length(jv_copy(input));\n  jv answer = jv_invalid();\n  while (start < end) {\n    int mid = start + (end - start) / 2;\n    int result = jv_cmp(jv_copy(target), jv_array_get(jv_copy(input), mid));\n    if (result == 0) {\n      answer = jv_number(mid);\n      break;\n    } else if (result < 0) {\n      end = mid;\n    } else {\n      start = mid + 1;\n    }\n  }\n  if (!jv_is_valid(answer)) {\n    answer = jv_number(-1 - start);\n  }\n  jv_free(input);\n  jv_free(target);\n  return answer;\n}\n\nstatic jv f_group_by_impl(jq_state *jq, jv input, jv keys) {\n  if (jv_get_kind(input) == JV_KIND_ARRAY &&\n      jv_get_kind(keys) == JV_KIND_ARRAY &&\n      jv_array_length(jv_copy(input)) == jv_array_length(jv_copy(keys))) {\n    return jv_group(input, keys);\n  } else {\n    return type_error2(input, keys, \"cannot be sorted, as they are not both arrays\");\n  }\n}\n\nstatic jv f_unique(jq_state *jq, jv input) {\n  if (jv_get_kind(input) == JV_KIND_ARRAY) {\n    return jv_unique(input, jv_copy(input));\n  } else {\n    return type_error(input, \"cannot be sorted, as it is not an array\");\n  }\n}\n\nstatic jv f_unique_by_impl(jq_state *jq, jv input, jv keys) {\n  if (jv_get_kind(input) == JV_KIND_ARRAY &&\n      jv_get_kind(keys) == JV_KIND_ARRAY &&\n      jv_array_length(jv_copy(input)) == jv_array_length(jv_copy(keys))) {\n    return jv_unique(input, keys);\n  } else {\n    return type_error2(input, keys, \"cannot be sorted, as they are not both arrays\");\n  }\n}\n\n#ifdef HAVE_LIBONIG\nstatic int f_match_name_iter(const UChar* name, const UChar *name_end, int ngroups,\n    int *groups, regex_t *reg, void *arg) {\n  jv captures = *(jv*)arg;\n  for (int i = 0; i < ngroups; ++i) {\n    jv cap = jv_array_get(jv_copy(captures),groups[i]-1);\n    if (jv_get_kind(cap) == JV_KIND_OBJECT) {\n      cap = jv_object_set(cap, jv_string(\"name\"), jv_string_sized((const char*)name, name_end-name));\n      captures = jv_array_set(captures,groups[i]-1,cap);\n    } else {\n      jv_free(cap);\n    }\n  }\n  *(jv *)arg = captures;\n  return 0;\n}\n\nstatic jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) {\n  int test = jv_equal(testmode, jv_true());\n  jv result;\n  int onigret;\n  int global = 0;\n  regex_t *reg;\n  OnigErrorInfo einfo;\n  OnigRegion* region;\n\n  if (jv_get_kind(input) != JV_KIND_STRING) {\n    jv_free(regex);\n    jv_free(modifiers);\n    return type_error(input, \"cannot be matched, as it is not a string\");\n  }\n\n  if (jv_get_kind(regex) != JV_KIND_STRING) {\n    jv_free(input);\n    jv_free(modifiers);\n    return type_error(regex, \"is not a string\");\n  }\n\n  OnigOptionType options = ONIG_OPTION_CAPTURE_GROUP;\n\n  if (jv_get_kind(modifiers) == JV_KIND_STRING) {\n    jv modarray = jv_string_explode(jv_copy(modifiers));\n    jv_array_foreach(modarray, i, mod) {\n      switch ((int)jv_number_value(mod)) {\n        case 'g':\n          global = 1;\n          break;\n        case 'i':\n          options |= ONIG_OPTION_IGNORECASE;\n          break;\n        case 'x':\n          options |= ONIG_OPTION_EXTEND;\n          break;\n        case 'm':\n          options |= ONIG_OPTION_MULTILINE;\n          break;\n        case 's':\n          options |= ONIG_OPTION_SINGLELINE;\n          break;\n        case 'p':\n          options |= ONIG_OPTION_MULTILINE | ONIG_OPTION_SINGLELINE;\n          break;\n        case 'l':\n          options |= ONIG_OPTION_FIND_LONGEST;\n          break;\n        case 'n':\n          options |= ONIG_OPTION_FIND_NOT_EMPTY;\n          break;\n        default:\n          jv_free(input);\n          jv_free(regex);\n          jv_free(modarray);\n          return jv_invalid_with_msg(jv_string_concat(modifiers,\n                jv_string(\" is not a valid modifier string\")));\n      }\n    }\n    jv_free(modarray);\n  } else if (jv_get_kind(modifiers) != JV_KIND_NULL) {\n    // If it isn't a string or null, then it is the wrong type...\n    jv_free(input);\n    jv_free(regex);\n    return type_error(modifiers, \"is not a string\");\n  }\n\n  jv_free(modifiers);\n\n  onigret = onig_new(&reg, (const UChar*)jv_string_value(regex),\n      (const UChar*)(jv_string_value(regex) + jv_string_length_bytes(jv_copy(regex))),\n      options, ONIG_ENCODING_UTF8, ONIG_SYNTAX_PERL_NG, &einfo);\n  if (onigret != ONIG_NORMAL) {\n    UChar ebuf[ONIG_MAX_ERROR_MESSAGE_LEN];\n    onig_error_code_to_str(ebuf, onigret, &einfo);\n    jv_free(input);\n    jv_free(regex);\n    return jv_invalid_with_msg(jv_string_concat(jv_string(\"Regex failure: \"),\n          jv_string((char*)ebuf)));\n  }\n  result = test ? jv_false() : jv_array();\n  const char *input_string = jv_string_value(input);\n  const UChar* start = (const UChar*)jv_string_value(input);\n  const unsigned long length = jv_string_length_bytes(jv_copy(input));\n  const UChar* end = start + length;\n  region = onig_region_new();\n  do {\n    onigret = onig_search(reg,\n        (const UChar*)jv_string_value(input), end, /* string boundaries */\n        start, end, /* search boundaries */\n        region, ONIG_OPTION_NONE);\n    if (onigret >= 0) {\n      if (test) {\n        result = jv_true();\n        break;\n      }\n\n      // Zero-width match\n      if (region->end[0] == region->beg[0]) {\n        unsigned long idx;\n        const char *fr = (const char*)input_string;\n        for (idx = 0; fr < input_string+region->beg[0]; idx++) {\n          fr += jvp_utf8_decode_length(*fr);\n        }\n        jv match = jv_object_set(jv_object(), jv_string(\"offset\"), jv_number(idx));\n        match = jv_object_set(match, jv_string(\"length\"), jv_number(0));\n        match = jv_object_set(match, jv_string(\"string\"), jv_string(\"\"));\n        jv captures = jv_array();\n        for (int i = 1; i < region->num_regs; ++i) {\n          jv cap = jv_object();\n          if (region->beg[i] == -1) {\n            cap = jv_object_set(cap, jv_string(\"offset\"), jv_number(-1));\n            cap = jv_object_set(cap, jv_string(\"string\"), jv_null());\n          } else {\n            cap = jv_object_set(cap, jv_string(\"offset\"), jv_number(idx));\n            cap = jv_object_set(cap, jv_string(\"string\"), jv_string(\"\"));\n          }\n          cap = jv_object_set(cap, jv_string(\"length\"), jv_number(0));\n          cap = jv_object_set(cap, jv_string(\"name\"), jv_null());\n          captures = jv_array_append(captures, cap);\n        }\n        onig_foreach_name(reg, f_match_name_iter, &captures);\n        match = jv_object_set(match, jv_string(\"captures\"), captures);\n        result = jv_array_append(result, match);\n        // ensure '\"qux\" | match(\"(?=u)\"; \"g\")' matches just once\n        start = (const UChar*)(input_string+region->end[0]+1);\n        continue;\n      }\n\n      unsigned long idx;\n      unsigned long len;\n      const char *fr = (const char*)input_string;\n\n      for (idx = len = 0; fr < input_string+region->end[0]; len++) {\n        if (fr == input_string+region->beg[0]) idx = len, len=0;\n        fr += jvp_utf8_decode_length(*fr);\n      }\n\n      jv match = jv_object_set(jv_object(), jv_string(\"offset\"), jv_number(idx));\n\n      unsigned long blen = region->end[0]-region->beg[0];\n      match = jv_object_set(match, jv_string(\"length\"), jv_number(len));\n      match = jv_object_set(match, jv_string(\"string\"), jv_string_sized(input_string+region->beg[0],blen));\n      jv captures = jv_array();\n      for (int i = 1; i < region->num_regs; ++i) {\n        // Empty capture.\n        if (region->beg[i] == region->end[i]) {\n          // Didn't match.\n          jv cap;\n          if (region->beg[i] == -1) {\n            cap = jv_object_set(jv_object(), jv_string(\"offset\"), jv_number(-1));\n            cap = jv_object_set(cap, jv_string(\"string\"), jv_null());\n          } else {\n            fr = input_string;\n            for (idx = 0; fr < input_string+region->beg[i]; idx++) {\n              fr += jvp_utf8_decode_length(*fr);\n            }\n            cap = jv_object_set(jv_object(), jv_string(\"offset\"), jv_number(idx));\n            cap = jv_object_set(cap, jv_string(\"string\"), jv_string(\"\"));\n          }\n          cap = jv_object_set(cap, jv_string(\"length\"), jv_number(0));\n          cap = jv_object_set(cap, jv_string(\"name\"), jv_null());\n          captures = jv_array_append(captures, cap);\n          continue;\n        }\n        fr = input_string;\n        for (idx = len = 0; fr < input_string+region->end[i]; len++) {\n          if (fr == input_string+region->beg[i]) idx = len, len=0;\n          fr += jvp_utf8_decode_length(*fr);\n        }\n\n        blen = region->end[i]-region->beg[i];\n        jv cap = jv_object_set(jv_object(), jv_string(\"offset\"), jv_number(idx));\n        cap = jv_object_set(cap, jv_string(\"length\"), jv_number(len));\n        cap = jv_object_set(cap, jv_string(\"string\"), jv_string_sized(input_string+region->beg[i],blen));\n        cap = jv_object_set(cap, jv_string(\"name\"), jv_null());\n        captures = jv_array_append(captures,cap);\n      }\n      onig_foreach_name(reg,f_match_name_iter,&captures);\n      match = jv_object_set(match, jv_string(\"captures\"), captures);\n      result = jv_array_append(result, match);\n      start = (const UChar*)(input_string+region->end[0]);\n      onig_region_free(region,0);\n    } else if (onigret == ONIG_MISMATCH) {\n      break;\n    } else { /* Error */\n      UChar ebuf[ONIG_MAX_ERROR_MESSAGE_LEN];\n      onig_error_code_to_str(ebuf, onigret, &einfo);\n      jv_free(result);\n      result = jv_invalid_with_msg(jv_string_concat(jv_string(\"Regex failure: \"),\n            jv_string((char*)ebuf)));\n      break;\n    }\n  } while (global && start <= end);\n  onig_region_free(region,1);\n  region = NULL;\n  onig_free(reg);\n  jv_free(input);\n  jv_free(regex);\n  return result;\n}\n#else /* !HAVE_LIBONIG */\nstatic jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) {\n  jv_free(input);\n  jv_free(regex);\n  jv_free(modifiers);\n  jv_free(testmode);\n  return jv_invalid_with_msg(jv_string(\"jq was compiled without ONIGURUMA regex library. match/test/sub and related functions are not available.\"));\n}\n#endif /* HAVE_LIBONIG */\n\nstatic jv minmax_by(jv values, jv keys, int is_min) {\n  if (jv_get_kind(values) != JV_KIND_ARRAY)\n    return type_error2(values, keys, \"cannot be iterated over\");\n  if (jv_get_kind(keys) != JV_KIND_ARRAY)\n    return type_error2(values, keys, \"cannot be iterated over\");\n  if (jv_array_length(jv_copy(values)) != jv_array_length(jv_copy(keys)))\n    return type_error2(values, keys, \"have wrong length\");\n\n  if (jv_array_length(jv_copy(values)) == 0) {\n    jv_free(values);\n    jv_free(keys);\n    return jv_null();\n  }\n  jv ret = jv_array_get(jv_copy(values), 0);\n  jv retkey = jv_array_get(jv_copy(keys), 0);\n  for (int i=1; i<jv_array_length(jv_copy(values)); i++) {\n    jv item = jv_array_get(jv_copy(keys), i);\n    int cmp = jv_cmp(jv_copy(item), jv_copy(retkey));\n    if ((cmp < 0) == (is_min == 1)) {\n      jv_free(retkey);\n      retkey = item;\n      jv_free(ret);\n      ret = jv_array_get(jv_copy(values), i);\n    } else {\n      jv_free(item);\n    }\n  }\n  jv_free(values);\n  jv_free(keys);\n  jv_free(retkey);\n  return ret;\n}\n\nstatic jv f_min(jq_state *jq, jv x) {\n  return minmax_by(x, jv_copy(x), 1);\n}\n\nstatic jv f_max(jq_state *jq, jv x) {\n  return minmax_by(x, jv_copy(x), 0);\n}\n\nstatic jv f_min_by_impl(jq_state *jq, jv x, jv y) {\n  return minmax_by(x, y, 1);\n}\n\nstatic jv f_max_by_impl(jq_state *jq, jv x, jv y) {\n  return minmax_by(x, y, 0);\n}\n\n\nstatic jv f_type(jq_state *jq, jv input) {\n  jv out = jv_string(jv_kind_name(jv_get_kind(input)));\n  jv_free(input);\n  return out;\n}\n\nstatic jv f_isinfinite(jq_state *jq, jv input) {\n  jv_kind k = jv_get_kind(input);\n  if (k != JV_KIND_NUMBER) {\n    jv_free(input);\n    return jv_false();\n  }\n  double n = jv_number_value(input);\n  jv_free(input);\n  return isinf(n) ? jv_true() : jv_false();\n}\n\nstatic jv f_isnan(jq_state *jq, jv input) {\n  jv_kind k = jv_get_kind(input);\n  if (k != JV_KIND_NUMBER) {\n    jv_free(input);\n    return jv_false();\n  }\n  double n = jv_number_value(input);\n  jv_free(input);\n  return isnan(n) ? jv_true() : jv_false();\n}\n\nstatic jv f_isnormal(jq_state *jq, jv input) {\n  jv_kind k = jv_get_kind(input);\n  if (k != JV_KIND_NUMBER) {\n    jv_free(input);\n    return jv_false();\n  }\n  double n = jv_number_value(input);\n  jv_free(input);\n  return isnormal(n) ? jv_true() : jv_false();\n}\n\nstatic jv f_infinite(jq_state *jq, jv input) {\n  jv_free(input);\n  return jv_number(INFINITY);\n}\n\nstatic jv f_nan(jq_state *jq, jv input) {\n  jv_free(input);\n  return jv_number(NAN);\n}\n\nstatic jv f_error(jq_state *jq, jv input) {\n  return jv_invalid_with_msg(input);\n}\n\n// FIXME Should autoconf check for this!\n#ifndef WIN32\nextern char **environ;\n#endif\n\nstatic jv f_env(jq_state *jq, jv input) {\n  jv_free(input);\n  jv env = jv_object();\n  const char *var, *val;\n  for (char **e = environ; *e != NULL; e++) {\n    var = e[0];\n    val = strchr(e[0], '=');\n    if (val == NULL)\n      env = jv_object_set(env, jv_string(var), jv_null());\n    else if (val - var < INT_MAX)\n      env = jv_object_set(env, jv_string_sized(var, val - var), jv_string(val + 1));\n  }\n  return env;\n}\n\nstatic jv f_halt(jq_state *jq, jv input) {\n  jv_free(input);\n  jq_halt(jq, jv_invalid(), jv_invalid());\n  return jv_true();\n}\n\nstatic jv f_halt_error(jq_state *jq, jv input, jv a) {\n  if (jv_get_kind(a) != JV_KIND_NUMBER) {\n    jv_free(a);\n    return type_error(input, \"halt_error/1: number required\");\n  }\n  jq_halt(jq, a, input);\n  return jv_true();\n}\n\nstatic jv f_get_search_list(jq_state *jq, jv input) {\n  jv_free(input);\n  return jq_get_lib_dirs(jq);\n}\n\nstatic jv f_get_prog_origin(jq_state *jq, jv input) {\n  jv_free(input);\n  return jq_get_prog_origin(jq);\n}\n\nstatic jv f_get_jq_origin(jq_state *jq, jv input) {\n  jv_free(input);\n  return jq_get_jq_origin(jq);\n}\n\nstatic jv f_string_split(jq_state *jq, jv a, jv b) {\n  if (jv_get_kind(a) != JV_KIND_STRING || jv_get_kind(b) != JV_KIND_STRING) {\n    return ret_error2(a, b, jv_string(\"split input and separator must be strings\"));\n  }\n  return jv_string_split(a, b);\n}\n\nstatic jv f_string_explode(jq_state *jq, jv a) {\n  if (jv_get_kind(a) != JV_KIND_STRING) {\n    return ret_error(a, jv_string(\"explode input must be a string\"));\n  }\n  return jv_string_explode(a);\n}\n\nstatic jv f_string_indexes(jq_state *jq, jv a, jv b) {\n  return jv_string_indexes(a, b);\n}\n\nenum trim_op {\n  TRIM_LEFT  = 1 << 0,\n  TRIM_RIGHT = 1 << 1\n};\n\nstatic jv string_trim(jv a, int op) {\n  if (jv_get_kind(a) != JV_KIND_STRING) {\n    return ret_error(a, jv_string(\"trim input must be a string\"));\n  }\n\n  int len = jv_string_length_bytes(jv_copy(a));\n  const char *start = jv_string_value(a);\n  const char *trim_start = start;\n  const char *end = trim_start + len;\n  const char *trim_end = end;\n  int c;\n\n  if (op & TRIM_LEFT) {\n    for (;;) {\n      const char *ns = jvp_utf8_next(trim_start, end, &c);\n      if (!ns || !jvp_codepoint_is_whitespace(c))\n        break;\n      trim_start = ns;\n    }\n  }\n\n  // make sure not empty string or start trim has trimmed everything\n  if ((op & TRIM_RIGHT) && trim_end > trim_start) {\n    for (;;) {\n      const char *ns = jvp_utf8_backtrack(trim_end-1, trim_start, NULL);\n      jvp_utf8_next(ns, trim_end, &c);\n      if (!jvp_codepoint_is_whitespace(c))\n        break;\n      trim_end = ns;\n      if (ns == trim_start)\n        break;\n    }\n  }\n\n  // no new string needed if there is nothing to trim\n  if (trim_start == start && trim_end == end)\n    return a;\n\n  jv ts = jv_string_sized(trim_start, trim_end - trim_start);\n  jv_free(a);\n  return ts;\n}\n\nstatic jv f_string_trim(jq_state *jq, jv a)  { return string_trim(a, TRIM_LEFT | TRIM_RIGHT); }\nstatic jv f_string_ltrim(jq_state *jq, jv a) { return string_trim(a, TRIM_LEFT); }\nstatic jv f_string_rtrim(jq_state *jq, jv a) { return string_trim(a, TRIM_RIGHT); }\n\nstatic jv f_string_implode(jq_state *jq, jv a) {\n  if (jv_get_kind(a) != JV_KIND_ARRAY) {\n    return ret_error(a, jv_string(\"implode input must be an array\"));\n  }\n\n  int len = jv_array_length(jv_copy(a));\n  jv s = jv_string_empty(len);\n\n  for (int i = 0; i < len; i++) {\n    jv n = jv_array_get(jv_copy(a), i);\n    if (jv_get_kind(n) != JV_KIND_NUMBER || jvp_number_is_nan(n)) {\n      jv_free(a);\n      jv_free(s);\n      return type_error(n, \"can't be imploded, unicode codepoint needs to be numeric\");\n    }\n\n    int nv = jv_number_value(n);\n    jv_free(n);\n    // outside codepoint range or in utf16 surrogate pair range\n    if (nv < 0 || nv > 0x10FFFF || (nv >= 0xD800 && nv <= 0xDFFF))\n      nv = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER\n    s = jv_string_append_codepoint(s, nv);\n  }\n\n  jv_free(a);\n  return s;\n}\n\nstatic jv f_setpath(jq_state *jq, jv a, jv b, jv c) { return jv_setpath(a, b, c); }\nextern jv _jq_path_append(jq_state *, jv, jv, jv);\nstatic jv f_getpath(jq_state *jq, jv a, jv b) {\n  return _jq_path_append(jq, a, b, jv_getpath(jv_copy(a), jv_copy(b)));\n}\nstatic jv f_delpaths(jq_state *jq, jv a, jv b) { return jv_delpaths(a, b); }\nstatic jv f_has(jq_state *jq, jv a, jv b) { return jv_has(a, b); }\n\nstatic jv f_modulemeta(jq_state *jq, jv a) {\n  if (jv_get_kind(a) != JV_KIND_STRING) {\n    return ret_error(a, jv_string(\"modulemeta input module name must be a string\"));\n  }\n  return load_module_meta(jq, a);\n}\n\nstatic jv f_input(jq_state *jq, jv input) {\n  jv_free(input);\n  jq_input_cb cb;\n  void *data;\n  jq_get_input_cb(jq, &cb, &data);\n  if (cb == NULL)\n    return jv_invalid_with_msg(jv_string(\"break\"));\n  jv v = cb(jq, data);\n  if (jv_is_valid(v) || jv_invalid_has_msg(jv_copy(v)))\n    return v;\n  return jv_invalid_with_msg(jv_string(\"break\"));\n}\n\nstatic jv f_debug(jq_state *jq, jv input) {\n  jq_msg_cb cb;\n  void *data;\n  jq_get_debug_cb(jq, &cb, &data);\n  if (cb != NULL)\n    cb(data, jv_copy(input));\n  return input;\n}\n\nstatic jv f_stderr(jq_state *jq, jv input) {\n  jq_msg_cb cb;\n  void *data;\n  jq_get_stderr_cb(jq, &cb, &data);\n  if (cb != NULL)\n    cb(data, jv_copy(input));\n  return input;\n}\n\nstatic jv tm2jv(struct tm *tm, double fsecs) {\n  return JV_ARRAY(jv_number(tm->tm_year + 1900),\n                  jv_number(tm->tm_mon),\n                  jv_number(tm->tm_mday),\n                  jv_number(tm->tm_hour),\n                  jv_number(tm->tm_min),\n                  jv_number(tm->tm_sec + (fsecs - floor(fsecs))),\n                  jv_number(tm->tm_wday),\n                  jv_number(tm->tm_yday));\n}\n\n#if defined(WIN32) && !defined(HAVE_SETENV)\nstatic int setenv(const char *var, const char *val, int ovr)\n{\n  BOOL b;\n  char c[2];\n  if (!ovr)\n  {\n    DWORD d;\n    d = GetEnvironmentVariableA (var, c, 2);\n    if (0 != d && GetLastError () != ERROR_ENVVAR_NOT_FOUND) {\n      return d;\n    }\n  }\n  b = SetEnvironmentVariableA (var, val);\n  if (b) {\n    return 0;\n  }\n  return 1;\n}\n#endif\n\n/*\n * mktime() has side-effects and anyways, returns time in the local\n * timezone, not UTC.  We want timegm(), which isn't standard.\n *\n * To make things worse, mktime() tells you what the timezone\n * adjustment is, but you have to #define _BSD_SOURCE to get this\n * field of struct tm on some systems.\n *\n * This is all to blame on POSIX, of course.\n *\n * Our wrapper tries to use timegm() if available, or mktime() and\n * correct for its side-effects if possible.\n *\n * Returns (time_t)-2 if mktime()'s side-effects cannot be corrected.\n */\nstatic time_t my_mktime(struct tm *tm) {\n#ifdef HAVE_TIMEGM\n  return timegm(tm);\n#elif HAVE_TM_TM_GMT_OFF\n\n  time_t t = mktime(tm);\n  if (t == (time_t)-1)\n    return t;\n  return t + tm->tm_gmtoff;\n#elif HAVE_TM___TM_GMT_OFF\n  time_t t = mktime(tm);\n  if (t == (time_t)-1)\n    return t;\n  return t + tm->__tm_gmtoff;\n#elif WIN32\n  return _mkgmtime(tm);\n#else\n  char *tz;\n\n  tz = (tz = getenv(\"TZ\")) != NULL ? strdup(tz) : NULL;\n  if (tz != NULL)\n    setenv(\"TZ\", \"\", 1);\n  time_t t = mktime(tm);\n  if (tz != NULL) {\n    setenv(\"TZ\", tz, 1);\n    free(tz);\n  }\n  return t;\n#endif\n}\n\n/* Compute and set tm_wday */\nstatic void set_tm_wday(struct tm *tm) {\n  /*\n   * https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Gauss.27s_algorithm\n   * https://cs.uwaterloo.ca/~alopez-o/math-faq/node73.html\n   *\n   * Tested with dates from 1900-01-01 through 2100-01-01.  This\n   * algorithm produces the wrong day-of-the-week number for dates in\n   * the range 1900-01-01..1900-02-28, and for 2100-01-01..2100-02-28.\n   * Since this is only needed on OS X and *BSD, we might just document\n   * this.\n   */\n  int century = (1900 + tm->tm_year) / 100;\n  int year = (1900 + tm->tm_year) % 100;\n  if (tm->tm_mon < 2)\n    year--;\n  /*\n   * The month value in the wday computation below is shifted so that\n   * March is 1, April is 2, .., January is 11, and February is 12.\n   */\n  int mon = tm->tm_mon - 1;\n  if (mon < 1)\n    mon += 12;\n  int wday =\n    (tm->tm_mday + (int)floor((2.6 * mon - 0.2)) + year + (int)floor(year / 4.0) + (int)floor(century / 4.0) - 2 * century) % 7;\n  if (wday < 0)\n    wday += 7;\n#if 0\n  /* See commentary above */\n  assert(wday == tm->tm_wday || tm->tm_wday == 8);\n#endif\n  tm->tm_wday = wday;\n}\n/*\n * Compute and set tm_yday.\n *\n */\nstatic void set_tm_yday(struct tm *tm) {\n  static const int d[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};\n  int mon = tm->tm_mon;\n  int year = 1900 + tm->tm_year;\n  int leap_day = 0;\n  if (tm->tm_mon > 1 &&\n      ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))\n    leap_day = 1;\n\n  /* Bound check index into d[] */\n  if (mon < 0)\n    mon = -mon;\n  if (mon > 11)\n    mon %= 12;\n\n  int yday = d[mon] + leap_day + tm->tm_mday - 1;\n  assert(yday == tm->tm_yday || tm->tm_yday == 367);\n  tm->tm_yday = yday;\n}\n\nstatic jv f_strptime(jq_state *jq, jv a, jv b) {\n  if (jv_get_kind(a) != JV_KIND_STRING || jv_get_kind(b) != JV_KIND_STRING) {\n    return ret_error2(a, b, jv_string(\"strptime/1 requires string inputs and arguments\"));\n  }\n\n  struct tm tm;\n  memset(&tm, 0, sizeof(tm));\n  tm.tm_wday = 8; // sentinel\n  tm.tm_yday = 367; // sentinel\n\n  const char *input = jv_string_value(a);\n  const char *fmt = jv_string_value(b);\n  const char *end = strptime(input, fmt, &tm);\n  if (end == NULL || (*end != '\\0' && !isspace((unsigned char)*end))) {\n    return ret_error2(a, b, jv_string_fmt(\"date \\\"%s\\\" does not match format \\\"%s\\\"\", input, fmt));\n  }\n  jv_free(b);\n  /*\n   * This is OS X or some *BSD whose strptime() is just not that\n   * helpful!\n   *\n   * We don't know that the format string did involve parsing a\n   * year, or a month (if tm->tm_mon == 0).  But with our invalid\n   * day-of-week and day-of-year sentinel checks above, the worst\n   * this can do is produce garbage.\n   */\n#ifdef __APPLE__\n  /*\n   * Apple has made it worse, and different versions of the OS have different\n   * behaviors. Some versions just don't touch the fields, but others do, and\n   * sometimes provide wrong answers, at that! We can't tell at compile-time\n   * which behavior the target system will have, so instead we always use our\n   * functions to set these on OS X, and document that %u and %j are\n   * unsupported on OS X.\n   */\n  set_tm_wday(&tm);\n  set_tm_yday(&tm);\n#elif defined(WIN32) || !defined(HAVE_STRPTIME)\n  set_tm_wday(&tm);\n#else\n  if (tm.tm_wday == 8 && tm.tm_mday != 0 && tm.tm_mon >= 0 && tm.tm_mon <= 11)\n    set_tm_wday(&tm);\n  if (tm.tm_yday == 367 && tm.tm_mday != 0 && tm.tm_mon >= 0 && tm.tm_mon <= 11)\n    set_tm_yday(&tm);\n#endif\n  jv r = tm2jv(&tm, 0);\n  if (*end != '\\0')\n    r = jv_array_append(r, jv_string(end));\n  jv_free(a); // must come after `*end` because `end` is a pointer into `a`'s string\n  return r;\n}\n\nstatic int jv2tm(jv a, struct tm *tm, int localtime) {\n  memset(tm, 0, sizeof(*tm));\n  static const size_t offsets[] = {\n    offsetof(struct tm, tm_year),\n    offsetof(struct tm, tm_mon),\n    offsetof(struct tm, tm_mday),\n    offsetof(struct tm, tm_hour),\n    offsetof(struct tm, tm_min),\n    offsetof(struct tm, tm_sec),\n    offsetof(struct tm, tm_wday),\n    offsetof(struct tm, tm_yday),\n  };\n\n  for (size_t i = 0; i < (sizeof offsets / sizeof *offsets); ++i) {\n    jv n = jv_array_get(jv_copy(a), i);\n    if (!jv_is_valid(n))\n      break;\n    if (jv_get_kind(n) != JV_KIND_NUMBER || jvp_number_is_nan(n)) {\n      jv_free(a);\n      jv_free(n);\n      return 0;\n    }\n    double d = jv_number_value(n);\n    if (i == 0) /* year */\n      d -= 1900;\n    *(int *)((void *)tm + offsets[i]) = d < INT_MIN ? INT_MIN :\n                                        d > INT_MAX ? INT_MAX : (int)d;\n    jv_free(n);\n  }\n\n  if (localtime) {\n    tm->tm_isdst = -1;\n    mktime(tm);\n  } else {\n#ifdef HAVE_TIMEGM\n    timegm(tm);\n#elif HAVE_TM_TM_GMT_OFF\n    // tm->tm_gmtoff = 0;\n    tm->tm_zone = \"GMT\";\n#elif HAVE_TM___TM_GMT_OFF\n    // tm->__tm_gmtoff = 0;\n    tm->__tm_zone = \"GMT\";\n#endif\n    // tm->tm_isdst = 0;\n\n    // The standard permits the tm structure to contain additional members. We\n    // hope it is okay to initialize them to zero, because the standard does not\n    // provide an alternative.\n  }\n\n  jv_free(a);\n  return 1;\n}\n\n#undef TO_TM_FIELD\n\nstatic jv f_mktime(jq_state *jq, jv a) {\n  if (jv_get_kind(a) != JV_KIND_ARRAY)\n    return ret_error(a, jv_string(\"mktime requires array inputs\"));\n  struct tm tm;\n  if (!jv2tm(a, &tm, 0))\n    return jv_invalid_with_msg(jv_string(\"mktime requires parsed datetime inputs\"));\n  time_t t = my_mktime(&tm);\n  if (t == (time_t)-1)\n    return jv_invalid_with_msg(jv_string(\"invalid gmtime representation\"));\n  if (t == (time_t)-2)\n    return jv_invalid_with_msg(jv_string(\"mktime not supported on this platform\"));\n  return jv_number(t);\n}\n\n#ifdef HAVE_GMTIME_R\nstatic jv f_gmtime(jq_state *jq, jv a) {\n  if (jv_get_kind(a) != JV_KIND_NUMBER)\n    return ret_error(a, jv_string(\"gmtime() requires numeric inputs\"));\n  struct tm tm, *tmp;\n  memset(&tm, 0, sizeof(tm));\n  double fsecs = jv_number_value(a);\n  time_t secs = fsecs;\n  jv_free(a);\n  tmp = gmtime_r(&secs, &tm);\n  if (tmp == NULL)\n    return jv_invalid_with_msg(jv_string(\"error converting number of seconds since epoch to datetime\"));\n  return tm2jv(tmp, fsecs);\n}\n#elif defined HAVE_GMTIME\nstatic jv f_gmtime(jq_state *jq, jv a) {\n  if (jv_get_kind(a) != JV_KIND_NUMBER)\n    return ret_error(a, jv_string(\"gmtime requires numeric inputs\"));\n  struct tm tm, *tmp;\n  memset(&tm, 0, sizeof(tm));\n  double fsecs = jv_number_value(a);\n  time_t secs = fsecs;\n  jv_free(a);\n  tmp = gmtime(&secs);\n  if (tmp == NULL)\n    return jv_invalid_with_msg(jv_string(\"error converting number of seconds since epoch to datetime\"));\n  return tm2jv(tmp, fsecs);\n}\n#else\nstatic jv f_gmtime(jq_state *jq, jv a) {\n  jv_free(a);\n  return jv_invalid_with_msg(jv_string(\"gmtime not implemented on this platform\"));\n}\n#endif\n\n#ifdef HAVE_LOCALTIME_R\nstatic jv f_localtime(jq_state *jq, jv a) {\n  if (jv_get_kind(a) != JV_KIND_NUMBER)\n    return ret_error(a, jv_string(\"localtime() requires numeric inputs\"));\n  struct tm tm, *tmp;\n  memset(&tm, 0, sizeof(tm));\n  double fsecs = jv_number_value(a);\n  time_t secs = fsecs;\n  jv_free(a);\n  tmp = localtime_r(&secs, &tm);\n  if (tmp == NULL)\n    return jv_invalid_with_msg(jv_string(\"error converting number of seconds since epoch to datetime\"));\n  return tm2jv(tmp, fsecs);\n}\n#elif defined HAVE_GMTIME\nstatic jv f_localtime(jq_state *jq, jv a) {\n  if (jv_get_kind(a) != JV_KIND_NUMBER)\n    return ret_error(a, jv_string(\"localtime requires numeric inputs\"));\n  struct tm tm, *tmp;\n  memset(&tm, 0, sizeof(tm));\n  double fsecs = jv_number_value(a);\n  time_t secs = fsecs;\n  jv_free(a);\n  tmp = localtime(&secs);\n  if (tmp == NULL)\n    return jv_invalid_with_msg(jv_string(\"error converting number of seconds since epoch to datetime\"));\n  return tm2jv(tmp, fsecs);\n}\n#else\nstatic jv f_localtime(jq_state *jq, jv a) {\n  jv_free(a);\n  return jv_invalid_with_msg(jv_string(\"localtime not implemented on this platform\"));\n}\n#endif\n\n#ifdef HAVE_STRFTIME\nstatic jv f_strftime(jq_state *jq, jv a, jv b) {\n  if (jv_get_kind(a) == JV_KIND_NUMBER) {\n    a = f_gmtime(jq, a);\n    if (!jv_is_valid(a)) {\n      jv_free(b);\n      return a;\n    }\n  } else if (jv_get_kind(a) != JV_KIND_ARRAY) {\n    return ret_error2(a, b, jv_string(\"strftime/1 requires parsed datetime inputs\"));\n  }\n  if (jv_get_kind(b) != JV_KIND_STRING)\n    return ret_error2(a, b, jv_string(\"strftime/1 requires a string format\"));\n  struct tm tm;\n  if (!jv2tm(a, &tm, 0))\n    return ret_error(b, jv_string(\"strftime/1 requires parsed datetime inputs\"));\n\n  const char *fmt = jv_string_value(b);\n  int fmt_not_empty = *fmt != '\\0';\n  size_t max_size = strlen(fmt) + 100;\n  char *buf = jv_mem_alloc(max_size);\n#ifdef __APPLE__\n  /* Apple Libc (as of version 1669.40.2) contains a bug which causes it to\n   * ignore the `tm.tm_gmtoff` in favor of the global timezone. To print the\n   * proper timezone offset we temporarily switch the TZ to UTC. */\n  char *tz = (tz = getenv(\"TZ\")) != NULL ? strdup(tz) : NULL;\n  setenv(\"TZ\", \"UTC\", 1);\n#endif\n  size_t n = strftime(buf, max_size, fmt, &tm);\n#ifdef __APPLE__\n  if (tz) {\n    setenv(\"TZ\", tz, 1);\n    free(tz);\n  } else {\n    unsetenv(\"TZ\");\n  }\n#endif\n  jv_free(b);\n  /* POSIX doesn't provide errno values for strftime() failures; weird */\n  if ((n == 0 && fmt_not_empty) || n > max_size) {\n    free(buf);\n    return jv_invalid_with_msg(jv_string(\"strftime/1: unknown system failure\"));\n  }\n  jv ret = jv_string_sized(buf, n);\n  free(buf);\n  return ret;\n}\n#else\nstatic jv f_strftime(jq_state *jq, jv a, jv b) {\n  jv_free(a);\n  jv_free(b);\n  return jv_invalid_with_msg(jv_string(\"strftime/1 not implemented on this platform\"));\n}\n#endif\n\n#ifdef HAVE_STRFTIME\nstatic jv f_strflocaltime(jq_state *jq, jv a, jv b) {\n  if (jv_get_kind(a) == JV_KIND_NUMBER) {\n    a = f_localtime(jq, a);\n    if (!jv_is_valid(a)) {\n      jv_free(b);\n      return a;\n    }\n  } else if (jv_get_kind(a) != JV_KIND_ARRAY) {\n    return ret_error2(a, b, jv_string(\"strflocaltime/1 requires parsed datetime inputs\"));\n  }\n  if (jv_get_kind(b) != JV_KIND_STRING)\n    return ret_error2(a, b, jv_string(\"strflocaltime/1 requires a string format\"));\n  struct tm tm;\n  if (!jv2tm(a, &tm, 1))\n    return ret_error(b, jv_string(\"strflocaltime/1 requires parsed datetime inputs\"));\n  const char *fmt = jv_string_value(b);\n  int fmt_not_empty = *fmt != '\\0';\n  size_t max_size = strlen(fmt) + 100;\n  char *buf = jv_mem_alloc(max_size);\n  size_t n = strftime(buf, max_size, fmt, &tm);\n  jv_free(b);\n  /* POSIX doesn't provide errno values for strftime() failures; weird */\n  if ((n == 0 && fmt_not_empty) || n > max_size) {\n    free(buf);\n    return jv_invalid_with_msg(jv_string(\"strflocaltime/1: unknown system failure\"));\n  }\n  jv ret = jv_string_sized(buf, n);\n  free(buf);\n  return ret;\n}\n#else\nstatic jv f_strflocaltime(jq_state *jq, jv a, jv b) {\n  jv_free(a);\n  jv_free(b);\n  return jv_invalid_with_msg(jv_string(\"strflocaltime/1 not implemented on this platform\"));\n}\n#endif\n\n#ifdef HAVE_GETTIMEOFDAY\nstatic jv f_now(jq_state *jq, jv a) {\n  jv_free(a);\n  struct timeval tv;\n  if (gettimeofday(&tv, NULL) == -1)\n    return jv_number(time(NULL));\n  return jv_number(tv.tv_sec + tv.tv_usec / 1000000.0);\n}\n#else\nstatic jv f_now(jq_state *jq, jv a) {\n  jv_free(a);\n  return jv_number(time(NULL));\n}\n#endif\n\nstatic jv f_current_filename(jq_state *jq, jv a) {\n  jv_free(a);\n\n  jv r = jq_util_input_get_current_filename(jq);\n  if (jv_is_valid(r))\n    return r;\n  jv_free(r);\n  return jv_null();\n}\nstatic jv f_current_line(jq_state *jq, jv a) {\n  jv_free(a);\n  return jq_util_input_get_current_line(jq);\n}\n\nstatic jv f_have_decnum(jq_state *jq, jv a) {\n  jv_free(a);\n#ifdef USE_DECNUM\n  return jv_true();\n#else\n  return jv_false();\n#endif\n}\n\n#define CFUNC(func, name, arity) \\\n  {.fptr = { .a ## arity = func }, name, arity}\n\n#define LIBM_DD(name) \\\n  CFUNC(f_ ## name, #name, 1),\n#define LIBM_DD_NO(name) LIBM_DD(name)\n#define LIBM_DA(name, type) LIBM_DD(name)\n#define LIBM_DA_NO(name, type) LIBM_DD(name)\n\n#define LIBM_DDD(name) \\\n  CFUNC(f_ ## name, #name, 3),\n#define LIBM_DDD_NO(name) LIBM_DDD(name)\n\n#define LIBM_DDDD(name) \\\n  CFUNC(f_ ## name, #name, 4),\n#define LIBM_DDDD_NO(name) LIBM_DDDD(name)\n\nstatic const struct cfunction function_list[] = {\n#include \"libm.h\"\n  CFUNC(f_negate, \"_negate\", 1),\n#define BINOP(name) CFUNC(f_ ## name, \"_\" #name, 3),\nBINOPS\n#undef BINOP\n  CFUNC(f_dump, \"tojson\", 1),\n  CFUNC(f_json_parse, \"fromjson\", 1),\n  CFUNC(f_tonumber, \"tonumber\", 1),\n  CFUNC(f_toboolean, \"toboolean\", 1),\n  CFUNC(f_tostring, \"tostring\", 1),\n  CFUNC(f_keys, \"keys\", 1),\n  CFUNC(f_keys_unsorted, \"keys_unsorted\", 1),\n  CFUNC(f_startswith, \"startswith\", 2),\n  CFUNC(f_endswith, \"endswith\", 2),\n  CFUNC(f_string_split, \"split\", 2),\n  CFUNC(f_string_explode, \"explode\", 1),\n  CFUNC(f_string_implode, \"implode\", 1),\n  CFUNC(f_string_indexes, \"_strindices\", 2),\n  CFUNC(f_string_trim, \"trim\", 1),\n  CFUNC(f_string_ltrim, \"ltrim\", 1),\n  CFUNC(f_string_rtrim, \"rtrim\", 1),\n  CFUNC(f_setpath, \"setpath\", 3),\n  CFUNC(f_getpath, \"getpath\", 2),\n  CFUNC(f_delpaths, \"delpaths\", 2),\n  CFUNC(f_has, \"has\", 2),\n  CFUNC(f_contains, \"contains\", 2),\n  CFUNC(f_length, \"length\", 1),\n  CFUNC(f_utf8bytelength, \"utf8bytelength\", 1),\n  CFUNC(f_type, \"type\", 1),\n  CFUNC(f_isinfinite, \"isinfinite\", 1),\n  CFUNC(f_isnan, \"isnan\", 1),\n  CFUNC(f_isnormal, \"isnormal\", 1),\n  CFUNC(f_infinite, \"infinite\", 1),\n  CFUNC(f_nan, \"nan\", 1),\n  CFUNC(f_sort, \"sort\", 1),\n  CFUNC(f_sort_by_impl, \"_sort_by_impl\", 2),\n  CFUNC(f_group_by_impl, \"_group_by_impl\", 2),\n  CFUNC(f_unique, \"unique\", 1),\n  CFUNC(f_unique_by_impl, \"_unique_by_impl\", 2),\n  CFUNC(f_bsearch, \"bsearch\", 2),\n  CFUNC(f_min, \"min\", 1),\n  CFUNC(f_max, \"max\", 1),\n  CFUNC(f_min_by_impl, \"_min_by_impl\", 2),\n  CFUNC(f_max_by_impl, \"_max_by_impl\", 2),\n  CFUNC(f_error, \"error\", 1),\n  CFUNC(f_format, \"format\", 2),\n  CFUNC(f_env, \"env\", 1),\n  CFUNC(f_halt, \"halt\", 1),\n  CFUNC(f_halt_error, \"halt_error\", 2),\n  CFUNC(f_get_search_list, \"get_search_list\", 1),\n  CFUNC(f_get_prog_origin, \"get_prog_origin\", 1),\n  CFUNC(f_get_jq_origin, \"get_jq_origin\", 1),\n  CFUNC(f_match, \"_match_impl\", 4),\n  CFUNC(f_modulemeta, \"modulemeta\", 1),\n  CFUNC(f_input, \"input\", 1),\n  CFUNC(f_debug, \"debug\", 1),\n  CFUNC(f_stderr, \"stderr\", 1),\n  CFUNC(f_strptime, \"strptime\", 2),\n  CFUNC(f_strftime, \"strftime\", 2),\n  CFUNC(f_strflocaltime, \"strflocaltime\", 2),\n  CFUNC(f_mktime, \"mktime\", 1),\n  CFUNC(f_gmtime, \"gmtime\", 1),\n  CFUNC(f_localtime, \"localtime\", 1),\n  CFUNC(f_now, \"now\", 1),\n  CFUNC(f_current_filename, \"input_filename\", 1),\n  CFUNC(f_current_line, \"input_line_number\", 1),\n  CFUNC(f_have_decnum, \"have_decnum\", 1),\n  CFUNC(f_have_decnum, \"have_literal_numbers\", 1),\n};\n#undef LIBM_DDDD_NO\n#undef LIBM_DDD_NO\n#undef LIBM_DD_NO\n#undef LIBM_DA_NO\n#undef LIBM_DDDD\n#undef LIBM_DDD\n#undef LIBM_DD\n#undef LIBM_DA\n\n// This is a hack to make last(g) yield no output values,\n// if g yields no output values, without using boxing.\nstatic block gen_last_1(void) {\n  block last_var = gen_op_var_fresh(STOREV, \"last\");\n  block is_empty_var = gen_op_var_fresh(STOREV, \"is_empty\");\n  block init = BLOCK(gen_op_simple(DUP),\n                     gen_const(jv_null()),\n                     last_var,\n                     gen_op_simple(DUP),\n                     gen_const(jv_true()),\n                     is_empty_var);\n  block call_arg = BLOCK(gen_call(\"arg\", gen_noop()),\n                         gen_op_simple(DUP),\n                         gen_op_bound(STOREV, last_var),\n                         gen_const(jv_false()),\n                         gen_op_bound(STOREV, is_empty_var),\n                         gen_op_simple(BACKTRACK));\n  block if_empty = gen_op_simple(BACKTRACK);\n  return BLOCK(init,\n               gen_op_target(FORK, call_arg),\n               call_arg,\n               BLOCK(gen_op_bound(LOADVN, is_empty_var),\n                     gen_op_target(JUMP_F, if_empty),\n                     if_empty,\n                     gen_op_bound(LOADVN, last_var)));\n}\n\nstruct bytecoded_builtin { const char* name; block code; };\nstatic block bind_bytecoded_builtins(block b) {\n  block builtins = gen_noop();\n  {\n    struct bytecoded_builtin builtin_defs[] = {\n      {\"empty\", gen_op_simple(BACKTRACK)},\n      {\"not\", gen_condbranch(gen_const(jv_false()),\n                             gen_const(jv_true()))}\n    };\n    for (unsigned i=0; i<sizeof(builtin_defs)/sizeof(builtin_defs[0]); i++) {\n      builtins = BLOCK(builtins, gen_function(builtin_defs[i].name, gen_noop(),\n                                              builtin_defs[i].code));\n    }\n  }\n  {\n    struct bytecoded_builtin builtin_def_1arg[] = {\n      {\"path\", BLOCK(gen_op_simple(PATH_BEGIN),\n                     gen_call(\"arg\", gen_noop()),\n                     gen_op_simple(PATH_END))},\n      {\"last\", gen_last_1()},\n    };\n    for (unsigned i=0; i<sizeof(builtin_def_1arg)/sizeof(builtin_def_1arg[0]); i++) {\n      builtins = BLOCK(builtins, gen_function(builtin_def_1arg[i].name,\n                                              gen_param(\"arg\"),\n                                              builtin_def_1arg[i].code));\n    }\n  }\n  {\n    // Note that we can now define `range` as a jq-coded function\n    block rangevar = gen_op_var_fresh(STOREV, \"rangevar\");\n    block rangestart = gen_op_var_fresh(STOREV, \"rangestart\");\n    block range = BLOCK(gen_op_simple(DUP),\n                        gen_call(\"start\", gen_noop()),\n                        rangestart,\n                        gen_call(\"end\", gen_noop()),\n                        gen_op_simple(DUP),\n                        gen_op_bound(LOADV, rangestart),\n                        // Reset rangevar for every value generated by \"end\"\n                        rangevar,\n                        gen_op_bound(RANGE, rangevar));\n    builtins = BLOCK(builtins, gen_function(\"range\",\n                                            BLOCK(gen_param(\"start\"), gen_param(\"end\")),\n                                            range));\n  }\n  return BLOCK(builtins, b);\n}\n\nstatic const char jq_builtins[] = {\n/* Include jq-coded builtins */\n#include \"src/builtin.inc\"\n  '\\0',\n};\n\nstatic block gen_builtin_list(block builtins) {\n  jv list = jv_array_append(block_list_funcs(builtins, 1), jv_string(\"builtins/0\"));\n  return BLOCK(builtins, gen_function(\"builtins\", gen_noop(), gen_const(list)));\n}\n\nint builtins_bind(jq_state *jq, block* bb) {\n  block builtins;\n  struct locfile* src = locfile_init(jq, \"<builtin>\", jq_builtins, sizeof(jq_builtins)-1);\n  int nerrors = jq_parse_library(src, &builtins);\n  assert(!nerrors);\n  locfile_free(src);\n\n  builtins = bind_bytecoded_builtins(builtins);\n  builtins = gen_cbinding(function_list, sizeof(function_list)/sizeof(function_list[0]), builtins);\n  builtins = gen_builtin_list(builtins);\n\n  *bb = block_bind_referenced(builtins, *bb, OP_IS_CALL_PSEUDO);\n  return nerrors;\n}\n"
  },
  {
    "path": "src/builtin.h",
    "content": "#ifndef BUILTIN_H\n#define BUILTIN_H\n\n#include \"jq.h\"\n#include \"bytecode.h\"\n#include \"compile.h\"\n\nint builtins_bind(jq_state *, block*);\n\n#define BINOPS \\\n  BINOP(plus) \\\n  BINOP(minus) \\\n  BINOP(multiply) \\\n  BINOP(divide) \\\n  BINOP(mod) \\\n  BINOP(equal) \\\n  BINOP(notequal) \\\n  BINOP(less) \\\n  BINOP(lesseq) \\\n  BINOP(greater) \\\n  BINOP(greatereq) \\\n\n\n#define BINOP(name) jv binop_ ## name(jv, jv);\nBINOPS\n#undef BINOP\n\n#endif\n"
  },
  {
    "path": "src/builtin.jq",
    "content": "def halt_error: halt_error(5);\ndef error(msg): msg|error;\ndef map(f): [.[] | f];\ndef select(f): if f then . else empty end;\ndef sort_by(f): _sort_by_impl(map([f]));\ndef group_by(f): _group_by_impl(map([f]));\ndef unique_by(f): _unique_by_impl(map([f]));\ndef max_by(f): _max_by_impl(map([f]));\ndef min_by(f): _min_by_impl(map([f]));\ndef add(f): reduce f as $x (null; . + $x);\ndef add: add(.[]);\ndef del(f): delpaths([path(f)]);\ndef abs: if . < 0 then - . else . end;\ndef _assign(paths; $value): reduce path(paths) as $p (.; setpath($p; $value));\ndef _modify(paths; update):\n    reduce path(paths) as $p ([., []];\n        . as $dot\n      | null\n      | label $out\n      | ($dot[0] | getpath($p)) as $v\n      | (\n          (   $$$$v\n            | update\n            | (., break $out) as $v\n            | $$$$dot\n            | setpath([0] + $p; $v)\n          ),\n          (\n              $$$$dot\n            | setpath([1, (.[1] | length)]; $p)\n          )\n        )\n    ) | . as $dot | $dot[0] | delpaths($dot[1]);\ndef map_values(f): .[] |= f;\n\n# recurse\ndef recurse(f): def r: ., (f | r); r;\ndef recurse(f; cond): def r: ., (f | select(cond) | r); r;\ndef recurse: recurse(.[]?);\n\ndef to_entries: [keys_unsorted[] as $k | {key: $k, value: .[$k]}];\ndef from_entries: map({(.key // .Key // .name // .Name): (if has(\"value\") then .value else .Value end)}) | add | .//={};\ndef with_entries(f): to_entries | map(f) | from_entries;\ndef reverse: [.[length - 1 - range(0;length)]];\ndef indices($i): if type == \"array\" and ($i|type) == \"array\" then .[$i]\n  elif type == \"array\" then .[[$i]]\n  elif type == \"string\" and ($i|type) == \"string\" then _strindices($i)\n  else .[$i] end;\ndef index($i):   indices($i) | .[0];       # TODO: optimize\ndef rindex($i):  indices($i) | .[-1:][0];  # TODO: optimize\ndef paths: path(recurse)|select(length > 0);\ndef paths(node_filter): path(recurse|select(node_filter))|select(length > 0);\ndef isfinite: type == \"number\" and (isinfinite | not);\ndef arrays: select(type == \"array\");\ndef objects: select(type == \"object\");\ndef iterables: select(type|. == \"array\" or . == \"object\");\ndef booleans: select(type == \"boolean\");\ndef numbers: select(type == \"number\");\ndef normals: select(isnormal);\ndef finites: select(isfinite);\ndef strings: select(type == \"string\");\ndef nulls: select(. == null);\ndef values: select(. != null);\ndef scalars: select(type|. != \"array\" and . != \"object\");\ndef join($x): reduce .[] as $i (null;\n            (if .==null then \"\" else .+$x end) +\n            ($i | if type==\"boolean\" or type==\"number\" then tostring else .//\"\" end)\n        ) // \"\";\ndef _flatten($x): reduce .[] as $i ([]; if $i | type == \"array\" and $x != 0 then . + ($i | _flatten($x-1)) else . + [$i] end);\ndef flatten($x): if $x < 0 then error(\"flatten depth must not be negative\") else _flatten($x) end;\ndef flatten: _flatten(-1);\ndef range($x): range(0;$x);\ndef fromdateiso8601: strptime(\"%Y-%m-%dT%H:%M:%SZ\")|mktime;\ndef todateiso8601: strftime(\"%Y-%m-%dT%H:%M:%SZ\");\ndef fromdate: fromdateiso8601;\ndef todate: todateiso8601;\ndef ltrimstr($left): if startswith($left) then .[$left | length:] end;\ndef rtrimstr($right): if endswith($right) then .[:length - ($right | length)] end;\ndef trimstr($val): ltrimstr($val) | rtrimstr($val);\ndef match(re; mode): _match_impl(re; mode; false)|.[];\ndef match($val): ($val|type) as $vt | if $vt == \"string\" then match($val; null)\n   elif $vt == \"array\" and ($val | length) > 1 then match($val[0]; $val[1])\n   elif $vt == \"array\" and ($val | length) > 0 then match($val[0]; null)\n   else error( $vt + \" not a string or array\") end;\ndef test(re; mode): _match_impl(re; mode; true);\ndef test($val): ($val|type) as $vt | if $vt == \"string\" then test($val; null)\n   elif $vt == \"array\" and ($val | length) > 1 then test($val[0]; $val[1])\n   elif $vt == \"array\" and ($val | length) > 0 then test($val[0]; null)\n   else error( $vt + \" not a string or array\") end;\ndef capture(re; mods): match(re; mods) | reduce ( .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair ({}; . + $pair);\ndef capture($val): ($val|type) as $vt | if $vt == \"string\" then capture($val; null)\n   elif $vt == \"array\" and ($val | length) > 1 then capture($val[0]; $val[1])\n   elif $vt == \"array\" and ($val | length) > 0 then capture($val[0]; null)\n   else error( $vt + \" not a string or array\") end;\ndef scan($re; $flags):\n  match($re; \"g\" + $flags)\n    | if (.captures|length > 0)\n      then [ .captures | .[] | .string ]\n      else .string\n      end;\ndef scan($re): scan($re; null);\n\n# splits/1 produces a stream; split/1 is retained for backward compatibility.\ndef splits($re; $flags):\n  .[foreach (match($re; $flags+\"g\"), null) as {$offset, $length}\n      (null; {start: .next, end: $offset, next: ($offset+$length)})];\ndef splits($re): splits($re; null);\n\n# split emits an array for backward compatibility\ndef split($re; $flags): [ splits($re; $flags) ];\n\n# If s contains capture variables, then create a capture object and pipe it to s, bearing\n# in mind that s could be a stream\ndef sub($re; s; $flags):\n   . as $in\n   | (reduce match($re; $flags) as $edit\n        ({result: [], previous: 0};\n            $in[ .previous: ($edit | .offset) ] as $gap\n            # create the \"capture\" objects (one per item in s)\n            | [reduce ( $edit | .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair\n                 ({}; . + $pair) | s ] as $inserts\n            | reduce range(0; $inserts|length) as $ix (.; .result[$ix] += $gap + $inserts[$ix])\n            | .previous = ($edit | .offset + .length ) )\n          | .result[] + $in[.previous:] )\n      // $in;\n\ndef sub($re; s): sub($re; s; \"\");\n\ndef gsub($re; s; flags): sub($re; s; flags + \"g\");\ndef gsub($re; s): sub($re; s; \"g\");\n\n########################################################################\n# generic iterator/generator\ndef while(cond; update):\n     def _while:\n         if cond then ., (update | _while) else empty end;\n     _while;\ndef until(cond; next):\n     def _until:\n         if cond then . else (next|_until) end;\n     _until;\ndef limit($n; expr):\n  if $n > 0 then label $out | foreach expr as $item ($n; . - 1; $item, if . <= 0 then break $out else empty end)\n  elif $n == 0 then empty\n  else error(\"limit doesn't support negative count\") end;\ndef skip($n; expr):\n  if $n > 0 then foreach expr as $item ($n; . - 1; if . < 0 then $item else empty end)\n  elif $n == 0 then expr\n  else error(\"skip doesn't support negative count\") end;\n# range/3, with a `by` expression argument\ndef range($init; $upto; $by):\n    if $by > 0 then $init|while(. < $upto; . + $by)\n  elif $by < 0 then $init|while(. > $upto; . + $by)\n  else empty end;\ndef first(g): label $out | g | ., break $out;\ndef isempty(g): first((g|false), true);\ndef all(generator; condition): isempty(generator|condition and empty);\ndef any(generator; condition): isempty(generator|condition or empty)|not;\ndef all(condition): all(.[]; condition);\ndef any(condition): any(.[]; condition);\ndef all: all(.[]; .);\ndef any: any(.[]; .);\ndef nth($n; g):\n  if $n < 0 then error(\"nth doesn't support negative indices\")\n  else first(skip($n; g)) end;\ndef first: .[0];\ndef last: .[-1];\ndef nth($n): .[$n];\ndef combinations:\n    if length == 0 then [] else\n        .[0][] as $x\n          | (.[1:] | combinations) as $y\n          | [$x] + $y\n    end;\ndef combinations(n):\n    . as $dot\n      | [range(n) | $dot]\n      | combinations;\n# transpose a possibly jagged matrix, quickly;\n# rows are padded with nulls so the result is always rectangular.\ndef transpose: [range(0; map(length)|max // 0) as $i | [.[][$i]]];\ndef in(xs): . as $x | xs | has($x);\ndef inside(xs): . as $x | xs | contains($x);\ndef repeat(exp):\n     def _repeat:\n         exp, _repeat;\n     _repeat;\ndef inputs: try repeat(input) catch if .==\"break\" then empty else error end;\n# like ruby's downcase - only characters A to Z are affected\ndef ascii_downcase:\n  explode | map( if 65 <= . and . <= 90 then . + 32  else . end) | implode;\n# like ruby's upcase - only characters a to z are affected\ndef ascii_upcase:\n  explode | map( if 97 <= . and . <= 122 then . - 32  else . end) | implode;\n\n# Streaming utilities\ndef truncate_stream(stream):\n  . as $n | null | stream | . as $input | if (.[0]|length) > $n then setpath([0];$input[0][$n:]) else empty end;\ndef fromstream(i): {x: null, e: false} as $init |\n  # .x = object being built; .e = emit and reset state\n  foreach i as $i ($init\n  ; if .e then $init else . end\n  | if $i|length == 2\n    then setpath([\"e\"]; $i[0]|length==0) | setpath([\"x\"]+$i[0]; $i[1])\n    else setpath([\"e\"]; $i[0]|length==1) end\n  ; if .e then .x else empty end);\ndef tostream:\n  path(def r: (.[]?|r), .; r) as $p |\n  getpath($p) |\n  reduce path(.[]?) as $q ([$p, .]; [$p+$q]);\n\n# Apply f to composite entities recursively, and to atoms\ndef walk(f):\n  def w:\n    if type == \"object\"\n    then map_values(w)\n    elif type == \"array\" then map(w)\n    else .\n    end\n    | f;\n  w;\n\n# pathexps could be a stream of dot-paths\ndef pick(pathexps):\n  . as $in\n  | reduce path(pathexps) as $a (null;\n      setpath($a; $in|getpath($a)) );\n\n# ensure the output of debug(m1,m2) is kept together:\ndef debug(msgs): (msgs | debug | empty), .;\n\n# SQL-ish operators here:\ndef INDEX(stream; idx_expr):\n  reduce stream as $row ({}; .[$row|idx_expr|tostring] = $row);\ndef INDEX(idx_expr): INDEX(.[]; idx_expr);\ndef JOIN($idx; idx_expr):\n  [.[] | [., $idx[idx_expr]]];\ndef JOIN($idx; stream; idx_expr):\n  stream | [., $idx[idx_expr]];\ndef JOIN($idx; stream; idx_expr; join_expr):\n  stream | [., $idx[idx_expr]] | join_expr;\ndef IN(s): any(s == .; .);\ndef IN(src; s): any(src == s; .);\n"
  },
  {
    "path": "src/bytecode.c",
    "content": "#include <stdio.h>\n#include <stdint.h>\n#include <stdlib.h>\n\n#include \"bytecode.h\"\n#include \"jv_alloc.h\"\n\n// flags, length\n#define NONE 0, 1\n#define CONSTANT OP_HAS_CONSTANT, 2\n#define VARIABLE (OP_HAS_VARIABLE | OP_HAS_BINDING), 3\n#define GLOBAL (OP_HAS_CONSTANT | OP_HAS_VARIABLE | OP_HAS_BINDING | OP_IS_CALL_PSEUDO), 4\n#define BRANCH OP_HAS_BRANCH, 2\n#define CFUNC (OP_HAS_CFUNC | OP_HAS_BINDING), 3\n#define UFUNC (OP_HAS_UFUNC | OP_HAS_BINDING | OP_IS_CALL_PSEUDO), 4\n#define DEFINITION (OP_IS_CALL_PSEUDO | OP_HAS_BINDING), 0\n#define CLOSURE_REF_IMM (OP_IS_CALL_PSEUDO | OP_HAS_BINDING), 2\n\n#define OP(name, imm, in, out) \\\n  {name, #name, imm, in, out},\n\nstatic const struct opcode_description opcode_descriptions[] = {\n#include \"opcode_list.h\"\n};\n\nstatic const struct opcode_description invalid_opcode_description = {\n  -1, \"#INVALID\", 0, 0, 0, 0\n};\n\n\nconst struct opcode_description* opcode_describe(opcode op) {\n  if ((int)op >= 0 && (int)op < NUM_OPCODES) {\n    return &opcode_descriptions[op];\n  } else {\n    return &invalid_opcode_description;\n  }\n}\n\n\nint bytecode_operation_length(uint16_t* codeptr) {\n  int length = opcode_describe(*codeptr)->length;\n  if (*codeptr == CALL_JQ || *codeptr == TAIL_CALL_JQ) {\n    length += codeptr[1] * 2;\n  }\n  return length;\n}\n\nstatic void dump_code(int indent, struct bytecode* bc) {\n  int pc = 0;\n  while (pc < bc->codelen) {\n    printf(\"%*s\", indent, \"\");\n    dump_operation(bc, bc->code + pc);\n    printf(\"\\n\");\n    pc += bytecode_operation_length(bc->code + pc);\n  }\n}\n\nstatic void symbol_table_free(struct symbol_table* syms) {\n  jv_mem_free(syms->cfunctions);\n  jv_free(syms->cfunc_names);\n  jv_mem_free(syms);\n}\n\nvoid dump_disassembly(int indent, struct bytecode* bc) {\n  if (bc->nclosures > 0) {\n    printf(\"%*s[params: \", indent, \"\");\n    jv params = jv_object_get(jv_copy(bc->debuginfo), jv_string(\"params\"));\n    for (int i=0; i<bc->nclosures; i++) {\n      if (i) printf(\", \");\n      jv name = jv_array_get(jv_copy(params), i);\n      printf(\"%s\", jv_string_value(name));\n      jv_free(name);\n    }\n    jv_free(params);\n    printf(\"]\\n\");\n  }\n  dump_code(indent, bc);\n  for (int i=0; i<bc->nsubfunctions; i++) {\n    struct bytecode* subfn = bc->subfunctions[i];\n    jv name = jv_object_get(jv_copy(subfn->debuginfo), jv_string(\"name\"));\n    printf(\"%*s%s:%d:\\n\", indent, \"\", jv_string_value(name), i);\n    jv_free(name);\n    dump_disassembly(indent+2, subfn);\n  }\n}\n\nstatic struct bytecode* getlevel(struct bytecode* bc, int level) {\n  while (level > 0) {\n    bc = bc->parent;\n    level--;\n  }\n  return bc;\n}\n\nvoid dump_operation(struct bytecode* bc, uint16_t* codeptr) {\n  int pc = codeptr - bc->code;\n  printf(\"%04d \", pc);\n  const struct opcode_description* op = opcode_describe(bc->code[pc++]);\n  printf(\"%s\", op->name);\n  if (op->length > 1) {\n    uint16_t imm = bc->code[pc++];\n    if (op->op == CALL_JQ || op->op == TAIL_CALL_JQ) {\n      for (int i=0; i<imm+1; i++) {\n        uint16_t level = bc->code[pc++];\n        uint16_t idx = bc->code[pc++];\n        jv name;\n        if (idx & ARG_NEWCLOSURE) {\n          idx &= ~ARG_NEWCLOSURE;\n          name = jv_object_get(jv_copy(getlevel(bc,level)->subfunctions[idx]->debuginfo),\n                               jv_string(\"name\"));\n        } else {\n          name = jv_array_get(jv_object_get(jv_copy(getlevel(bc,level)->debuginfo),\n                                            jv_string(\"params\")), idx);\n        }\n        printf(\" %s:%d\",\n               jv_string_value(name),\n               idx);\n        jv_free(name);\n        if (level) {\n          printf(\"^%d\", level);\n        }\n      }\n    } else if (op->op == CALL_BUILTIN) {\n      int func = bc->code[pc++];\n      jv name = jv_array_get(jv_copy(bc->globals->cfunc_names), func);\n      printf(\" %s\", jv_string_value(name));\n      jv_free(name);\n    } else if (op->flags & OP_HAS_BRANCH) {\n      printf(\" %04d\", pc + imm);\n    } else if (op->flags & OP_HAS_CONSTANT) {\n      printf(\" \");\n      jv_dump(jv_array_get(jv_copy(bc->constants), imm), 0);\n    } else if (op->flags & OP_HAS_VARIABLE) {\n      uint16_t v = bc->code[pc++];\n      jv name = jv_array_get(jv_object_get(jv_copy(getlevel(bc,imm)->debuginfo), jv_string(\"locals\")), v);\n      printf(\" $%s:%d\",\n             jv_string_value(name),\n             v);\n      jv_free(name);\n      if (imm) {\n        printf(\"^%d\", imm);\n      }\n    } else {\n      printf(\" %d\", imm);\n    }\n  }\n}\n\nvoid bytecode_free(struct bytecode* bc) {\n  if (!bc)\n    return;\n  jv_mem_free(bc->code);\n  jv_free(bc->constants);\n  for (int i=0; i<bc->nsubfunctions; i++)\n    bytecode_free(bc->subfunctions[i]);\n  if (!bc->parent)\n    symbol_table_free(bc->globals);\n  jv_mem_free(bc->subfunctions);\n  jv_free(bc->debuginfo);\n  jv_mem_free(bc);\n}\n"
  },
  {
    "path": "src/bytecode.h",
    "content": "#ifndef BYTECODE_H\n#define BYTECODE_H\n#include <stdint.h>\n\n#include \"jq.h\"\n\ntypedef enum {\n#define OP(name, imm, in, out) name,\n#include \"opcode_list.h\"\n#undef OP\n} opcode;\n\nenum {\n  NUM_OPCODES =\n#define OP(name, imm, in, out) +1\n#include \"opcode_list.h\"\n#undef OP\n};\n\nenum {\n  OP_HAS_CONSTANT = 2,\n  OP_HAS_VARIABLE = 4,\n  OP_HAS_BRANCH = 8,\n  OP_HAS_CFUNC = 32,\n  OP_HAS_UFUNC = 64,\n  OP_IS_CALL_PSEUDO = 128,\n  OP_HAS_BINDING = 1024,\n  // NOTE: Not actually part of any op -- a pseudo-op flag for special\n  //       handling of `break`.\n  OP_BIND_WILDCARD = 2048,\n};\nstruct opcode_description {\n  opcode op;\n  const char* name;\n\n  int flags;\n\n  // length in 16-bit units\n  int length;\n\n  int stack_in, stack_out;\n};\n\nconst struct opcode_description* opcode_describe(opcode op);\n\n\n#define MAX_CFUNCTION_ARGS 4\nstruct cfunction {\n  union {\n    jv (*a1)(jq_state *, jv);\n    jv (*a2)(jq_state *, jv, jv);\n    jv (*a3)(jq_state *, jv, jv, jv);\n    jv (*a4)(jq_state *, jv, jv, jv, jv);\n  } fptr;\n  const char* name;\n  int nargs;\n};\n\nstruct symbol_table {\n  struct cfunction* cfunctions;\n  int ncfunctions;\n  jv cfunc_names;\n};\n\n// The bytecode format matters in:\n//   execute.c  - interpreter\n//   compile.c  - compiler\n//   bytecode.c - disassembler\n\n#define ARG_NEWCLOSURE 0x1000\n\nstruct bytecode {\n  uint16_t* code;\n  int codelen;\n\n  int nlocals;\n  int nclosures;\n\n  jv constants; // JSON array of constants\n  struct symbol_table* globals;\n\n  struct bytecode** subfunctions;\n  int nsubfunctions;\n\n  struct bytecode* parent;\n\n  jv debuginfo;\n};\n\nvoid dump_disassembly(int, struct bytecode* code);\nvoid dump_operation(struct bytecode* bc, uint16_t* op);\n\nint bytecode_operation_length(uint16_t* codeptr);\nvoid bytecode_free(struct bytecode* bc);\n\n#endif\n"
  },
  {
    "path": "src/compile.c",
    "content": "#include <assert.h>\n#include <string.h>\n#include <stdlib.h>\n#include <unistd.h>\n#include \"compile.h\"\n#include \"bytecode.h\"\n#include \"locfile.h\"\n#include \"jv_alloc.h\"\n#include \"util.h\"\n\n/*\n  The intermediate representation for jq filters is as a sequence of\n  struct inst, which form a doubly-linked list via the next and prev\n  pointers.\n\n  A \"block\" represents a sequence of \"struct inst\", which may be\n  empty.\n\n  Blocks are generated by the parser bottom-up, so may have free\n  variables (refer to things not defined). See inst.bound_by and\n  inst.symbol.\n */\nstruct inst {\n  struct inst* next;\n  struct inst* prev;\n\n  opcode op;\n\n  struct {\n    uint16_t intval;\n    struct inst* target;\n    jv constant;\n    const struct cfunction* cfunc;\n  } imm;\n\n  struct locfile* locfile;\n  location source;\n\n  // Binding\n  // An instruction requiring binding (for parameters/variables/functions)\n  // is in one of three states:\n  //   inst->bound_by = NULL  - Unbound free variable\n  //   inst->bound_by = inst  - This instruction binds a variable\n  //   inst->bound_by = other - Uses variable bound by other instruction\n  // Unbound instructions (references to other things that may or may not\n  // exist) are created by \"gen_foo_unbound\", and bindings are created by\n  // block_bind(definition, body), which binds all instructions in\n  // body which are unbound and refer to \"definition\" by name.\n  struct inst* bound_by;\n  char* symbol;\n  int any_unbound;\n  int referenced;\n\n  int nformals;\n  int nactuals;\n\n  block subfn;   // used by CLOSURE_CREATE (body of function)\n  block arglist; // used by CLOSURE_CREATE (formals) and CALL_JQ (arguments)\n\n  // This instruction is compiled as part of which function?\n  // (only used during block_compile)\n  struct bytecode* compiled;\n\n  int bytecode_pos; // position just after this insn\n};\n\nstatic inst* inst_new(opcode op) {\n  inst* i = jv_mem_alloc(sizeof(inst));\n  i->next = i->prev = 0;\n  i->op = op;\n  i->bytecode_pos = -1;\n  i->bound_by = 0;\n  i->symbol = 0;\n  i->any_unbound = 0;\n  i->referenced = 0;\n  i->nformals = -1;\n  i->nactuals = -1;\n  i->subfn = gen_noop();\n  i->arglist = gen_noop();\n  i->source = UNKNOWN_LOCATION;\n  i->locfile = 0;\n  return i;\n}\n\nstatic void inst_free(struct inst* i) {\n  jv_mem_free(i->symbol);\n  block_free(i->subfn);\n  block_free(i->arglist);\n  if (i->locfile)\n    locfile_free(i->locfile);\n  if (opcode_describe(i->op)->flags & OP_HAS_CONSTANT) {\n    jv_free(i->imm.constant);\n  }\n  jv_mem_free(i);\n}\n\nstatic block inst_block(inst* i) {\n  block b = {i,i};\n  return b;\n}\n\nint block_is_single(block b) {\n  return b.first && b.first == b.last;\n}\n\nstatic inst* block_take(block* b) {\n  if (b->first == 0) return 0;\n  inst* i = b->first;\n  if (i->next) {\n    i->next->prev = 0;\n    b->first = i->next;\n    i->next = 0;\n  } else {\n    b->first = 0;\n    b->last = 0;\n  }\n  return i;\n}\n\nblock gen_location(location loc, struct locfile* l, block b) {\n  for (inst* i = b.first; i; i = i->next) {\n    if (i->source.start == UNKNOWN_LOCATION.start &&\n        i->source.end == UNKNOWN_LOCATION.end) {\n      i->source = loc;\n      i->locfile = locfile_retain(l);\n    }\n  }\n  return b;\n}\n\nblock gen_noop(void) {\n  block b = {0,0};\n  return b;\n}\n\nint block_is_noop(block b) {\n  return (b.first == 0 && b.last == 0);\n}\n\nblock gen_op_simple(opcode op) {\n  assert(opcode_describe(op)->length == 1);\n  return inst_block(inst_new(op));\n}\n\n\nblock gen_error(jv constant) {\n  assert(opcode_describe(ERRORK)->flags & OP_HAS_CONSTANT);\n  inst *i = inst_new(ERRORK);\n  i->imm.constant = constant;\n  return inst_block(i);\n}\n\nblock gen_const(jv constant) {\n  assert(opcode_describe(LOADK)->flags & OP_HAS_CONSTANT);\n  inst* i = inst_new(LOADK);\n  i->imm.constant = constant;\n  return inst_block(i);\n}\n\nblock gen_const_global(jv constant, const char *name) {\n  assert((opcode_describe(STORE_GLOBAL)->flags & (OP_HAS_CONSTANT | OP_HAS_VARIABLE | OP_HAS_BINDING)) ==\n         (OP_HAS_CONSTANT | OP_HAS_VARIABLE | OP_HAS_BINDING));\n  inst* i = inst_new(STORE_GLOBAL);\n  i->imm.constant = constant;\n  i->symbol = strdup(name);\n  i->any_unbound = 0;\n  return inst_block(i);\n}\n\nblock gen_op_pushk_under(jv constant) {\n  assert(opcode_describe(PUSHK_UNDER)->flags & OP_HAS_CONSTANT);\n  inst* i = inst_new(PUSHK_UNDER);\n  i->imm.constant = constant;\n  return inst_block(i);\n}\n\nint block_is_const(block b) {\n  return (block_is_single(b) && (b.first->op == LOADK || b.first->op == PUSHK_UNDER));\n}\n\njv_kind block_const_kind(block b) {\n  assert(block_is_const(b));\n  return jv_get_kind(b.first->imm.constant);\n}\n\njv block_const(block b) {\n  assert(block_is_const(b));\n  return jv_copy(b.first->imm.constant);\n}\n\nblock gen_op_target(opcode op, block target) {\n  assert(opcode_describe(op)->flags & OP_HAS_BRANCH);\n  assert(target.last);\n  inst* i = inst_new(op);\n  i->imm.target = target.last;\n  return inst_block(i);\n}\n\nblock gen_op_targetlater(opcode op) {\n  assert(opcode_describe(op)->flags & OP_HAS_BRANCH);\n  inst* i = inst_new(op);\n  i->imm.target = 0;\n  return inst_block(i);\n}\nvoid inst_set_target(block b, block target) {\n  assert(block_is_single(b));\n  assert(opcode_describe(b.first->op)->flags & OP_HAS_BRANCH);\n  assert(target.last);\n  b.first->imm.target = target.last;\n}\n\nblock gen_op_unbound(opcode op, const char* name) {\n  assert(opcode_describe(op)->flags & OP_HAS_BINDING);\n  inst* i = inst_new(op);\n  i->symbol = strdup(name);\n  i->any_unbound = 1;\n  return inst_block(i);\n}\n\nblock gen_op_var_fresh(opcode op, const char* name) {\n  assert(opcode_describe(op)->flags & OP_HAS_VARIABLE);\n  block b = gen_op_unbound(op, name);\n  b.first->bound_by = b.first;\n  return b;\n}\n\nblock gen_op_bound(opcode op, block binder) {\n  assert(block_is_single(binder));\n  block b = gen_op_unbound(op, binder.first->symbol);\n  b.first->bound_by = binder.first;\n  b.first->any_unbound = 0;\n  return b;\n}\n\nblock gen_dictpair(block k, block v) {\n  return BLOCK(gen_subexp(k), gen_subexp(v), gen_op_simple(INSERT));\n}\n\n\nstatic void inst_join(inst* a, inst* b) {\n  assert(a && b);\n  assert(!a->next);\n  assert(!b->prev);\n  a->next = b;\n  b->prev = a;\n}\n\nvoid block_append(block* b, block b2) {\n  if (b2.first) {\n    if (b->last) {\n      inst_join(b->last, b2.first);\n    } else {\n      b->first = b2.first;\n    }\n    b->last = b2.last;\n  }\n}\n\nblock block_join(block a, block b) {\n  block c = a;\n  block_append(&c, b);\n  return c;\n}\n\nint block_has_only_binders_and_imports(block binders, int bindflags) {\n  bindflags |= OP_HAS_BINDING;\n  for (inst* curr = binders.first; curr; curr = curr->next) {\n    if ((opcode_describe(curr->op)->flags & bindflags) != bindflags && curr->op != DEPS && curr->op != MODULEMETA) {\n      return 0;\n    }\n  }\n  return 1;\n}\n\nstatic int inst_is_binder(inst *i, int bindflags) {\n  return !((opcode_describe(i->op)->flags & bindflags) != bindflags && i->op != MODULEMETA);\n}\n\nint block_has_only_binders(block binders, int bindflags) {\n  bindflags |= OP_HAS_BINDING;\n  bindflags &= ~OP_BIND_WILDCARD;\n  for (inst* curr = binders.first; curr; curr = curr->next) {\n    if ((opcode_describe(curr->op)->flags & bindflags) != bindflags && curr->op != MODULEMETA) {\n      return 0;\n    }\n  }\n  return 1;\n}\n\n// Count a call site's actual params\nstatic int block_count_actuals(block b) {\n  int args = 0;\n  for (inst* i = b.first; i; i = i->next) {\n    switch (i->op) {\n    default: assert(0 && \"Unknown function type\"); break;\n    case CLOSURE_CREATE:\n    case CLOSURE_PARAM:\n    case CLOSURE_CREATE_C:\n      args++;\n      break;\n    }\n  }\n  return args;\n}\n\nstatic int block_bind_subblock_inner(int* any_unbound, block binder, block body, int bindflags, int break_distance) {\n  assert(block_is_single(binder));\n  assert((opcode_describe(binder.first->op)->flags & bindflags) == (bindflags & ~OP_BIND_WILDCARD));\n  assert(binder.first->symbol);\n  assert(binder.first->bound_by == 0 || binder.first->bound_by == binder.first);\n  assert(break_distance >= 0);\n\n  binder.first->bound_by = binder.first;\n  int nrefs = 0;\n  for (inst* i = body.first; i; i = i->next) {\n    if (i->any_unbound == 0)\n      continue;\n\n    int flags = opcode_describe(i->op)->flags;\n    if ((flags & bindflags) == (bindflags & ~OP_BIND_WILDCARD) && i->bound_by == 0 &&\n        (!strcmp(i->symbol, binder.first->symbol) ||\n         // Check for break/break2/break3; see parser.y\n         ((bindflags & OP_BIND_WILDCARD) && i->symbol[0] == '*' &&\n          break_distance <= 3 && (i->symbol[1] == '1' + break_distance) &&\n          i->symbol[2] == '\\0'))) {\n      // bind this instruction\n      if (i->nactuals == -1 || i->nactuals == binder.first->nformals) {\n        i->bound_by = binder.first;\n        nrefs++;\n      }\n    } else if ((flags & bindflags) == (bindflags & ~OP_BIND_WILDCARD) && i->bound_by != 0 &&\n               !strncmp(binder.first->symbol, \"*anonlabel\", sizeof(\"*anonlabel\") - 1) &&\n               !strncmp(i->symbol, \"*anonlabel\", sizeof(\"*anonlabel\") - 1)) {\n      // Increment the break distance required for this binder to match\n      // a break whenever we come across a STOREV of *anonlabel...\n      break_distance++;\n    }\n\n    i->any_unbound = (i->symbol && !i->bound_by);\n\n    // binding recurses into closures\n    nrefs += block_bind_subblock_inner(&i->any_unbound, binder, i->subfn, bindflags, break_distance);\n    // binding recurses into argument list\n    nrefs += block_bind_subblock_inner(&i->any_unbound, binder, i->arglist, bindflags, break_distance);\n\n    if (i->any_unbound)\n      *any_unbound = 1;\n  }\n  return nrefs;\n}\n\nstatic int block_bind_subblock(block binder, block body, int bindflags, int break_distance) {\n  int any_unbound;\n  return block_bind_subblock_inner(&any_unbound, binder, body, bindflags, break_distance);\n}\n\nstatic int block_bind_each(block binder, block body, int bindflags) {\n  assert(block_has_only_binders(binder, bindflags));\n  bindflags |= OP_HAS_BINDING;\n  int nrefs = 0;\n  for (inst* curr = binder.first; curr; curr = curr->next) {\n    nrefs += block_bind_subblock(inst_block(curr), body, bindflags, 0);\n  }\n  return nrefs;\n}\n\nstatic block block_bind(block binder, block body, int bindflags) {\n  block_bind_each(binder, body, bindflags);\n  return block_join(binder, body);\n}\n\nblock block_bind_library(block binder, block body, int bindflags, const char *libname) {\n  bindflags |= OP_HAS_BINDING;\n  int matchlen = (libname == NULL) ? 0 : strlen(libname);\n  char *matchname = jv_mem_alloc(matchlen+2+1);\n  matchname[0] = '\\0';\n  if (libname != NULL && libname[0] != '\\0') {\n    strcpy(matchname,libname);\n    strcpy(matchname+matchlen, \"::\");\n    matchlen += 2;\n  }\n  assert(block_has_only_binders(binder, bindflags));\n  for (inst *curr = binder.last; curr; curr = curr->prev) {\n    int bindflags2 = bindflags;\n    char* cname = curr->symbol;\n    char* tname = jv_mem_alloc(strlen(curr->symbol)+matchlen+1);\n    strcpy(tname, matchname);\n    strcpy(tname+matchlen, curr->symbol);\n\n    // Ew\n    if ((opcode_describe(curr->op)->flags & (OP_HAS_VARIABLE | OP_HAS_CONSTANT)))\n      bindflags2 = OP_HAS_VARIABLE | OP_HAS_BINDING;\n\n    // This mutation is ugly, even if we undo it\n    curr->symbol = tname;\n    block_bind_subblock(inst_block(curr), body, bindflags2, 0);\n    curr->symbol = cname;\n    free(tname);\n  }\n  free(matchname);\n  return body; // We don't return a join because we don't want those sticking around...\n}\n\nstatic inst* block_take_last(block* b) {\n  inst* i = b->last;\n  if (i == 0)\n    return 0;\n  if (i->prev) {\n    i->prev->next = i->next;\n    b->last = i->prev;\n    i->prev = 0;\n  } else {\n    b->first = 0;\n    b->last = 0;\n  }\n  return i;\n}\n\n// Binds a sequence of binders, which *must not* already be bound to each other,\n// to body, throwing away unreferenced defs\nblock block_bind_referenced(block binder, block body, int bindflags) {\n  assert(block_has_only_binders(binder, bindflags));\n  bindflags |= OP_HAS_BINDING;\n\n  inst* curr;\n  while ((curr = block_take_last(&binder))) {\n    block b = inst_block(curr);\n    if (block_bind_subblock(b, body, bindflags, 0) == 0) {\n      block_free(b);\n    } else {\n      body = BLOCK(b, body);\n    }\n  }\n  return body;\n}\n\nblock block_bind_self(block binder, int bindflags) {\n  assert(block_has_only_binders(binder, bindflags));\n  bindflags |= OP_HAS_BINDING;\n  block body = gen_noop();\n\n  inst* curr;\n  while ((curr = block_take_last(&binder))) {\n    block b = inst_block(curr);\n    block_bind_subblock(b, body, bindflags, 0);\n    body = BLOCK(b, body);\n  }\n  return body;\n}\n\nstatic void block_mark_referenced(block body) {\n  int saw_top = 0;\n  for (inst* i = body.last; i; i = i->prev) {\n    if (saw_top && i->bound_by == i && !i->referenced)\n      continue;\n    if (i->op == TOP) {\n      saw_top = 1;\n    }\n    if (i->bound_by) {\n      i->bound_by->referenced = 1;\n    }\n\n    block_mark_referenced(i->arglist);\n    block_mark_referenced(i->subfn);\n  }\n}\n\nblock block_drop_unreferenced(block body) {\n  block_mark_referenced(body);\n\n  block refd = gen_noop();\n  inst* curr;\n  while ((curr = block_take(&body))) {\n    if (curr->bound_by == curr && !curr->referenced) {\n      inst_free(curr);\n    } else {\n      refd = BLOCK(refd, inst_block(curr));\n    }\n  }\n  return refd;\n}\n\njv block_take_imports(block* body) {\n  jv imports = jv_array();\n\n  /* Parser should never generate TOP before imports */\n  assert(!(body->first && body->first->op == TOP && body->first->next &&\n        (body->first->next->op == MODULEMETA || body->first->next->op == DEPS)));\n\n  while (body->first && (body->first->op == MODULEMETA || body->first->op == DEPS)) {\n    inst* dep = block_take(body);\n    if (dep->op == DEPS) {\n      imports = jv_array_append(imports, jv_copy(dep->imm.constant));\n    }\n    inst_free(dep);\n  }\n  return imports;\n}\n\njv block_list_funcs(block body, int omit_underscores) {\n  jv funcs = jv_object(); // Use the keys for set semantics.\n  for (inst *pos = body.first; pos != NULL; pos = pos->next) {\n    if (pos->op == CLOSURE_CREATE || pos->op == CLOSURE_CREATE_C) {\n      if (pos->symbol != NULL && (!omit_underscores || pos->symbol[0] != '_')) {\n        funcs = jv_object_set(funcs, jv_string_fmt(\"%s/%i\", pos->symbol, pos->nformals), jv_null());\n      }\n    }\n  }\n  return jv_keys_unsorted(funcs);\n}\n\nblock gen_module(block metadata) {\n  assert(block_is_const(metadata) && block_const_kind(metadata) == JV_KIND_OBJECT);\n  inst* i = inst_new(MODULEMETA);\n  i->imm.constant = block_const(metadata);\n  if (jv_get_kind(i->imm.constant) != JV_KIND_OBJECT)\n    i->imm.constant = jv_object_set(jv_object(), jv_string(\"metadata\"), i->imm.constant);\n  block_free(metadata);\n  return inst_block(i);\n}\n\njv block_module_meta(block b) {\n  if (b.first != NULL && b.first->op == MODULEMETA)\n    return jv_copy(b.first->imm.constant);\n  return jv_null();\n}\n\nblock gen_import(const char* name, const char* as, int is_data) {\n  inst* i = inst_new(DEPS);\n  jv meta = jv_object();\n  if (as != NULL)\n    meta = jv_object_set(meta, jv_string(\"as\"), jv_string(as));\n  meta = jv_object_set(meta, jv_string(\"is_data\"), is_data ? jv_true() : jv_false());\n  meta = jv_object_set(meta, jv_string(\"relpath\"), jv_string(name));\n  i->imm.constant = meta;\n  return inst_block(i);\n}\n\nblock gen_import_meta(block import, block metadata) {\n  assert(block_is_single(import) && import.first->op == DEPS);\n  assert(block_is_const(metadata) && block_const_kind(metadata) == JV_KIND_OBJECT);\n  inst *i = import.first;\n  i->imm.constant = jv_object_merge(block_const(metadata), i->imm.constant);\n  block_free(metadata);\n  return import;\n}\n\nblock gen_function(const char* name, block formals, block body) {\n  inst* i = inst_new(CLOSURE_CREATE);\n  int nformals = 0;\n  for (inst* i = formals.last; i; i = i->prev) {\n    nformals++;\n    i->nformals = 0;\n    if (i->op == CLOSURE_PARAM_REGULAR) {\n      i->op = CLOSURE_PARAM;\n      body = gen_var_binding(gen_call(i->symbol, gen_noop()), i->symbol, body);\n    }\n    block_bind_subblock(inst_block(i), body, OP_IS_CALL_PSEUDO | OP_HAS_BINDING, 0);\n  }\n  i->subfn = body;\n  i->symbol = strdup(name);\n  i->any_unbound = -1;\n  i->nformals = nformals;\n  i->arglist = formals;\n  block b = inst_block(i);\n  block_bind_subblock(b, b, OP_IS_CALL_PSEUDO | OP_HAS_BINDING, 0);\n  return b;\n}\n\nblock gen_param_regular(const char* name) {\n  return gen_op_unbound(CLOSURE_PARAM_REGULAR, name);\n}\n\nblock gen_param(const char* name) {\n  return gen_op_unbound(CLOSURE_PARAM, name);\n}\n\nblock gen_lambda(block body) {\n  return gen_function(\"@lambda\", gen_noop(), body);\n}\n\nblock gen_call(const char* name, block args) {\n  block b = gen_op_unbound(CALL_JQ, name);\n  b.first->arglist = args;\n  b.first->nactuals = block_count_actuals(b.first->arglist);\n  return b;\n}\n\nblock gen_subexp(block a) {\n  if (block_is_noop(a)) {\n    return gen_op_simple(DUP);\n  }\n  if (block_is_single(a) && a.first->op == LOADK) {\n    jv c = block_const(a);\n    block_free(a);\n    return gen_op_pushk_under(c);\n  }\n  return BLOCK(gen_op_simple(SUBEXP_BEGIN), a, gen_op_simple(SUBEXP_END));\n}\n\nblock gen_both(block a, block b) {\n  block jump = gen_op_targetlater(JUMP);\n  block fork = gen_op_target(FORK, jump);\n  block c = BLOCK(fork, a, jump, b);\n  inst_set_target(jump, c);\n  return c;\n}\n\nblock gen_const_object(block expr) {\n  int is_const = 1;\n  jv o = jv_object();\n  jv k = jv_null();\n  jv v = jv_null();\n  for (inst *i = expr.first; i; i = i->next) {\n    if (i->op == PUSHK_UNDER) {\n      k = jv_copy(i->imm.constant);\n      i = i->next;\n    } else if (i->op != SUBEXP_BEGIN ||\n        i->next == NULL ||\n        i->next->op != LOADK ||\n        i->next->next == NULL ||\n        i->next->next->op != SUBEXP_END) {\n      is_const = 0;\n      break;\n    } else {\n      k = jv_copy(i->next->imm.constant);\n      i = i->next->next->next;\n    }\n    if (i != NULL && i->op == PUSHK_UNDER) {\n      v = jv_copy(i->imm.constant);\n      i = i->next;\n    } else if (i == NULL ||\n        i->op != SUBEXP_BEGIN ||\n        i->next == NULL ||\n        i->next->op != LOADK ||\n        i->next->next == NULL ||\n        i->next->next->op != SUBEXP_END) {\n      is_const = 0;\n      break;\n    } else {\n      v = jv_copy(i->next->imm.constant);\n      i = i->next->next->next;\n    }\n    if (i == NULL || i->op != INSERT) {\n      is_const = 0;\n      break;\n    }\n    if (jv_get_kind(k) != JV_KIND_STRING) {\n      is_const = 0;\n      break;\n    }\n    o = jv_object_set(o, k, v);\n    k = jv_null();\n    v = jv_null();\n  }\n  if (!is_const) {\n    jv_free(o);\n    jv_free(k);\n    jv_free(v);\n    block b = {0,0};\n    return b;\n  }\n  block_free(expr);\n  return gen_const(o);\n}\n\nstatic block gen_const_array(block expr) {\n  /*\n   * An expr of all constant elements looks like this:\n   *\n   * 0009 FORK 0027\n   * 0011 FORK 0023\n   * 0013 FORK 0019\n   * 0015 LOADK 1\n   * 0017 JUMP 0021\n   * 0019 LOADK 2\n   * 0021 JUMP 0025\n   * 0023 LOADK 3\n   * 0025 JUMP 0029\n   * 0027 LOADK 4\n   *\n   * That's: N-1 commas for N elements, N LOADKs, and a JUMP between\n   * every LOADK.  The sequence ends in a LOADK.  Any deviation and it's\n   * not a list of constants.\n   *\n   * Here we check for this pattern almost exactly.  We don't check that\n   * the targets of the FORK and JUMP instructions are in the right\n   * sequence.\n   */\n  int all_const = 1;\n  int commas = 0;\n  int normal = 1;\n  jv a = jv_array();\n  for (inst *i = expr.first; i; i = i->next) {\n    if (i->op == FORK) {\n      commas++;\n      if (i->imm.target == NULL || i->imm.target->op != JUMP ||\n          jv_array_length(jv_copy(a)) > 0) {\n        normal = 0;\n        break;\n      }\n    } else if (all_const && i->op == LOADK) {\n      if (i->next != NULL && i->next->op != JUMP) {\n        normal = 0;\n        break;\n      }\n      a = jv_array_append(a, jv_copy(i->imm.constant));\n    } else if (i->op != JUMP || i->imm.target == NULL ||\n               i->imm.target->op != LOADK) {\n      all_const = 0;\n    }\n  }\n\n  if (all_const && normal &&\n      (expr.last == NULL || expr.last->op == LOADK) &&\n      jv_array_length(jv_copy(a)) == commas + 1) {\n    block_free(expr);\n    return gen_const(a);\n  }\n\n  jv_free(a);\n  block b = {0,0};\n  return b;\n}\n\nblock gen_collect(block expr) {\n  block const_array = gen_const_array(expr);\n  if (const_array.first != NULL)\n    return const_array;\n\n  block array_var = gen_op_var_fresh(STOREV, \"collect\");\n  block c = BLOCK(gen_op_simple(DUP), gen_const(jv_array()), array_var);\n\n  block tail = BLOCK(gen_op_bound(APPEND, array_var),\n                     gen_op_simple(BACKTRACK));\n\n  return BLOCK(c,\n               gen_op_target(FORK, tail),\n               expr,\n               tail,\n               gen_op_bound(LOADVN, array_var));\n}\n\nstatic block bind_matcher(block matcher, block body) {\n  // cannot call block_bind(matcher, body) because that requires\n  // block_has_only_binders(matcher), which is not true here as matchers\n  // may also contain code to extract the correct elements\n  for (inst* i = matcher.first; i; i = i->next) {\n    if ((i->op == STOREV || i->op == STOREVN) && !i->bound_by)\n      block_bind_subblock(inst_block(i), body, OP_HAS_VARIABLE, 0);\n  }\n  return BLOCK(matcher, body);\n}\n\n\n// Extract destructuring var names from the block\n// *vars should be a jv_object (for set semantics)\nstatic void block_get_unbound_vars(block b, jv *vars) {\n  assert(vars != NULL);\n  assert(jv_get_kind(*vars) == JV_KIND_OBJECT);\n  for (inst* i = b.first; i; i = i->next) {\n    if (i->subfn.first) {\n      block_get_unbound_vars(i->subfn, vars);\n      continue;\n    }\n    if ((i->op == STOREV || i->op == STOREVN) && i->bound_by == NULL) {\n      *vars = jv_object_set(*vars, jv_string(i->symbol), jv_true());\n    }\n  }\n}\n\n/* Build wrappers around destructuring matchers so that we can chain them\n * when we have errors.  The approach is as follows:\n * DESTRUCTURE_ALT NEXT_MATCHER (unless last matcher)\n * existing_matcher_block\n * JUMP BODY\n */\nstatic block bind_alternation_matchers(block matchers, block body) {\n  block preamble = {0};\n  block altmatchers = {0};\n  block mb = {0};\n  block final_matcher = matchers;\n\n  // Pass through the matchers to find all destructured names.\n  while (final_matcher.first && final_matcher.first->op == DESTRUCTURE_ALT) {\n    block_append(&altmatchers, inst_block(block_take(&final_matcher)));\n  }\n\n  // We don't have any alternations here, so we can use the simplest case.\n  if (altmatchers.first == NULL) {\n    return bind_matcher(final_matcher, body);\n  }\n\n  // Collect var names\n  jv all_vars = jv_object();\n  block_get_unbound_vars(altmatchers, &all_vars);\n  block_get_unbound_vars(final_matcher, &all_vars);\n\n  // We need a preamble of STOREVs to which to bind the matchers and the body.\n  jv_object_keys_foreach(all_vars, key) {\n    preamble = BLOCK(preamble,\n                     gen_op_simple(DUP),\n                     gen_const(jv_null()),\n                     gen_op_unbound(STOREV, jv_string_value(key)));\n    jv_free(key);\n  }\n  jv_free(all_vars);\n\n  // Now we build each matcher in turn\n  for (inst *i = altmatchers.first; i; i = i->next) {\n    block submatcher = i->subfn;\n\n    // If we're successful, jump to the end of the matchers\n    submatcher = BLOCK(submatcher, gen_op_target(JUMP, final_matcher));\n\n    // DESTRUCTURE_ALT to the end of this submatcher so we can skip to the next one on error\n    mb = BLOCK(mb, gen_op_target(DESTRUCTURE_ALT, submatcher), submatcher);\n\n    // We're done with this inst and we don't want it anymore\n    // But we can't let it free the submatcher block.\n    i->subfn.first = i->subfn.last = NULL;\n  }\n  // We're done with these insts now.\n  block_free(altmatchers);\n\n  return bind_matcher(preamble, BLOCK(mb, final_matcher, body));\n}\n\nblock gen_reduce(block source, block matcher, block init, block body) {\n  block res_var = gen_op_var_fresh(STOREV, \"reduce\");\n  block loop = BLOCK(gen_op_simple(DUPN),\n                     source,\n                     bind_alternation_matchers(matcher,\n                                  BLOCK(gen_op_bound(LOADVN, res_var),\n                                        body,\n                                        gen_op_bound(STOREV, res_var))),\n                     gen_op_simple(BACKTRACK));\n  return BLOCK(gen_op_simple(DUP),\n               init,\n               res_var,\n               gen_op_target(FORK, loop),\n               loop,\n               gen_op_bound(LOADVN, res_var));\n}\n\nblock gen_foreach(block source, block matcher, block init, block update, block extract) {\n  block state_var = gen_op_var_fresh(STOREV, \"foreach\");\n  return BLOCK(gen_op_simple(DUP),\n               init,\n               state_var,\n               gen_op_simple(DUP),\n               // get a value from the source expression:\n               source,\n               // destructure the value into variable(s) for all the code\n               // in the body to see\n               bind_alternation_matchers(matcher,\n                            // load the loop state variable\n                            BLOCK(gen_op_bound(LOADVN, state_var),\n                                  // generate updated state\n                                  update,\n                                  // save the updated state for value extraction\n                                  gen_op_simple(DUP),\n                                  // save new state\n                                  gen_op_bound(STOREV, state_var),\n                                  // extract an output...\n                                  extract)));\n}\n\nblock gen_definedor(block a, block b) {\n  // var found := false\n  block found_var = gen_op_var_fresh(STOREV, \"found\");\n  block init = BLOCK(gen_op_simple(DUP), gen_const(jv_false()), found_var);\n\n  // if found, backtrack. Otherwise execute b\n  block backtrack = gen_op_simple(BACKTRACK);\n  block tail = BLOCK(gen_op_simple(DUP),\n                     gen_op_bound(LOADV, found_var),\n                     gen_op_target(JUMP_F, backtrack),\n                     backtrack,\n                     gen_op_simple(POP),\n                     b);\n\n  // try again\n  block if_notfound = gen_op_simple(BACKTRACK);\n\n  // found := true, produce result\n  block if_found = BLOCK(gen_op_simple(DUP),\n                         gen_const(jv_true()),\n                         gen_op_bound(STOREV, found_var),\n                         gen_op_target(JUMP, tail));\n\n  return BLOCK(init,\n               gen_op_target(FORK, if_notfound),\n               a,\n               gen_op_target(JUMP_F, if_found),\n               if_found,\n               if_notfound,\n               tail);\n}\n\nint block_has_main(block top) {\n  for (inst *c = top.first; c; c = c->next) {\n    if (c->op == TOP)\n      return 1;\n  }\n  return 0;\n}\n\nint block_is_funcdef(block b) {\n  if (b.first != NULL && b.first->op == CLOSURE_CREATE)\n    return 1;\n  return 0;\n}\n\nblock gen_condbranch(block iftrue, block iffalse) {\n  iftrue = BLOCK(iftrue, gen_op_target(JUMP, iffalse));\n  return BLOCK(gen_op_target(JUMP_F, iftrue), iftrue, iffalse);\n}\n\nblock gen_and(block a, block b) {\n  // a and b = if a then (if b then true else false) else false\n  return BLOCK(gen_op_simple(DUP), a,\n               gen_condbranch(BLOCK(gen_op_simple(POP),\n                                    b,\n                                    gen_condbranch(gen_const(jv_true()),\n                                                   gen_const(jv_false()))),\n                              BLOCK(gen_op_simple(POP), gen_const(jv_false()))));\n}\n\nblock gen_or(block a, block b) {\n  // a or b = if a then true else (if b then true else false)\n  return BLOCK(gen_op_simple(DUP), a,\n               gen_condbranch(BLOCK(gen_op_simple(POP), gen_const(jv_true())),\n                              BLOCK(gen_op_simple(POP),\n                                    b,\n                                    gen_condbranch(gen_const(jv_true()),\n                                                   gen_const(jv_false())))));\n}\n\nblock gen_destructure_alt(block matcher) {\n  for (inst *i = matcher.first; i; i = i->next) {\n    if (i->op == STOREV) {\n      i->op = STOREVN;\n    }\n  }\n  inst* i = inst_new(DESTRUCTURE_ALT);\n  i->subfn = matcher;\n  return inst_block(i);\n}\n\nblock gen_var_binding(block var, const char* name, block body) {\n  return gen_destructure(var, gen_op_unbound(STOREV, name), body);\n}\n\nblock gen_array_matcher(block left, block curr) {\n  int index;\n  if (block_is_noop(left))\n    index = 0;\n  else {\n    // `left` was returned by this function, so the third inst is the\n    // constant containing the previously used index\n    assert(left.first->op == DUP);\n    assert(left.first->next != NULL);\n    inst *i = NULL;\n    if (left.first->next->op == PUSHK_UNDER) {\n      i = left.first->next;\n    } else {\n      assert(left.first->next->op == SUBEXP_BEGIN);\n      assert(left.first->next->next->op == LOADK);\n      i = left.first->next->next;\n    }\n    index = 1 + (int) jv_number_value(i->imm.constant);\n  }\n\n  // `left` goes at the end so that the const index is in a predictable place\n  return BLOCK(gen_op_simple(DUP), gen_subexp(gen_const(jv_number(index))),\n               gen_op_simple(INDEX), curr, left);\n}\n\nblock gen_object_matcher(block name, block curr) {\n  return BLOCK(gen_op_simple(DUP), gen_subexp(name), gen_op_simple(INDEX),\n               curr);\n}\n\nblock gen_destructure(block var, block matchers, block body) {\n  // var bindings can be added after coding the program; leave the TOP first.\n  block top = gen_noop();\n  if (body.first && body.first->op == TOP)\n    top = inst_block(block_take(&body));\n\n  if (matchers.first && matchers.first->op == DESTRUCTURE_ALT) {\n    block_append(&var, gen_op_simple(DUP));\n  } else {\n    top = BLOCK(top, gen_op_simple(DUP));\n  }\n\n  return BLOCK(top, gen_subexp(var), gen_op_simple(POP), bind_alternation_matchers(matchers, body));\n}\n\n// Like gen_var_binding(), but bind `break`'s wildcard unbound variable\nstatic block gen_wildvar_binding(block var, const char* name, block body) {\n  return BLOCK(gen_op_simple(DUP), var,\n               block_bind(gen_op_unbound(STOREV, name),\n                          body, OP_HAS_VARIABLE | OP_BIND_WILDCARD));\n}\n\nblock gen_cond(block cond, block iftrue, block iffalse) {\n  return BLOCK(gen_op_simple(DUP), BLOCK(gen_subexp(cond), gen_op_simple(POP)),\n               gen_condbranch(BLOCK(gen_op_simple(POP), iftrue),\n                              BLOCK(gen_op_simple(POP), iffalse)));\n}\n\nblock gen_try(block exp, block handler) {\n  /*\n   * Produce:\n   *\n   *  TRY_BEGIN handler\n   *  <exp>\n   *  TRY_END\n   *  JUMP past_handler\n   *  handler: <handler>\n   *  past_handler:\n   *\n   * If <exp> backtracks then TRY_BEGIN will backtrack.\n   *\n   * If <exp> produces a value then we'll execute whatever bytecode follows\n   * this sequence.  If that code raises an exception, then TRY_END will wrap\n   * and re-raise that exception, and TRY_BEGIN will unwrap and re-raise the\n   * exception (see jq_next()).\n   *\n   * If <exp> raises then the TRY_BEGIN will see a non-wrapped exception and\n   * will jump to the handler (note the TRY_END will not execute in this case),\n   * and if the handler produces any values, then we'll execute whatever\n   * bytecode follows this sequence.  Note that TRY_END will not execute in\n   * this case, so if the handler raises an exception, or code past the handler\n   * raises an exception, then that exception won't be wrapped and re-raised,\n   * and the TRY_BEGIN will not catch it because it does not stack_save() when\n   * it branches to the handler.\n   */\n\n  if (block_is_noop(handler))\n    handler = BLOCK(gen_op_simple(DUP), gen_op_simple(POP));\n\n  block jump = gen_op_target(JUMP, handler);\n  return BLOCK(gen_op_target(TRY_BEGIN, jump), exp, gen_op_simple(TRY_END),\n               jump, handler);\n}\n\nblock gen_label(const char *label, block exp) {\n  block cond = gen_call(\"_equal\",\n                        BLOCK(gen_lambda(gen_noop()),\n                              gen_lambda(gen_op_unbound(LOADV, label))));\n  return gen_wildvar_binding(gen_op_simple(GENLABEL), label,\n                             BLOCK(gen_op_simple(POP),\n                                   // try exp catch if . == $label\n                                   //               then empty\n                                   //               else error end\n                                   //\n                                   // Can't use gen_binop(), as that's firmly\n                                   // stuck in parser.y as it refers to things\n                                   // like EQ.\n                                   gen_try(exp,\n                                           gen_cond(cond,\n                                                    gen_op_simple(BACKTRACK),\n                                                    gen_call(\"error\", gen_noop())))));\n}\n\nblock gen_cbinding(const struct cfunction* cfunctions, int ncfunctions, block code) {\n  for (int cfunc=0; cfunc<ncfunctions; cfunc++) {\n    inst* i = inst_new(CLOSURE_CREATE_C);\n    i->imm.cfunc = &cfunctions[cfunc];\n    i->symbol = strdup(cfunctions[cfunc].name);\n    i->nformals = cfunctions[cfunc].nargs - 1;\n    i->any_unbound = 0;\n    code = BLOCK(inst_block(i), code);\n  }\n  return code;\n}\n\nstatic uint16_t nesting_level(struct bytecode* bc, inst* target) {\n  uint16_t level = 0;\n  assert(bc && target && target->compiled);\n  while (bc && target->compiled != bc) {\n    level++;\n    bc = bc->parent;\n  }\n  assert(bc && bc == target->compiled);\n  return level;\n}\n\nstatic int count_cfunctions(block b) {\n  int n = 0;\n  for (inst* i = b.first; i; i = i->next) {\n    if (i->op == CLOSURE_CREATE_C) n++;\n    n += count_cfunctions(i->subfn);\n  }\n  return n;\n}\n\n#ifndef WIN32\nextern char **environ;\n#endif\n\nstatic jv\nmake_env(jv env)\n{\n  if (jv_is_valid(env))\n    return jv_copy(env);\n  jv r = jv_object();\n  if (environ == NULL)\n    return r;\n  for (size_t i = 0; environ[i] != NULL; i++) {\n    const char *eq;\n\n    if ((eq = strchr(environ[i], '=')) == NULL)\n      r = jv_object_delete(r, jv_string(environ[i]));\n    else\n      r = jv_object_set(r, jv_string_sized(environ[i], eq - environ[i]), jv_string(eq + 1));\n  }\n  return jv_copy(r);\n}\n\n// Expands call instructions into a calling sequence\nstatic int expand_call_arglist(block* b, jv args, jv *env) {\n  int errors = 0;\n  block ret = gen_noop();\n  for (inst* curr; (curr = block_take(b));) {\n    if (opcode_describe(curr->op)->flags & OP_HAS_BINDING) {\n      if (!curr->bound_by && curr->op == LOADV && strcmp(curr->symbol, \"ENV\") == 0) {\n        curr->op = LOADK;\n        *env = curr->imm.constant = make_env(*env);\n      } else if (!curr->bound_by && curr->op == LOADV && jv_object_has(jv_copy(args), jv_string(curr->symbol))) {\n        curr->op = LOADK;\n        curr->imm.constant = jv_object_get(jv_copy(args), jv_string(curr->symbol));\n      } else if (!curr->bound_by) {\n        if (curr->symbol[0] == '*' && curr->symbol[1] >= '1' && curr->symbol[1] <= '3' && curr->symbol[2] == '\\0')\n          locfile_locate(curr->locfile, curr->source, \"jq: error: break used outside labeled control structure\");\n        else if (curr->op == LOADV)\n          locfile_locate(curr->locfile, curr->source, \"jq: error: $%s is not defined\", curr->symbol);\n        else\n          locfile_locate(curr->locfile, curr->source, \"jq: error: %s/%d is not defined\", curr->symbol, curr->nactuals);\n        errors++;\n        // don't process this instruction if it's not well-defined\n        ret = BLOCK(ret, inst_block(curr));\n        continue;\n      }\n    }\n\n    block prelude = gen_noop();\n    if (curr->op == CALL_JQ) {\n      int actual_args = 0, desired_args = 0;\n      // We expand the argument list as a series of instructions\n      switch (curr->bound_by->op) {\n      default: assert(0 && \"Unknown function type\"); break;\n      case CLOSURE_CREATE:\n      case CLOSURE_PARAM: {\n        block callargs = gen_noop();\n        for (inst* i; (i = block_take(&curr->arglist));) {\n          assert(opcode_describe(i->op)->flags & OP_IS_CALL_PSEUDO);\n          block b = inst_block(i);\n          switch (i->op) {\n          default: assert(0 && \"Unknown type of parameter\"); break;\n          case CLOSURE_REF:\n            block_append(&callargs, b);\n            break;\n          case CLOSURE_CREATE:\n            block_append(&prelude, b);\n            block_append(&callargs, gen_op_bound(CLOSURE_REF, b));\n            break;\n          }\n          actual_args++;\n        }\n        curr->imm.intval = actual_args;\n        curr->arglist = callargs;\n\n        if (curr->bound_by->op == CLOSURE_CREATE) {\n          for (inst* i = curr->bound_by->arglist.first; i; i = i->next) {\n            assert(i->op == CLOSURE_PARAM);\n            desired_args++;\n          }\n        }\n        break;\n      }\n\n      case CLOSURE_CREATE_C: {\n        for (inst* i; (i = block_take(&curr->arglist)); ) {\n          assert(i->op == CLOSURE_CREATE); // FIXME\n          block body = i->subfn;\n          i->subfn = gen_noop();\n          inst_free(i);\n          // arguments should be pushed in reverse order, prepend them to prelude\n          errors += expand_call_arglist(&body, args, env);\n          prelude = BLOCK(gen_subexp(body), prelude);\n          actual_args++;\n        }\n        assert(curr->op == CALL_JQ);\n        curr->op = CALL_BUILTIN;\n        curr->imm.intval = actual_args + 1 /* include the implicit input in arg count */;\n        assert(curr->bound_by->op == CLOSURE_CREATE_C);\n        desired_args = curr->bound_by->imm.cfunc->nargs - 1;\n        assert(!curr->arglist.first);\n        break;\n      }\n      }\n\n      assert(actual_args == desired_args); // because now handle this above\n    }\n    ret = BLOCK(ret, prelude, inst_block(curr));\n  }\n  *b = ret;\n  return errors;\n}\n\nstatic int compile(struct bytecode* bc, block b, struct locfile* lf, jv args, jv *env) {\n  int errors = 0;\n  int pos = 0;\n  int var_frame_idx = 0;\n  bc->nsubfunctions = 0;\n  errors += expand_call_arglist(&b, args, env);\n  b = BLOCK(b, gen_op_simple(RET));\n  jv localnames = jv_array();\n  for (inst* curr = b.first; curr; curr = curr->next) {\n    if (!curr->next) assert(curr == b.last);\n    int length = opcode_describe(curr->op)->length;\n    if (curr->op == CALL_JQ) {\n      for (inst* arg = curr->arglist.first; arg; arg = arg->next) {\n        length += 2;\n      }\n    }\n    pos += length;\n    curr->bytecode_pos = pos;\n    curr->compiled = bc;\n\n    assert(curr->op != CLOSURE_REF && curr->op != CLOSURE_PARAM);\n\n    if ((opcode_describe(curr->op)->flags & OP_HAS_VARIABLE) &&\n        curr->bound_by == curr) {\n      curr->imm.intval = var_frame_idx++;\n      localnames = jv_array_append(localnames, jv_string(curr->symbol));\n    }\n\n    if (curr->op == CLOSURE_CREATE) {\n      assert(curr->bound_by == curr);\n      // Prevent subfunction index from overflowing into ARG_NEWCLOSURE flag\n      if (bc->nsubfunctions >= ARG_NEWCLOSURE) {\n        locfile_locate(lf, curr->source,\n            \"too many function parameters or local function definitions (max %d)\", ARG_NEWCLOSURE - 1);\n        errors++;\n        break;\n      }\n      curr->imm.intval = bc->nsubfunctions++;\n    }\n    if (curr->op == CLOSURE_CREATE_C) {\n      assert(curr->bound_by == curr);\n      int idx = bc->globals->ncfunctions++;\n      bc->globals->cfunc_names = jv_array_append(bc->globals->cfunc_names,\n                                                 jv_string(curr->symbol));\n      bc->globals->cfunctions[idx] = *curr->imm.cfunc;\n      curr->imm.intval = idx;\n    }\n  }\n  if (pos > 0xFFFF) {\n    // too long for program counter to fit in uint16_t\n    locfile_locate(lf, UNKNOWN_LOCATION,\n        \"function compiled to %d bytes which is too long\", pos);\n    errors++;\n  }\n  bc->codelen = pos;\n  bc->debuginfo = jv_object_set(bc->debuginfo, jv_string(\"locals\"), localnames);\n  if (bc->nsubfunctions && !errors) {\n    bc->subfunctions = jv_mem_calloc(bc->nsubfunctions, sizeof(struct bytecode*));\n    for (inst* curr = b.first; curr; curr = curr->next) {\n      if (curr->op == CLOSURE_CREATE) {\n        struct bytecode* subfn = jv_mem_alloc(sizeof(struct bytecode));\n        bc->subfunctions[curr->imm.intval] = subfn;\n        subfn->globals = bc->globals;\n        subfn->parent = bc;\n        subfn->nclosures = 0;\n        subfn->debuginfo = jv_object_set(jv_object(), jv_string(\"name\"), jv_string(curr->symbol));\n        jv params = jv_array();\n        for (inst* param = curr->arglist.first; param; param = param->next) {\n          assert(param->op == CLOSURE_PARAM);\n          assert(param->bound_by == param);\n          // Prevent closure index from overflowing into ARG_NEWCLOSURE flag\n          if (subfn->nclosures >= ARG_NEWCLOSURE) {\n            locfile_locate(lf, curr->source,\n                \"function has too many parameters (max %d)\", ARG_NEWCLOSURE - 1);\n            errors++;\n            break;\n          }\n          param->imm.intval = subfn->nclosures++;\n          param->compiled = subfn;\n          params = jv_array_append(params, jv_string(param->symbol));\n        }\n        subfn->debuginfo = jv_object_set(subfn->debuginfo, jv_string(\"params\"), params);\n        errors += compile(subfn, curr->subfn, lf, args, env);\n        curr->subfn = gen_noop();\n      }\n    }\n  } else {\n    bc->nsubfunctions = 0;\n    bc->subfunctions = 0;\n  }\n  uint16_t* code = jv_mem_calloc(bc->codelen, sizeof(uint16_t));\n  bc->code = code;\n  pos = 0;\n  jv constant_pool = jv_array();\n  int maxvar = -1;\n  if (!errors) for (inst* curr = b.first; curr; curr = curr->next) {\n    const struct opcode_description* op = opcode_describe(curr->op);\n    if (op->length == 0)\n      continue;\n    code[pos++] = curr->op;\n    assert(curr->op != CLOSURE_REF && curr->op != CLOSURE_PARAM);\n    if (curr->op == CALL_BUILTIN) {\n      assert(curr->bound_by->op == CLOSURE_CREATE_C);\n      assert(!curr->arglist.first);\n      code[pos++] = (uint16_t)curr->imm.intval;\n      code[pos++] = curr->bound_by->imm.intval;\n    } else if (curr->op == CALL_JQ) {\n      assert(curr->bound_by->op == CLOSURE_CREATE ||\n             curr->bound_by->op == CLOSURE_PARAM);\n      code[pos++] = (uint16_t)curr->imm.intval;\n      code[pos++] = nesting_level(bc, curr->bound_by);\n      code[pos++] = curr->bound_by->imm.intval |\n        (curr->bound_by->op == CLOSURE_CREATE ? ARG_NEWCLOSURE : 0);\n      for (inst* arg = curr->arglist.first; arg; arg = arg->next) {\n        assert(arg->op == CLOSURE_REF && arg->bound_by->op == CLOSURE_CREATE);\n        code[pos++] = nesting_level(bc, arg->bound_by);\n        code[pos++] = arg->bound_by->imm.intval | ARG_NEWCLOSURE;\n      }\n    } else if ((op->flags & OP_HAS_CONSTANT) && (op->flags & OP_HAS_VARIABLE)) {\n      // STORE_GLOBAL: constant global, basically\n      code[pos++] = jv_array_length(jv_copy(constant_pool));\n      constant_pool = jv_array_append(constant_pool, jv_copy(curr->imm.constant));\n      code[pos++] = nesting_level(bc, curr->bound_by);\n      uint16_t var = (uint16_t)curr->bound_by->imm.intval;\n      code[pos++] = var;\n      if (var > maxvar) maxvar = var;\n    } else if (op->flags & OP_HAS_CONSTANT) {\n      code[pos++] = jv_array_length(jv_copy(constant_pool));\n      constant_pool = jv_array_append(constant_pool, jv_copy(curr->imm.constant));\n    } else if (op->flags & OP_HAS_VARIABLE) {\n      code[pos++] = nesting_level(bc, curr->bound_by);\n      uint16_t var = (uint16_t)curr->bound_by->imm.intval;\n      code[pos++] = var;\n      if (var > maxvar) maxvar = var;\n    } else if (op->flags & OP_HAS_BRANCH) {\n      assert(curr->imm.target->bytecode_pos != -1);\n      assert(curr->imm.target->bytecode_pos > pos); // only forward branches\n      code[pos] = curr->imm.target->bytecode_pos - (pos + 1);\n      pos++;\n    } else if (op->length > 1) {\n      assert(0 && \"codegen not implemented for this operation\");\n    }\n  }\n  bc->constants = constant_pool;\n  bc->nlocals = maxvar + 2; // FIXME: frames of size zero?\n  block_free(b);\n  return errors;\n}\n\nint block_compile(block b, struct bytecode** out, struct locfile* lf, jv args) {\n  struct bytecode* bc = jv_mem_alloc(sizeof(struct bytecode));\n  bc->parent = 0;\n  bc->nclosures = 0;\n  bc->globals = jv_mem_alloc(sizeof(struct symbol_table));\n  int ncfunc = count_cfunctions(b);\n  bc->globals->ncfunctions = 0;\n  bc->globals->cfunctions = jv_mem_calloc(MAX(ncfunc, 1), sizeof(struct cfunction));\n  bc->globals->cfunc_names = jv_array();\n  bc->debuginfo = jv_object_set(jv_object(), jv_string(\"name\"), jv_null());\n  jv env = jv_invalid();\n  int nerrors = compile(bc, b, lf, args, &env);\n  jv_free(args);\n  jv_free(env);\n  assert(bc->globals->ncfunctions == ncfunc);\n  if (nerrors > 0) {\n    bytecode_free(bc);\n    *out = 0;\n  } else {\n    *out = bc;\n  }\n  return nerrors;\n}\n\nvoid block_free(block b) {\n  struct inst* next;\n  for (struct inst* curr = b.first; curr; curr = next) {\n    next = curr->next;\n    inst_free(curr);\n  }\n}\n"
  },
  {
    "path": "src/compile.h",
    "content": "#ifndef COMPILE_H\n#define COMPILE_H\n#include <stdint.h>\n#include \"jv.h\"\n#include \"bytecode.h\"\n#include \"locfile.h\"\n\nstruct inst;\ntypedef struct inst inst;\n\n\ntypedef struct block {\n  inst* first;\n  inst* last;\n} block;\n\nblock gen_location(location, struct locfile*, block);\n\nblock gen_noop(void);\nint block_is_noop(block b);\nblock gen_op_simple(opcode op);\nblock gen_error(jv constant);\nblock gen_const(jv constant);\nblock gen_const_global(jv constant, const char *name);\nint block_is_const(block b);\njv_kind block_const_kind(block b);\njv block_const(block b);\nblock gen_op_target(opcode op, block target);\nblock gen_op_unbound(opcode op, const char* name);\nblock gen_op_bound(opcode op, block binder);\nblock gen_op_var_fresh(opcode op, const char* name);\nblock gen_op_pushk_under(jv constant);\n\nblock gen_module(block metadata);\njv block_module_meta(block b);\nblock gen_import(const char* name, const char *as, int is_data);\nblock gen_import_meta(block import, block metadata);\nblock gen_function(const char* name, block formals, block body);\nblock gen_param_regular(const char* name);\nblock gen_param(const char* name);\nblock gen_lambda(block body);\nblock gen_call(const char* name, block body);\nblock gen_subexp(block a);\nblock gen_both(block a, block b);\nblock gen_const_object(block expr);\nblock gen_collect(block expr);\nblock gen_reduce(block source, block matcher, block init, block body);\nblock gen_foreach(block source, block matcher, block init, block update, block extract);\nblock gen_definedor(block a, block b);\nblock gen_condbranch(block iftrue, block iffalse);\nblock gen_and(block a, block b);\nblock gen_or(block a, block b);\nblock gen_dictpair(block k, block v);\n\nblock gen_var_binding(block var, const char* name, block body);\nblock gen_array_matcher(block left, block curr);\nblock gen_object_matcher(block name, block curr);\nblock gen_destructure(block var, block matcher, block body);\nblock gen_destructure_alt(block matcher);\n\nblock gen_cond(block cond, block iftrue, block iffalse);\nblock gen_try(block exp, block handler);\nblock gen_label(const char *label, block exp);\n\nblock gen_cbinding(const struct cfunction* functions, int nfunctions, block b);\n\nvoid block_append(block* b, block b2);\nblock block_join(block a, block b);\nint block_has_only_binders_and_imports(block, int bindflags);\nint block_has_only_binders(block, int bindflags);\nint block_has_main(block);\nint block_is_funcdef(block b);\nint block_is_single(block b);\nblock block_bind_library(block binder, block body, int bindflags, const char* libname);\nblock block_bind_referenced(block binder, block body, int bindflags);\nblock block_bind_self(block binder, int bindflags);\nblock block_drop_unreferenced(block body);\n\njv block_take_imports(block* body);\njv block_list_funcs(block body, int omit_underscores);\n\nint block_compile(block, struct bytecode**, struct locfile*, jv);\n\nvoid block_free(block);\n\n\n\n// Here's some horrible preprocessor gunk so that code\n// sequences can be constructed as BLOCK(block1, block2, block3)\n\n#define BLOCK_1(b1) (b1)\n#define BLOCK_2(b1,b2) (block_join((b1),(b2)))\n#define BLOCK_3(b1,b2,b3) (block_join(BLOCK_2(b1,b2),(b3)))\n#define BLOCK_4(b1,b2,b3,b4) (block_join(BLOCK_3(b1,b2,b3),(b4)))\n#define BLOCK_5(b1,b2,b3,b4,b5) (block_join(BLOCK_4(b1,b2,b3,b4),(b5)))\n#define BLOCK_6(b1,b2,b3,b4,b5,b6) (block_join(BLOCK_5(b1,b2,b3,b4,b5),(b6)))\n#define BLOCK_7(b1,b2,b3,b4,b5,b6,b7) (block_join(BLOCK_6(b1,b2,b3,b4,b5,b6),(b7)))\n#define BLOCK_8(b1,b2,b3,b4,b5,b6,b7,b8) (block_join(BLOCK_7(b1,b2,b3,b4,b5,b6,b7),(b8)))\n\n#define BLOCK_IDX(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME\n#define BLOCK(...) \\\n  BLOCK_IDX(__VA_ARGS__, BLOCK_8, BLOCK_7, BLOCK_6, BLOCK_5, BLOCK_4, BLOCK_3, BLOCK_2, BLOCK_1)(__VA_ARGS__)\n\n\n#endif\n"
  },
  {
    "path": "src/exec_stack.h",
    "content": "#ifndef EXEC_STACK_H\n#define EXEC_STACK_H\n#include <stddef.h>\n#include <stdint.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"jv_alloc.h\"\n\n/*\n * The stack is a directed forest of variably sized blocks. Each block has a\n * \"next\" block which is at a higher memory address, or 0 if the block has no\n * \"next\" block. More than one block may have no \"next\" block. A block may be\n * the \"next\" block of more than one other block. Pushed blocks are added at\n * the low-address end of the stack.\n *\n * Stack pointers are negative integers that are offsets relative to \"mem_end\",\n * the end of the allocated region. The stack \"bound\" is the stack pointer of\n * the last block that would be able to fit in the currently allocated region.\n * The stack \"limit\" is the stack pointer of the last block currently in the\n * stack. The stack pointer of the \"next\" block is stored directly below each\n * block.\n *\n *                      <- mem_end = 0x100\n * 0xF8  +------------+\n * 0xF0  |            |\n * 0xE8  +------------+ <- stack_ptr1 = -0x18\n * 0xE0  next = 0\n * 0xD8  +------------+\n * 0xD0  |            |\n * 0xC8  |            |\n * 0xC0  +------------+ <- stack_ptr2 = limit = -0x40\n * 0xB8  next = -0x18\n * 0xB0\n * 0xA8                 <- bound = -0x58\n * 0xA0\n */\n\nstruct determine_alignment {\n  char x;\n  union { int i; double d; uint64_t u64; size_t sz; void* ptr; } u;\n};\nenum {ALIGNMENT = offsetof(struct determine_alignment, u)};\n\nstatic size_t align_round_up(size_t sz) {\n  return ((sz + (ALIGNMENT - 1)) / ALIGNMENT) * ALIGNMENT;\n}\n\ntypedef int stack_ptr;\n\nstruct stack {\n  char* mem_end; // one-past-the-end of allocated region\n  stack_ptr bound;\n  stack_ptr limit; // 0 - stack is empty\n};\n\nstatic void stack_init(struct stack* s) {\n  s->mem_end = 0;\n  s->bound = ALIGNMENT;\n  s->limit = 0;\n}\n\nstatic void stack_reset(struct stack* s) {\n  assert(s->limit == 0 && \"stack freed while not empty\");\n  if(s->mem_end != NULL) {\n    char* mem_start = s->mem_end - ( -s->bound + ALIGNMENT);\n    free(mem_start);\n  }\n  stack_init(s);\n}\n\nstatic int stack_pop_will_free(struct stack* s, stack_ptr p) {\n  return p == s->limit;\n}\n\nstatic void* stack_block(struct stack* s, stack_ptr p) {\n  return (void*)(s->mem_end + p);\n}\n\nstatic stack_ptr* stack_block_next(struct stack* s, stack_ptr p) {\n  return &((stack_ptr*)stack_block(s, p))[-1];\n}\n\nstatic void stack_reallocate(struct stack* s, size_t sz) {\n  int old_mem_length = -(s->bound) + ALIGNMENT;\n  char* old_mem_start = (s->mem_end != NULL) ? (s->mem_end - old_mem_length) : NULL;\n\n  int new_mem_length = align_round_up((old_mem_length + sz + 256) * 2);\n  char* new_mem_start = jv_mem_realloc(old_mem_start, new_mem_length);\n  memmove(new_mem_start + (new_mem_length - old_mem_length),\n            new_mem_start, old_mem_length);\n  s->mem_end = new_mem_start + new_mem_length;\n  s->bound = -(new_mem_length - ALIGNMENT);\n}\n\nstatic stack_ptr stack_push_block(struct stack* s, stack_ptr p, size_t sz) {\n  int alloc_sz = align_round_up(sz) + ALIGNMENT;\n  stack_ptr r = s->limit - alloc_sz;\n  if (r < s->bound) {\n    stack_reallocate(s, alloc_sz);\n  }\n  s->limit = r;\n  *stack_block_next(s, r) = p;\n  return r;\n}\n\nstatic stack_ptr stack_pop_block(struct stack* s, stack_ptr p, size_t sz) {\n  stack_ptr r = *stack_block_next(s, p);\n  if (p == s->limit) {\n    int alloc_sz = align_round_up(sz) + ALIGNMENT;\n    s->limit += alloc_sz;\n  }\n  return r;\n}\n#endif\n"
  },
  {
    "path": "src/execute.c",
    "content": "#include <assert.h>\n#include <errno.h>\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdint.h>\n#include <sys/stat.h>\n\n#include \"exec_stack.h\"\n#include \"bytecode.h\"\n\n#include \"jv_alloc.h\"\n#include \"locfile.h\"\n#include \"jv.h\"\n#include \"jq.h\"\n#include \"builtin.h\"\n#include \"linker.h\"\n\nstruct jq_state {\n  void (*nomem_handler)(void *);\n  void *nomem_handler_data;\n  struct bytecode* bc;\n\n  jq_msg_cb err_cb;\n  void *err_cb_data;\n  jv error;\n\n  struct stack stk;\n  stack_ptr curr_frame;\n  stack_ptr stk_top;\n  stack_ptr fork_top;\n\n  jv path;\n  jv value_at_path;\n  int subexp_nest;\n  int debug_trace_enabled;\n  int initial_execution;\n  unsigned next_label;\n\n  int halted;\n  jv exit_code;\n  jv error_message;\n\n  jv attrs;\n  jq_input_cb input_cb;\n  void *input_cb_data;\n  jq_msg_cb debug_cb;\n  void *debug_cb_data;\n  jq_msg_cb stderr_cb;\n  void *stderr_cb_data;\n};\n\nstruct closure {\n  struct bytecode* bc;  // jq bytecode\n  stack_ptr env;        // jq stack address of closed frame\n};\n\n// locals for any function called: either a closure or a local variable\nunion frame_entry {\n  struct closure closure;\n  jv localvar;\n};\n\n// jq function call frame\nstruct frame {\n  struct bytecode* bc;      // jq bytecode for callee\n  stack_ptr env;            // jq stack address of frame to return to\n  stack_ptr retdata;        // jq stack address to unwind to on RET\n  uint16_t* retaddr;        // jq bytecode return address\n  union frame_entry entries[]; // nclosures + nlocals\n};\n\nstatic int frame_size(struct bytecode* bc) {\n  return sizeof(struct frame) + sizeof(union frame_entry) * (bc->nclosures + bc->nlocals);\n}\n\nstatic struct frame* frame_current(struct jq_state* jq) {\n  struct frame* fp = stack_block(&jq->stk, jq->curr_frame);\n\n  stack_ptr next = *stack_block_next(&jq->stk, jq->curr_frame);\n  if (next) {\n    struct frame* fpnext = stack_block(&jq->stk, next);\n    struct bytecode* bc = fpnext->bc;\n    assert(fp->retaddr >= bc->code && fp->retaddr < bc->code + bc->codelen);\n  } else {\n    assert(fp->retaddr == 0);\n  }\n  return fp;\n}\n\nstatic stack_ptr frame_get_level(struct jq_state* jq, int level) {\n  stack_ptr fr = jq->curr_frame;\n  for (int i=0; i<level; i++) {\n    struct frame* fp = stack_block(&jq->stk, fr);\n    fr = fp->env;\n  }\n  return fr;\n}\n\nstatic jv* frame_local_var(struct jq_state* jq, int var, int level) {\n  struct frame* fr = stack_block(&jq->stk, frame_get_level(jq, level));\n  assert(var >= 0);\n  assert(var < fr->bc->nlocals);\n  return &fr->entries[fr->bc->nclosures + var].localvar;\n}\n\nstatic struct closure make_closure(struct jq_state* jq, uint16_t* pc) {\n  uint16_t level = *pc++;\n  uint16_t idx = *pc++;\n  stack_ptr fridx = frame_get_level(jq, level);\n  struct frame* fr = stack_block(&jq->stk, fridx);\n  if (idx & ARG_NEWCLOSURE) {\n    // A new closure closing the frame identified by level, and with\n    // the bytecode body of the idx'th subfunction of that frame\n    int subfn_idx = idx & ~ARG_NEWCLOSURE;\n    assert(subfn_idx < fr->bc->nsubfunctions);\n    struct closure cl = {fr->bc->subfunctions[subfn_idx],\n                         fridx};\n    return cl;\n  } else {\n    // A reference to a closure from the frame identified by level; copy\n    // it as-is\n    int closure = idx;\n    assert(closure >= 0);\n    assert(closure < fr->bc->nclosures);\n    return fr->entries[closure].closure;\n  }\n}\n\nstatic struct frame* frame_push(struct jq_state* jq, struct closure callee,\n                                uint16_t* argdef, int nargs) {\n  stack_ptr new_frame_idx = stack_push_block(&jq->stk, jq->curr_frame, frame_size(callee.bc));\n  struct frame* new_frame = stack_block(&jq->stk, new_frame_idx);\n  new_frame->bc = callee.bc;\n  new_frame->env = callee.env;\n  assert(nargs == new_frame->bc->nclosures);\n  union frame_entry* entries = new_frame->entries;\n  for (int i=0; i<nargs; i++) {\n    entries->closure = make_closure(jq, argdef + i * 2);\n    entries++;\n  }\n  for (int i=0; i<callee.bc->nlocals; i++) {\n    entries->localvar = jv_invalid();\n    entries++;\n  }\n  jq->curr_frame = new_frame_idx;\n  return new_frame;\n}\n\nstatic void frame_pop(struct jq_state* jq) {\n  assert(jq->curr_frame);\n  struct frame* fp = frame_current(jq);\n  if (stack_pop_will_free(&jq->stk, jq->curr_frame)) {\n    int nlocals = fp->bc->nlocals;\n    for (int i=0; i<nlocals; i++) {\n      jv_free(*frame_local_var(jq, i, 0));\n    }\n  }\n  jq->curr_frame = stack_pop_block(&jq->stk, jq->curr_frame, frame_size(fp->bc));\n}\n\nvoid stack_push(jq_state *jq, jv val) {\n  assert(jv_is_valid(val));\n  jq->stk_top = stack_push_block(&jq->stk, jq->stk_top, sizeof(jv));\n  jv* sval = stack_block(&jq->stk, jq->stk_top);\n  *sval = val;\n}\n\njv stack_pop(jq_state *jq) {\n  jv* sval = stack_block(&jq->stk, jq->stk_top);\n  jv val = *sval;\n  if (!stack_pop_will_free(&jq->stk, jq->stk_top)) {\n    val = jv_copy(val);\n  }\n  jq->stk_top = stack_pop_block(&jq->stk, jq->stk_top, sizeof(jv));\n  assert(jv_is_valid(val));\n  return val;\n}\n\n// Like stack_pop(), but assert !stack_pop_will_free() and replace with\n// jv_null() on the stack.\njv stack_popn(jq_state *jq) {\n  jv* sval = stack_block(&jq->stk, jq->stk_top);\n  jv val = *sval;\n  if (!stack_pop_will_free(&jq->stk, jq->stk_top)) {\n    *sval = jv_null();\n  }\n  jq->stk_top = stack_pop_block(&jq->stk, jq->stk_top, sizeof(jv));\n  assert(jv_is_valid(val));\n  return val;\n}\n\n\nstruct forkpoint {\n  stack_ptr saved_data_stack;\n  stack_ptr saved_curr_frame;\n  int path_len, subexp_nest;\n  jv value_at_path;\n  uint16_t* return_address;\n};\n\nstruct stack_pos {\n  stack_ptr saved_data_stack, saved_curr_frame;\n};\n\nstruct stack_pos stack_get_pos(jq_state* jq) {\n  struct stack_pos sp = {jq->stk_top, jq->curr_frame};\n  return sp;\n}\n\nvoid stack_save(jq_state *jq, uint16_t* retaddr, struct stack_pos sp){\n  jq->fork_top = stack_push_block(&jq->stk, jq->fork_top, sizeof(struct forkpoint));\n  struct forkpoint* fork = stack_block(&jq->stk, jq->fork_top);\n  fork->saved_data_stack = jq->stk_top;\n  fork->saved_curr_frame = jq->curr_frame;\n  fork->path_len =\n    jv_get_kind(jq->path) == JV_KIND_ARRAY ? jv_array_length(jv_copy(jq->path)) : 0;\n  fork->value_at_path = jv_copy(jq->value_at_path);\n  fork->subexp_nest = jq->subexp_nest;\n  fork->return_address = retaddr;\n  jq->stk_top = sp.saved_data_stack;\n  jq->curr_frame = sp.saved_curr_frame;\n}\n\nstatic int path_intact(jq_state *jq, jv curr) {\n  if (jq->subexp_nest == 0 && jv_get_kind(jq->path) == JV_KIND_ARRAY) {\n    return jv_identical(curr, jv_copy(jq->value_at_path));\n  } else {\n    jv_free(curr);\n    return 1;\n  }\n}\n\nstatic void path_append(jq_state* jq, jv component, jv value_at_path) {\n  if (jq->subexp_nest == 0 && jv_get_kind(jq->path) == JV_KIND_ARRAY) {\n    int n1 = jv_array_length(jv_copy(jq->path));\n    jq->path = jv_array_append(jq->path, component);\n    int n2 = jv_array_length(jv_copy(jq->path));\n    assert(n2 == n1 + 1);\n    jv_free(jq->value_at_path);\n    jq->value_at_path = value_at_path;\n  } else {\n    jv_free(component);\n    jv_free(value_at_path);\n  }\n}\n\n/* For f_getpath() */\njv\n_jq_path_append(jq_state *jq, jv v, jv p, jv value_at_path) {\n  if (jq->subexp_nest != 0 ||\n      jv_get_kind(jq->path) != JV_KIND_ARRAY ||\n      !jv_is_valid(value_at_path)) {\n    jv_free(v);\n    jv_free(p);\n    return value_at_path;\n  }\n  if (!jv_identical(v, jv_copy(jq->value_at_path))) {\n    jv_free(p);\n    return value_at_path;\n  }\n  if (jv_get_kind(p) == JV_KIND_ARRAY)\n    jq->path = jv_array_concat(jq->path, p);\n  else\n    jq->path = jv_array_append(jq->path, p);\n  jv_free(jq->value_at_path);\n  return jv_copy(jq->value_at_path = value_at_path);\n}\n\nuint16_t* stack_restore(jq_state *jq){\n  while (!stack_pop_will_free(&jq->stk, jq->fork_top)) {\n    if (stack_pop_will_free(&jq->stk, jq->stk_top)) {\n      jv_free(stack_pop(jq));\n    } else if (stack_pop_will_free(&jq->stk, jq->curr_frame)) {\n      frame_pop(jq);\n    } else {\n      assert(0);\n    }\n  }\n\n  if (jq->fork_top == 0) {\n    return 0;\n  }\n\n  struct forkpoint* fork = stack_block(&jq->stk, jq->fork_top);\n  uint16_t* retaddr = fork->return_address;\n  jq->stk_top = fork->saved_data_stack;\n  jq->curr_frame = fork->saved_curr_frame;\n  int path_len = fork->path_len;\n  if (jv_get_kind(jq->path) == JV_KIND_ARRAY) {\n    assert(path_len >= 0);\n    jq->path = jv_array_slice(jq->path, 0, path_len);\n  } else {\n    fork->path_len = 0;\n  }\n  jv_free(jq->value_at_path);\n  jq->value_at_path = fork->value_at_path;\n  jq->subexp_nest = fork->subexp_nest;\n  jq->fork_top = stack_pop_block(&jq->stk, jq->fork_top, sizeof(struct forkpoint));\n  return retaddr;\n}\n\nstatic void jq_reset(jq_state *jq) {\n  while (stack_restore(jq)) {}\n\n  assert(jq->stk_top == 0);\n  assert(jq->fork_top == 0);\n  assert(jq->curr_frame == 0);\n  stack_reset(&jq->stk);\n  jv_free(jq->error);\n  jq->error = jv_null();\n\n  jq->halted = 0;\n  jv_free(jq->exit_code);\n  jq->exit_code = jv_invalid();\n  jv_free(jq->error_message);\n  jq->error_message = jv_invalid();\n  if (jv_get_kind(jq->path) != JV_KIND_INVALID)\n    jv_free(jq->path);\n  jq->path = jv_null();\n  jv_free(jq->value_at_path);\n  jq->value_at_path = jv_null();\n  jq->subexp_nest = 0;\n}\n\nvoid jq_report_error(jq_state *jq, jv value) {\n  assert(jq->err_cb);\n  // callback must jv_free() its jv argument\n  jq->err_cb(jq->err_cb_data, value);\n}\n\nstatic void set_error(jq_state *jq, jv value) {\n  // Record so try/catch can find it.\n  jv_free(jq->error);\n  jq->error = value;\n}\n\n#define ON_BACKTRACK(op) ((op)+NUM_OPCODES)\n\njv jq_next(jq_state *jq) {\n  jv_nomem_handler(jq->nomem_handler, jq->nomem_handler_data);\n\n  uint16_t* pc = stack_restore(jq);\n  assert(pc);\n\n  int raising;\n  int backtracking = !jq->initial_execution;\n\n  jq->initial_execution = 0;\n  assert(jv_get_kind(jq->error) == JV_KIND_NULL);\n  while (1) {\n    if (jq->halted) {\n      if (jq->debug_trace_enabled)\n        printf(\"\\t<halted>\\n\");\n      return jv_invalid();\n    }\n    uint16_t opcode = *pc;\n    raising = 0;\n\n    if (jq->debug_trace_enabled) {\n      dump_operation(frame_current(jq)->bc, pc);\n      printf(\"\\t\");\n      const struct opcode_description* opdesc = opcode_describe(opcode);\n      stack_ptr param = 0;\n      if (!backtracking) {\n        int stack_in = opdesc->stack_in;\n        if (stack_in == -1) stack_in = pc[1];\n        param = jq->stk_top;\n        for (int i=0; i<stack_in; i++) {\n          if (i != 0) {\n            printf(\" | \");\n            param = *stack_block_next(&jq->stk, param);\n          }\n          if (!param) break;\n          jv_dump(jv_copy(*(jv*)stack_block(&jq->stk, param)), JV_PRINT_REFCOUNT);\n          //printf(\"<%d>\", jv_get_refcnt(param->val));\n          //printf(\" -- \");\n          //jv_dump(jv_copy(jq->path), 0);\n        }\n        if (jq->debug_trace_enabled & JQ_DEBUG_TRACE_DETAIL) {\n          while ((param = *stack_block_next(&jq->stk, param))) {\n            printf(\" || \");\n            jv_dump(jv_copy(*(jv*)stack_block(&jq->stk, param)), JV_PRINT_REFCOUNT);\n          }\n        }\n      } else {\n        printf(\"\\t<backtracking>\");\n      }\n\n      printf(\"\\n\");\n    }\n\n    if (backtracking) {\n      opcode = ON_BACKTRACK(opcode);\n      backtracking = 0;\n      raising = !jv_is_valid(jq->error);\n    }\n    pc++;\n\n    switch (opcode) {\n    default: assert(0 && \"invalid instruction\");\n\n    case TOP: break;\n\n    case ERRORK: {\n      jv v = jv_array_get(jv_copy(frame_current(jq)->bc->constants), *pc++);\n      set_error(jq, jv_invalid_with_msg(v));\n      goto do_backtrack;\n    }\n\n    case LOADK: {\n      jv v = jv_array_get(jv_copy(frame_current(jq)->bc->constants), *pc++);\n      assert(jv_is_valid(v));\n      jv_free(stack_pop(jq));\n      stack_push(jq, v);\n      break;\n    }\n\n    case GENLABEL: {\n      stack_push(jq, JV_OBJECT(jv_string(\"__jq\"), jv_number(jq->next_label++)));\n      break;\n    }\n\n    case DUP: {\n      jv v = stack_pop(jq);\n      stack_push(jq, jv_copy(v));\n      stack_push(jq, v);\n      break;\n    }\n\n    case DUPN: {\n      jv v = stack_popn(jq);\n      stack_push(jq, jv_copy(v));\n      stack_push(jq, v);\n      break;\n    }\n\n    case DUP2: {\n      jv keep = stack_pop(jq);\n      jv v = stack_pop(jq);\n      stack_push(jq, jv_copy(v));\n      stack_push(jq, keep);\n      stack_push(jq, v);\n      break;\n    }\n\n    case SUBEXP_BEGIN: {\n      jv v = stack_pop(jq);\n      stack_push(jq, jv_copy(v));\n      stack_push(jq, v);\n      jq->subexp_nest++;\n      break;\n    }\n\n    case SUBEXP_END: {\n      assert(jq->subexp_nest > 0);\n      jq->subexp_nest--;\n      jv a = stack_pop(jq);\n      jv b = stack_pop(jq);\n      stack_push(jq, a);\n      stack_push(jq, b);\n      break;\n    }\n\n    case PUSHK_UNDER: {\n      jv v = jv_array_get(jv_copy(frame_current(jq)->bc->constants), *pc++);\n      assert(jv_is_valid(v));\n      jv v2 = stack_pop(jq);\n      stack_push(jq, v);\n      stack_push(jq, v2);\n      break;\n    }\n\n    case POP: {\n      jv_free(stack_pop(jq));\n      break;\n    }\n\n    case APPEND: {\n      jv v = stack_pop(jq);\n      uint16_t level = *pc++;\n      uint16_t vidx = *pc++;\n      jv* var = frame_local_var(jq, vidx, level);\n      assert(jv_get_kind(*var) == JV_KIND_ARRAY);\n      *var = jv_array_append(*var, v);\n      break;\n    }\n\n    case INSERT: {\n      jv stktop = stack_pop(jq);\n      jv v = stack_pop(jq);\n      jv k = stack_pop(jq);\n      jv objv = stack_pop(jq);\n      assert(jv_get_kind(objv) == JV_KIND_OBJECT);\n      if (jv_get_kind(k) == JV_KIND_STRING) {\n        stack_push(jq, jv_object_set(objv, k, v));\n        stack_push(jq, stktop);\n      } else {\n        char errbuf[30];\n        set_error(jq, jv_invalid_with_msg(jv_string_fmt(\n                \"Cannot use %s (%s) as object key\",\n                jv_kind_name(jv_get_kind(k)),\n                jv_dump_string_trunc(jv_copy(k), errbuf, sizeof(errbuf)))));\n        jv_free(stktop);\n        jv_free(v);\n        jv_free(k);\n        jv_free(objv);\n        goto do_backtrack;\n      }\n      break;\n    }\n\n    case ON_BACKTRACK(RANGE):\n    case RANGE: {\n      uint16_t level = *pc++;\n      uint16_t v = *pc++;\n      jv* var = frame_local_var(jq, v, level);\n      jv max = stack_pop(jq);\n      if (raising) {\n        jv_free(max);\n        goto do_backtrack;\n      } \n      if (jv_get_kind(*var) != JV_KIND_NUMBER ||\n          jv_get_kind(max) != JV_KIND_NUMBER) {\n        set_error(jq, jv_invalid_with_msg(jv_string_fmt(\"Range bounds must be numeric\")));\n        jv_free(max);\n        goto do_backtrack;\n      } else if (jv_number_value(*var) >= jv_number_value(max)) {\n        /* finished iterating */\n        jv_free(max);\n        goto do_backtrack;\n      } else {\n        jv curr = *var;\n        *var = jv_number(jv_number_value(*var) + 1);\n\n        struct stack_pos spos = stack_get_pos(jq);\n        stack_push(jq, max);\n        stack_save(jq, pc - 3, spos);\n\n        stack_push(jq, curr);\n      }\n      break;\n    }\n\n      // FIXME: loadv/storev may do too much copying/freeing\n    case LOADV: {\n      uint16_t level = *pc++;\n      uint16_t v = *pc++;\n      jv* var = frame_local_var(jq, v, level);\n      if (jq->debug_trace_enabled) {\n        printf(\"V%d = \", v);\n        jv_dump(jv_copy(*var), JV_PRINT_REFCOUNT);\n        printf(\"\\n\");\n      }\n      jv_free(stack_pop(jq));\n      stack_push(jq, jv_copy(*var));\n      break;\n    }\n\n      // Does a load but replaces the variable with null\n    case LOADVN: {\n      uint16_t level = *pc++;\n      uint16_t v = *pc++;\n      jv* var = frame_local_var(jq, v, level);\n      if (jq->debug_trace_enabled) {\n        printf(\"V%d = \", v);\n        jv_dump(jv_copy(*var), JV_PRINT_REFCOUNT);\n        printf(\"\\n\");\n      }\n      jv_free(stack_popn(jq));\n\n      // This `stack_push()` invalidates the `var` reference, so\n      stack_push(jq, *var);\n      // we have to re-resolve `var` before we can set it to null\n      var = frame_local_var(jq, v, level);\n      *var = jv_null();\n      break;\n    }\n\n    case STOREVN:\n        stack_save(jq, pc - 1, stack_get_pos(jq));\n        JQ_FALLTHROUGH;\n    case STOREV: {\n      uint16_t level = *pc++;\n      uint16_t v = *pc++;\n      jv* var = frame_local_var(jq, v, level);\n      jv val = stack_pop(jq);\n      if (jq->debug_trace_enabled) {\n        printf(\"V%d = \", v);\n        jv_dump(jv_copy(val), 0);\n        printf(\" (%d)\\n\", jv_get_refcnt(val));\n      }\n      jv_free(*var);\n      *var = val;\n      break;\n    }\n\n    case ON_BACKTRACK(STOREVN): {\n      uint16_t level = *pc++;\n      uint16_t v = *pc++;\n      jv* var = frame_local_var(jq, v, level);\n      jv_free(*var);\n      *var = jv_null();\n      goto do_backtrack;\n      break;\n    }\n\n    case STORE_GLOBAL: {\n      // Get the constant\n      jv val = jv_array_get(jv_copy(frame_current(jq)->bc->constants), *pc++);\n      assert(jv_is_valid(val));\n\n      // Store the var\n      uint16_t level = *pc++;\n      uint16_t v = *pc++;\n      jv* var = frame_local_var(jq, v, level);\n      if (jq->debug_trace_enabled) {\n        printf(\"V%d = \", v);\n        jv_dump(jv_copy(val), 0);\n        printf(\" (%d)\\n\", jv_get_refcnt(val));\n      }\n      jv_free(*var);\n      *var = val;\n      break;\n    }\n\n    case PATH_BEGIN: {\n      jv v = stack_pop(jq);\n      stack_push(jq, jq->path);\n\n      stack_save(jq, pc - 1, stack_get_pos(jq));\n\n      stack_push(jq, jv_number(jq->subexp_nest));\n      stack_push(jq, jq->value_at_path);\n      stack_push(jq, jv_copy(v));\n\n      jq->path = jv_array();\n      jq->value_at_path = v; // next INDEX operation must index into v\n      jq->subexp_nest = 0;\n      break;\n    }\n\n    case PATH_END: {\n      jv v = stack_pop(jq);\n      // detect invalid path expression like path(.a | reverse)\n      if (!path_intact(jq, jv_copy(v))) {\n        char errbuf[30];\n        jv msg = jv_string_fmt(\n            \"Invalid path expression with result %s\",\n            jv_dump_string_trunc(v, errbuf, sizeof(errbuf)));\n        set_error(jq, jv_invalid_with_msg(msg));\n        goto do_backtrack;\n      }\n      jv_free(v); // discard value, only keep path\n\n      jv old_value_at_path = stack_pop(jq);\n      int old_subexp_nest = (int)jv_number_value(stack_pop(jq));\n\n      jv path = jq->path;\n      jq->path = stack_pop(jq);\n\n      struct stack_pos spos = stack_get_pos(jq);\n      stack_push(jq, jv_copy(path));\n      stack_save(jq, pc - 1, spos);\n\n      stack_push(jq, path);\n      jq->subexp_nest = old_subexp_nest;\n      jv_free(jq->value_at_path);\n      jq->value_at_path = old_value_at_path;\n      break;\n    }\n\n    case ON_BACKTRACK(PATH_BEGIN):\n    case ON_BACKTRACK(PATH_END): {\n      jv_free(jq->path);\n      jq->path = stack_pop(jq);\n      goto do_backtrack;\n    }\n\n    case INDEX:\n    case INDEX_OPT: {\n      jv t = stack_pop(jq);\n      jv k = stack_pop(jq);\n      // detect invalid path expression like path(reverse | .a)\n      if (!path_intact(jq, jv_copy(t))) {\n        char keybuf[30];\n        char objbuf[30];\n        jv msg = jv_string_fmt(\n            \"Invalid path expression near attempt to access element %s of %s\",\n            jv_dump_string_trunc(k, keybuf, sizeof(keybuf)),\n            jv_dump_string_trunc(t, objbuf, sizeof(objbuf)));\n        set_error(jq, jv_invalid_with_msg(msg));\n        goto do_backtrack;\n      }\n      jv v = jv_get(t, jv_copy(k));\n      if (jv_is_valid(v)) {\n        path_append(jq, k, jv_copy(v));\n        stack_push(jq, v);\n      } else {\n        jv_free(k);\n        if (opcode == INDEX)\n          set_error(jq, v);\n        else\n          jv_free(v);\n        goto do_backtrack;\n      }\n      break;\n    }\n\n\n    case JUMP: {\n      uint16_t offset = *pc++;\n      pc += offset;\n      break;\n    }\n\n    case JUMP_F: {\n      uint16_t offset = *pc++;\n      jv t = stack_pop(jq);\n      jv_kind kind = jv_get_kind(t);\n      if (kind == JV_KIND_FALSE || kind == JV_KIND_NULL) {\n        pc += offset;\n      }\n      stack_push(jq, t); // FIXME do this better\n      break;\n    }\n\n    case EACH:\n    case EACH_OPT: {\n      jv container = stack_pop(jq);\n      // detect invalid path expression like path(reverse | .[])\n      if (!path_intact(jq, jv_copy(container))) {\n        char errbuf[30];\n        jv msg = jv_string_fmt(\n            \"Invalid path expression near attempt to iterate through %s\",\n            jv_dump_string_trunc(container, errbuf, sizeof(errbuf)));\n        set_error(jq, jv_invalid_with_msg(msg));\n        goto do_backtrack;\n      }\n      stack_push(jq, container);\n      stack_push(jq, jv_number(-1));\n      JQ_FALLTHROUGH;\n    }\n    case ON_BACKTRACK(EACH):\n    case ON_BACKTRACK(EACH_OPT): {\n      int idx = jv_number_value(stack_pop(jq));\n      jv container = stack_pop(jq);\n\n      int keep_going, is_last = 0;\n      jv key, value;\n      if (jv_get_kind(container) == JV_KIND_ARRAY) {\n        if (opcode == EACH || opcode == EACH_OPT) idx = 0;\n        else idx = idx + 1;\n        int len = jv_array_length(jv_copy(container));\n        keep_going = idx < len;\n        is_last = idx == len - 1;\n        if (keep_going) {\n          key = jv_number(idx);\n          value = jv_array_get(jv_copy(container), idx);\n        }\n      } else if (jv_get_kind(container) == JV_KIND_OBJECT) {\n        if (opcode == EACH || opcode == EACH_OPT) idx = jv_object_iter(container);\n        else idx = jv_object_iter_next(container, idx);\n        keep_going = jv_object_iter_valid(container, idx);\n        if (keep_going) {\n          key = jv_object_iter_key(container, idx);\n          value = jv_object_iter_value(container, idx);\n        }\n      } else {\n        assert(opcode == EACH || opcode == EACH_OPT);\n        if (opcode == EACH) {\n          char errbuf[30];\n          set_error(jq, jv_invalid_with_msg(jv_string_fmt(\n                  \"Cannot iterate over %s (%s)\",\n                  jv_kind_name(jv_get_kind(container)),\n                  jv_dump_string_trunc(jv_copy(container), errbuf, sizeof(errbuf)))));\n        }\n        keep_going = 0;\n      }\n\n      if (!keep_going || raising) {\n        if (keep_going) {\n          jv_free(key);\n          jv_free(value);\n        }\n        jv_free(container);\n        goto do_backtrack;\n      } else if (is_last) {\n        // we don't need to make a backtrack point\n        jv_free(container);\n        path_append(jq, key, jv_copy(value));\n        stack_push(jq, value);\n      } else {\n        struct stack_pos spos = stack_get_pos(jq);\n        stack_push(jq, container);\n        stack_push(jq, jv_number(idx));\n        stack_save(jq, pc - 1, spos);\n        path_append(jq, key, jv_copy(value));\n        stack_push(jq, value);\n      }\n      break;\n    }\n\n    do_backtrack:\n    case BACKTRACK: {\n      pc = stack_restore(jq);\n      if (!pc) {\n        if (!jv_is_valid(jq->error)) {\n          jv error = jq->error;\n          jq->error = jv_null();\n          return error;\n        }\n        return jv_invalid();\n      }\n      backtracking = 1;\n      break;\n    }\n\n    case TRY_BEGIN:\n      stack_save(jq, pc - 1, stack_get_pos(jq));\n      pc++; // skip handler offset this time\n      break;\n\n    case TRY_END:\n      stack_save(jq, pc - 1, stack_get_pos(jq));\n      break;\n\n    case ON_BACKTRACK(TRY_BEGIN): {\n      if (!raising) {\n        /*\n         * `try EXP ...` -- EXP backtracked (e.g., EXP was `empty`), so we\n         * backtrack more:\n         */\n        jv_free(stack_pop(jq));\n        goto do_backtrack;\n      }\n\n      /*\n       * Else `(try EXP ... ) | EXP2` raised an error.\n       *\n       * If the error was wrapped in another error, then that means EXP2 raised\n       * the error.  We unwrap it and re-raise it as it wasn't raised by EXP.\n       *\n       * See commentary in gen_try().\n       */\n      jv e = jv_invalid_get_msg(jv_copy(jq->error));\n      if (!jv_is_valid(e) && jv_invalid_has_msg(jv_copy(e))) {\n        set_error(jq, e);\n        goto do_backtrack;\n      }\n      jv_free(e);\n\n      /*\n       * Else we caught an error containing a non-error value, so we jump to\n       * the handler.\n       *\n       * See commentary in gen_try().\n       */\n      uint16_t offset = *pc++;\n      jv_free(stack_pop(jq)); // free the input\n      stack_push(jq, jv_invalid_get_msg(jq->error));  // push the error's message\n      jq->error = jv_null();\n      pc += offset;\n      break;\n    }\n    case ON_BACKTRACK(TRY_END):\n      // Wrap the error so the matching TRY_BEGIN doesn't catch it\n      if (raising)\n        set_error(jq, jv_invalid_with_msg(jv_copy(jq->error)));\n      goto do_backtrack;\n\n    case DESTRUCTURE_ALT:\n    case FORK: {\n      stack_save(jq, pc - 1, stack_get_pos(jq));\n      pc++; // skip offset this time\n      break;\n    }\n\n    case ON_BACKTRACK(DESTRUCTURE_ALT): {\n      if (jv_is_valid(jq->error)) {\n        // `try EXP ...` backtracked here (no value, `empty`), so we backtrack more\n        jv_free(stack_pop(jq));\n        goto do_backtrack;\n      }\n      // `try EXP ...` exception caught in EXP\n      // DESTRUCTURE_ALT doesn't want the error message on the stack,\n      // as we would just want to throw it away anyway.\n      if (opcode != ON_BACKTRACK(DESTRUCTURE_ALT)) {\n        jv_free(stack_pop(jq)); // free the input\n        stack_push(jq, jv_invalid_get_msg(jq->error));  // push the error's message\n      } else {\n        jv_free(jq->error);\n      }\n      jq->error = jv_null();\n      uint16_t offset = *pc++;\n      pc += offset;\n      break;\n    }\n    case ON_BACKTRACK(FORK): {\n      if (raising) goto do_backtrack;\n      uint16_t offset = *pc++;\n      pc += offset;\n      break;\n    }\n\n    case CALL_BUILTIN: {\n      int nargs = *pc++;\n      struct cfunction* function = &frame_current(jq)->bc->globals->cfunctions[*pc++];\n      jv in[MAX_CFUNCTION_ARGS];\n      for (int i = 0; i < nargs; ++i)\n        in[i] = stack_pop(jq);\n\n      jv top;\n      switch (function->nargs) {\n      case 1: top = function->fptr.a1(jq, in[0]); break;\n      case 2: top = function->fptr.a2(jq, in[0], in[1]); break;\n      case 3: top = function->fptr.a3(jq, in[0], in[1], in[2]); break;\n      case 4: top = function->fptr.a4(jq, in[0], in[1], in[2], in[3]); break;\n      default: assert(0 && \"Invalid number of arguments\");\n      }\n\n      if (!jv_is_valid(top)) {\n        if (jv_invalid_has_msg(jv_copy(top)))\n          set_error(jq, top);\n        else\n          jv_free(top);\n        goto do_backtrack;\n      }\n\n      stack_push(jq, top);\n      break;\n    }\n\n    case TAIL_CALL_JQ:\n    case CALL_JQ: {\n      /*\n       * Bytecode layout here:\n       *\n       *  CALL_JQ\n       *  <nclosures>                       (i.e., number of call arguments)\n       *  <callee closure>                  (what we're calling)\n       *  <nclosures' worth of closures>    (frame reference + code pointer)\n       *\n       *  <next instruction (to return to)>\n       *\n       * Each closure consists of two uint16_t values: a \"level\"\n       * identifying the frame to be closed over, and an index.\n       *\n       * The level is a relative number of call frames reachable from\n       * the currently one; 0 -> current frame, 1 -> previous frame, and\n       * so on.\n       *\n       * The index is either an index of the closed frame's subfunctions\n       * or of the closed frame's parameter closures.  If the latter,\n       * that closure will be passed, else the closed frame's pointer\n       * and the subfunction's code will form the closure to be passed.\n       *\n       * See make_closure() for more information.\n       */\n      jv input = stack_pop(jq);\n      uint16_t nclosures = *pc++;\n      uint16_t* retaddr = pc + 2 + nclosures*2;\n      stack_ptr retdata = jq->stk_top;\n      struct frame* new_frame;\n      struct closure cl = make_closure(jq, pc);\n      if (opcode == TAIL_CALL_JQ) {\n        retaddr = frame_current(jq)->retaddr;\n        retdata = frame_current(jq)->retdata;\n        frame_pop(jq);\n      }\n      new_frame = frame_push(jq, cl, pc + 2, nclosures);\n      new_frame->retdata = retdata;\n      new_frame->retaddr = retaddr;\n      pc = new_frame->bc->code;\n      stack_push(jq, input);\n      break;\n    }\n\n    case RET: {\n      jv value = stack_pop(jq);\n      assert(jq->stk_top == frame_current(jq)->retdata);\n      uint16_t* retaddr = frame_current(jq)->retaddr;\n      if (retaddr) {\n        // function return\n        pc = retaddr;\n        frame_pop(jq);\n      } else {\n        // top-level return, yielding value\n        struct stack_pos spos = stack_get_pos(jq);\n        stack_push(jq, jv_null());\n        stack_save(jq, pc - 1, spos);\n        return value;\n      }\n      stack_push(jq, value);\n      break;\n    }\n    case ON_BACKTRACK(RET): {\n      // resumed after top-level return\n      goto do_backtrack;\n    }\n    }\n  }\n}\n\njv jq_format_error(jv msg) {\n  if (jv_get_kind(msg) == JV_KIND_NULL ||\n      (jv_get_kind(msg) == JV_KIND_INVALID && !jv_invalid_has_msg(jv_copy(msg)))) {\n    jv_free(msg);\n    fprintf(stderr, \"jq: error: out of memory\\n\");\n    return jv_null();\n  }\n\n  if (jv_get_kind(msg) == JV_KIND_STRING)\n    return msg;                         // expected to already be formatted\n\n  if (jv_get_kind(msg) == JV_KIND_INVALID)\n    msg = jv_invalid_get_msg(msg);\n\n  if (jv_get_kind(msg) == JV_KIND_NULL)\n    return jq_format_error(msg);        // ENOMEM\n\n  // Invalid with msg; prefix with \"jq: error: \"\n\n  if (jv_get_kind(msg) != JV_KIND_INVALID) {\n    if (jv_get_kind(msg) == JV_KIND_STRING) {\n      jv r = jv_string_fmt(\"jq: error: %s\", jv_string_value(msg));\n      jv_free(msg);\n      return r;\n    }\n\n    msg = jv_dump_string(msg, JV_PRINT_INVALID);\n    if (jv_get_kind(msg) == JV_KIND_STRING) {\n      jv r = jv_string_fmt(\"jq: error: %s\", jv_string_value(msg));\n      jv_free(msg);\n      return r;\n    }\n    jv_free(msg);\n    return jq_format_error(jv_null());  // ENOMEM\n  }\n\n  // An invalid inside an invalid!\n  return jq_format_error(jv_invalid_get_msg(msg));\n}\n\n// XXX Refactor into a utility function that returns a jv and one that\n// uses it and then prints that jv's string as the complete error\n// message.\nstatic void default_err_cb(void *data, jv msg) {\n  msg = jq_format_error(msg);\n  fprintf((FILE *)data, \"%s\\n\", jv_string_value(msg));\n  jv_free(msg);\n}\n\njq_state *jq_init(void) {\n  jq_state *jq;\n  jq = jv_mem_alloc_unguarded(sizeof(*jq));\n  if (jq == NULL)\n    return NULL;\n\n  jq->bc = 0;\n  jq->next_label = 0;\n\n  stack_init(&jq->stk);\n  jq->stk_top = 0;\n  jq->fork_top = 0;\n  jq->curr_frame = 0;\n  jq->error = jv_null();\n\n  jq->halted = 0;\n  jq->exit_code = jv_invalid();\n  jq->error_message = jv_invalid();\n\n  jq->input_cb = NULL;\n  jq->input_cb_data = NULL;\n\n  jq->debug_cb = NULL;\n  jq->debug_cb_data = NULL;\n\n  jq->stderr_cb = NULL;\n  jq->stderr_cb_data = NULL;\n\n  jq->err_cb = default_err_cb;\n  jq->err_cb_data = stderr;\n\n  jq->attrs = jv_object();\n  jq->path = jv_null();\n  jq->value_at_path = jv_null();\n\n  jq->nomem_handler = NULL;\n  jq->nomem_handler_data = NULL;\n  return jq;\n}\n\nvoid jq_set_error_cb(jq_state *jq, jq_msg_cb cb, void *data) {\n  if (cb == NULL) {\n    jq->err_cb = default_err_cb;\n    jq->err_cb_data = stderr;\n  } else {\n    jq->err_cb = cb;\n    jq->err_cb_data = data;\n  }\n}\n\nvoid jq_get_error_cb(jq_state *jq, jq_msg_cb *cb, void **data) {\n  *cb = jq->err_cb;\n  *data = jq->err_cb_data;\n}\n\nvoid jq_set_nomem_handler(jq_state *jq, void (*nomem_handler)(void *), void *data) {\n  jv_nomem_handler(nomem_handler, data);\n  jq->nomem_handler = nomem_handler;\n  jq->nomem_handler_data = data;\n}\n\n\nvoid jq_start(jq_state *jq, jv input, int flags) {\n  jv_nomem_handler(jq->nomem_handler, jq->nomem_handler_data);\n  jq_reset(jq);\n\n  struct closure top = {jq->bc, -1};\n  struct frame* top_frame = frame_push(jq, top, 0, 0);\n  top_frame->retdata = 0;\n  top_frame->retaddr = 0;\n\n  stack_push(jq, input);\n  stack_save(jq, jq->bc->code, stack_get_pos(jq));\n  jq->debug_trace_enabled = flags & JQ_DEBUG_TRACE_ALL;\n  jq->initial_execution = 1;\n}\n\nvoid jq_teardown(jq_state **jq) {\n  jq_state *old_jq = *jq;\n  if (old_jq == NULL)\n    return;\n  *jq = NULL;\n\n  jq_reset(old_jq);\n  bytecode_free(old_jq->bc);\n  old_jq->bc = 0;\n  jv_free(old_jq->attrs);\n\n  jv_mem_free(old_jq);\n}\n\nstatic int ret_follows(uint16_t *pc) {\n  if (*pc == RET)\n    return 1;\n  if (*pc++ != JUMP)\n    return 0;\n  return ret_follows(pc + *pc + 1); // FIXME, might be ironic\n}\n\n/*\n * Look for tail calls that can be optimized: tail calls with no\n * references left to the current frame.\n *\n * We're staring at this bytecode layout:\n *\n *   CALL_JQ\n *   <nclosures>\n *   <callee closure>       (2 units)\n *   <nclosures closures>   (2 units each)\n *   <next instruction>\n *\n * A closure is:\n *\n *   <level>    (a relative frame count chased via the current frame's env)\n *   <index>    (an index of a subfunction or closure in that frame)\n *\n * We're looking for:\n *\n * a) the next instruction is a RET or a chain of unconditional JUMPs\n * that ends in a RET, and\n *\n * b) none of the closures -callee included- have level == 0.\n */\nstatic uint16_t tail_call_analyze(uint16_t *pc) {\n  assert(*pc == CALL_JQ);\n  pc++;\n  // + 1 for the callee closure\n  for (uint16_t nclosures = *pc++ + 1; nclosures > 0; pc++, nclosures--) {\n    if (*pc++ == 0)\n      return CALL_JQ;\n  }\n  if (ret_follows(pc))\n    return TAIL_CALL_JQ;\n  return CALL_JQ;\n}\n\nstatic struct bytecode *optimize_code(struct bytecode *bc) {\n  uint16_t *pc = bc->code;\n  // FIXME: Don't mutate bc->code...\n  while (pc < bc->code + bc->codelen) {\n    switch (*pc) {\n    case CALL_JQ:\n      *pc = tail_call_analyze(pc);\n      break;\n\n    // Other bytecode optimizations here.  A peephole optimizer would\n    // fit right in.\n    default: break;\n    }\n    pc += bytecode_operation_length(pc);\n  }\n  return bc;\n}\n\nstatic struct bytecode *optimize(struct bytecode *bc) {\n  for (int i=0; i<bc->nsubfunctions; i++) {\n    bc->subfunctions[i] = optimize(bc->subfunctions[i]);\n  }\n  return optimize_code(bc);\n}\n\nstatic jv\nargs2obj(jv args)\n{\n  if (jv_get_kind(args) == JV_KIND_OBJECT)\n    return args;\n  assert(jv_get_kind(args) == JV_KIND_ARRAY);\n  jv r = jv_object();\n  jv kk = jv_string(\"name\");\n  jv vk = jv_string(\"value\");\n  jv_array_foreach(args, i, v)\n    r = jv_object_set(r, jv_object_get(jv_copy(v), jv_copy(kk)), jv_object_get(v, jv_copy(vk)));\n  jv_free(args);\n  jv_free(kk);\n  jv_free(vk);\n  return r;\n}\n\nint jq_compile_args(jq_state *jq, const char* str, jv args) {\n  jv_nomem_handler(jq->nomem_handler, jq->nomem_handler_data);\n  assert(jv_get_kind(args) == JV_KIND_ARRAY || jv_get_kind(args) == JV_KIND_OBJECT);\n  struct locfile* locations;\n  locations = locfile_init(jq, \"<top-level>\", str, strlen(str));\n  block program;\n  jq_reset(jq);\n  if (jq->bc) {\n    bytecode_free(jq->bc);\n    jq->bc = 0;\n  }\n  int nerrors = load_program(jq, locations, &program);\n  if (nerrors == 0) {\n    nerrors = builtins_bind(jq, &program);\n    if (nerrors == 0)\n      nerrors = block_compile(program, &jq->bc, locations, args2obj(args));\n    else\n      jv_free(args);\n  } else\n    jv_free(args);\n  if (nerrors)\n    jq_report_error(jq, jv_string_fmt(\"jq: %d compile %s\", nerrors, nerrors > 1 ? \"errors\" : \"error\"));\n  if (jq->bc)\n    jq->bc = optimize(jq->bc);\n  locfile_free(locations);\n  return jq->bc != NULL;\n}\n\nint jq_compile(jq_state *jq, const char* str) {\n  return jq_compile_args(jq, str, jv_object());\n}\n\njv jq_get_jq_origin(jq_state *jq) {\n  return jq_get_attr(jq, jv_string(\"JQ_ORIGIN\"));\n}\n\njv jq_get_prog_origin(jq_state *jq) {\n  return jq_get_attr(jq, jv_string(\"PROGRAM_ORIGIN\"));\n}\n\njv jq_get_lib_dirs(jq_state *jq) {\n  jv lib_dirs = jq_get_attr(jq, jv_string(\"JQ_LIBRARY_PATH\"));\n  return jv_is_valid(lib_dirs) ? lib_dirs : jv_array();\n}\n\nvoid jq_set_attrs(jq_state *jq, jv attrs) {\n  assert(jv_get_kind(attrs) == JV_KIND_OBJECT);\n  jv_free(jq->attrs);\n  jq->attrs = attrs;\n}\n\nvoid jq_set_attr(jq_state *jq, jv attr, jv val) {\n  jq->attrs = jv_object_set(jq->attrs, attr, val);\n}\n\njv jq_get_attr(jq_state *jq, jv attr) {\n  return jv_object_get(jv_copy(jq->attrs), attr);\n}\n\nvoid jq_dump_disassembly(jq_state *jq, int indent) {\n  dump_disassembly(indent, jq->bc);\n}\n\nvoid jq_set_input_cb(jq_state *jq, jq_input_cb cb, void *data) {\n  jq->input_cb = cb;\n  jq->input_cb_data = data;\n}\n\nvoid jq_get_input_cb(jq_state *jq, jq_input_cb *cb, void **data) {\n  *cb = jq->input_cb;\n  *data = jq->input_cb_data;\n}\n\nvoid jq_set_debug_cb(jq_state *jq, jq_msg_cb cb, void *data) {\n  jq->debug_cb = cb;\n  jq->debug_cb_data = data;\n}\n\nvoid jq_get_debug_cb(jq_state *jq, jq_msg_cb *cb, void **data) {\n  *cb = jq->debug_cb;\n  *data = jq->debug_cb_data;\n}\n\nvoid jq_set_stderr_cb(jq_state *jq, jq_msg_cb cb, void *data) {\n  jq->stderr_cb = cb;\n  jq->stderr_cb_data = data;\n}\n\nvoid jq_get_stderr_cb(jq_state *jq, jq_msg_cb *cb, void **data) {\n  *cb = jq->stderr_cb;\n  *data = jq->stderr_cb_data;\n}\n\nvoid\njq_halt(jq_state *jq, jv exit_code, jv error_message)\n{\n  assert(!jq->halted);\n  jq->halted = 1;\n  jq->exit_code = exit_code;\n  jq->error_message = error_message;\n}\n\nint\njq_halted(jq_state *jq)\n{\n  return jq->halted;\n}\n\njv jq_get_exit_code(jq_state *jq)\n{\n  return jv_copy(jq->exit_code);\n}\n\njv jq_get_error_message(jq_state *jq)\n{\n  return jv_copy(jq->error_message);\n}\n"
  },
  {
    "path": "src/inject_errors.c",
    "content": "#include <assert.h>\n#include <dlfcn.h>\n#include <errno.h>\n#include <stdio.h>\n#include <string.h>\n#include <unistd.h>\n\nstatic FILE *fail;\nstatic FILE *fail_read;\nstatic FILE *fail_write;\nstatic FILE *fail_close;\nstatic int error;\n\nstatic FILE * (*real_fopen)(const char *, const char *);\nstatic int           (*real_fclose)(FILE *);\nstatic int           (*real_ferror)(FILE *);\nstatic void          (*real_clearerr)(FILE *);\nstatic char *        (*real_fgets)(char *, int, FILE *);\nstatic size_t        (*real_fread)(void *, size_t, size_t, FILE *);\nstatic size_t        (*real_fwrite)(const void *, size_t, size_t, FILE *);\n\n#define GET_REAL(sym)                         \\\n  do {                                        \\\n    if (real_ ## sym == 0) {                  \\\n      real_ ## sym = dlsym(RTLD_NEXT, #sym);  \\\n      assert(real_ ## sym != 0);              \\\n    }                                         \\\n  } while (0)\n\n#define dbg_write(msg) (void)write(2, msg, sizeof(msg) - 1)\n\n#define dbg() \\\n  do {                                      \\\n    dbg_write(\"here: \");                    \\\n    dbg_write(__func__);                    \\\n    dbg_write(\"!\\n\");                       \\\n  } while (0)\n\nFILE *fopen(const char *path, const char *mode) {\n  GET_REAL(fopen);\n  fail = fail_read = fail_write = fail_close = 0;\n  FILE *f = real_fopen(path, mode);\n  error = EIO;\n  if (strcmp(path, \"fail_read\") == 0) {\n    fail = fail_read = f;\n  } else if (strncmp(path, \"fail_write\", sizeof(\"fail_write\") - 1) == 0) {\n    // Not that jq opens files for write anyways...\n    fail = fail_write = f;\n    if (strcmp(path, \"fail_write_enospc\") == 0)\n      error = ENOSPC;\n  } else if (strncmp(path, \"fail_close\", sizeof(\"fail_close\") - 1) == 0) {\n    fail = fail_close = f;\n    if (strcmp(path, \"fail_close_enospc\") == 0)\n      error = ENOSPC;\n  }\n  return f;\n}\n\nint fclose(FILE *f) {\n  GET_REAL(fclose);\n  int res = real_fclose(f);\n  if (fail_close == f) {\n    fail = fail_read = fail_write = fail_close = 0;\n    return EOF;\n  }\n  return res;\n}\n\nchar * fgets(char *buf, int len, FILE *f) {\n  GET_REAL(fgets);\n  char *res = real_fgets(buf, len, f);\n  if (fail_read == f)\n    return 0;\n  return res;\n}\n\nsize_t fread(void *buf, size_t sz, size_t nemb, FILE *f) {\n  GET_REAL(fread);\n  size_t res = real_fread(buf, sz, nemb, f);\n  if (fail_read == f)\n    return 0;\n  return res;\n}\n\nsize_t fwrite(const void *buf, size_t sz, size_t nemb, FILE *f) {\n  GET_REAL(fwrite);\n  size_t res = real_fwrite(buf, sz, nemb, f);\n  if (fail_write == f)\n    return 0;\n  return res;\n}\n\nint ferror(FILE *f) {\n  GET_REAL(ferror);\n  int res = real_ferror(f);\n  if (fail == f) {\n    errno = error;\n    return 1;\n  }\n  return res;\n}\n\nvoid clearerr(FILE *f) {\n  GET_REAL(clearerr);\n  real_clearerr(f);\n  if (fail == f) {\n    fail = fail_read = fail_write = fail_close = 0;\n    error = 0;\n  }\n}\n"
  },
  {
    "path": "src/jq.h",
    "content": "#ifndef JQ_H\n#define JQ_H\n\n#include <stdio.h>\n#include \"jv.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nenum {\n  JQ_DEBUG_TRACE = 1,\n  JQ_DEBUG_TRACE_DETAIL = 2,\n  JQ_DEBUG_TRACE_ALL = JQ_DEBUG_TRACE | JQ_DEBUG_TRACE_DETAIL,\n};\n\ntypedef struct jq_state jq_state;\ntypedef void (*jq_msg_cb)(void *, jv);\n\njq_state *jq_init(void);\nvoid jq_set_error_cb(jq_state *, jq_msg_cb, void *);\nvoid jq_get_error_cb(jq_state *, jq_msg_cb *, void **);\nvoid jq_set_nomem_handler(jq_state *, void (*)(void *), void *);\njv jq_format_error(jv msg);\nvoid jq_report_error(jq_state *, jv);\nint jq_compile(jq_state *, const char*);\nint jq_compile_args(jq_state *, const char*, jv);\nvoid jq_dump_disassembly(jq_state *, int);\nvoid jq_start(jq_state *, jv value, int);\njv jq_next(jq_state *);\nvoid jq_teardown(jq_state **);\n\nvoid jq_halt(jq_state *, jv, jv);\nint jq_halted(jq_state *);\njv jq_get_exit_code(jq_state *);\njv jq_get_error_message(jq_state *);\n\ntypedef jv (*jq_input_cb)(jq_state *, void *);\nvoid jq_set_input_cb(jq_state *, jq_input_cb, void *);\nvoid jq_get_input_cb(jq_state *, jq_input_cb *, void **);\nvoid jq_set_debug_cb(jq_state *, jq_msg_cb, void *);\nvoid jq_get_debug_cb(jq_state *, jq_msg_cb *, void **);\nvoid jq_set_stderr_cb(jq_state *, jq_msg_cb, void *);\nvoid jq_get_stderr_cb(jq_state *, jq_msg_cb *, void **);\n\nvoid jq_set_attrs(jq_state *, jv);\njv jq_get_attrs(jq_state *);\njv jq_get_jq_origin(jq_state *);\njv jq_get_prog_origin(jq_state *);\njv jq_get_lib_dirs(jq_state *);\nvoid jq_set_attr(jq_state *, jv, jv);\njv jq_get_attr(jq_state *, jv);\n\n/*\n * We use char * instead of jf for filenames here because filenames\n * should be in the process' locale's codeset, which may not be UTF-8,\n * whereas jv string values must be in UTF-8.  This way the caller\n * doesn't have to perform any codeset conversions.\n */\ntypedef struct jq_util_input_state jq_util_input_state;\ntypedef void (*jq_util_msg_cb)(void *, const char *);\n\njq_util_input_state *jq_util_input_init(jq_util_msg_cb, void *);\nvoid jq_util_input_set_parser(jq_util_input_state *, jv_parser *, int);\nvoid jq_util_input_free(jq_util_input_state **);\nvoid jq_util_input_add_input(jq_util_input_state *, const char *);\nint jq_util_input_errors(jq_util_input_state *);\njv jq_util_input_next_input(jq_util_input_state *);\njv jq_util_input_next_input_cb(jq_state *, void *);\njv jq_util_input_get_position(jq_state*);\njv jq_util_input_get_current_filename(jq_state*);\njv jq_util_input_get_current_line(jq_state*);\n\nint jq_set_colors(const char *);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !JQ_H */\n"
  },
  {
    "path": "src/jq_parser.h",
    "content": "#ifndef JQ_PARSER_H\n#define JQ_PARSER_H\n#include \"locfile.h\"\n#include \"compile.h\"\n\nint jq_parse(struct locfile* source, block* answer);\nint jq_parse_library(struct locfile* locations, block* answer);\n\n#endif\n"
  },
  {
    "path": "src/jq_test.c",
    "content": "#include <assert.h>\n#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n#ifdef HAVE_PTHREAD\n#include <pthread.h>\n#endif\n#include \"jv.h\"\n#include \"jq.h\"\n\nstatic void jv_test(void);\nstatic void run_jq_tests(jv, int, FILE *, int, int);\nstatic void run_jq_start_state_tests(void);\nstatic void run_jq_compile_args_tests(void);\nstatic void run_jq_recompile_tests(void);\nstatic void run_jq_exhaust_and_reuse_tests(void);\n#ifdef HAVE_PTHREAD\nstatic void run_jq_pthread_tests(void);\n#endif\n\nint jq_testsuite(jv libdirs, int verbose, int argc, char* argv[]) {\n  int skip = -1;\n  int take = -1;\n  int nfiles = 0;\n  jv_test();\n  for (int i = 0; i < argc; i++) {\n    if (!strcmp(argv[i], \"--skip\")) {\n      if (++i >= argc) {\n        fprintf(stderr, \"--skip requires an argument\\n\");\n        exit(1);\n      }\n      skip = atoi(argv[i]);\n    } else if (!strcmp(argv[i], \"--take\")) {\n      if (++i >= argc) {\n        fprintf(stderr, \"--take requires an argument\\n\");\n        exit(1);\n      }\n      take = atoi(argv[i]);\n    } else {\n      FILE *testdata = fopen(argv[i], \"r\");\n      if (!testdata) {\n        perror(\"fopen\");\n        exit(1);\n      }\n      run_jq_tests(jv_copy(libdirs), verbose, testdata, skip, take);\n      fclose(testdata);\n      nfiles++;\n    }\n  }\n  if (nfiles == 0)\n    run_jq_tests(jv_copy(libdirs), verbose, stdin, skip, take);\n  jv_free(libdirs);\n  run_jq_start_state_tests();\n  run_jq_compile_args_tests();\n  run_jq_recompile_tests();\n  run_jq_exhaust_and_reuse_tests();\n#ifdef HAVE_PTHREAD\n  run_jq_pthread_tests();\n#endif\n  return 0;\n}\n\nstatic int skipline(const char* buf) {\n  int p = 0;\n  while (buf[p] == ' ' || buf[p] == '\\t') p++;\n  if (buf[p] == '#' || buf[p] == '\\n' || buf[p] == 0) return 1;\n  return 0;\n}\n\nstatic int checkerrormsg(const char* buf) {\n  return strcmp(buf, \"%%FAIL\\n\") == 0;\n}\n\nstatic int checkfail(const char* buf) {\n  return strcmp(buf, \"%%FAIL\\n\") == 0 || strcmp(buf, \"%%FAIL IGNORE MSG\\n\") == 0;\n}\n\nstruct err_data {\n  char buf[4096];\n};\n\nstatic void test_err_cb(void *data, jv e) {\n  struct err_data *err_data = data;\n  if (jv_get_kind(e) != JV_KIND_STRING)\n    e = jv_dump_string(e, JV_PRINT_INVALID);\n  if (!strncmp(jv_string_value(e), \"jq: error\", sizeof(\"jq: error\") - 1))\n    snprintf(err_data->buf, sizeof(err_data->buf), \"%s\", jv_string_value(e));\n  jv_free(e);\n}\n\nstatic void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int take) {\n  char prog[4096] = {0};\n  char buf[4096];\n  struct err_data err_msg;\n  int tests = 0, passed = 0, invalid = 0;\n  unsigned int lineno = 0;\n  int must_fail = 0;\n  int check_msg = 0;\n  jq_state *jq = NULL;\n\n  int tests_to_skip = skip > 0 ? skip : 0;\n  int tests_to_take = take;\n\n  jq = jq_init();\n  assert(jq);\n  if (jv_get_kind(lib_dirs) == JV_KIND_NULL)\n    lib_dirs = jv_array();\n  jq_set_attr(jq, jv_string(\"JQ_LIBRARY_PATH\"), lib_dirs);\n\n  while (1) {\n    if (!fgets(prog, sizeof(prog), testdata)) break;\n    lineno++;\n    if (skipline(prog)) continue;\n    if (checkfail(prog)) {\n      must_fail = 1;\n      check_msg = checkerrormsg(prog);\n      jq_set_error_cb(jq, test_err_cb, &err_msg);\n      continue;\n    }\n    if (prog[strlen(prog)-1] == '\\n') prog[strlen(prog)-1] = 0;\n\n    if (skip > 0) {\n      skip--;\n      goto next;\n    } else if (skip == 0) {\n      printf(\"Skipped %d tests\\n\", tests_to_skip);\n      skip = -1;\n    }\n\n    if (take > 0) {\n      take--;\n    } else if (take == 0) {\n      printf(\"Hit the number of tests limit (%d), breaking\\n\", tests_to_take);\n      break;\n    }\n\n    int pass = 1;\n    tests++;\n    printf(\"Test #%d: '%s' at line number %u\\n\", tests + tests_to_skip, prog, lineno);\n    int compiled = jq_compile(jq, prog);\n\n    if (must_fail) {\n      jq_set_error_cb(jq, NULL, NULL);\n      if (compiled) {\n        printf(\"*** Test program compiled successfully, but should fail at line number %u: %s\\n\", lineno, prog);\n        goto fail;\n      }\n      char *err_buf = err_msg.buf;\n      while (fgets(buf, sizeof(buf), testdata)) {\n        lineno++;\n        if (skipline(buf)) break;\n        if (check_msg) {\n          if (buf[strlen(buf)-1] == '\\n') buf[strlen(buf)-1] = '\\0';\n          if (strncmp(buf, err_buf, strlen(buf)) != 0) {\n            if (strchr(err_buf, '\\n')) *strchr(err_buf, '\\n') = '\\0';\n            printf(\"*** Erroneous program failed with '%s', but expected '%s' at line number %u: %s\\n\", err_buf, buf, lineno, prog);\n            goto fail;\n          }\n          err_buf += strlen(buf);\n          if (*err_buf == '\\n') err_buf++;\n        }\n      }\n      if (check_msg && *err_buf != '\\0') {\n        if (strchr(err_buf, '\\n')) *strchr(err_buf, '\\n') = '\\0';\n        printf(\"*** Erroneous program failed with extra message '%s' at line %u: %s\\n\", err_buf, lineno, prog);\n        invalid++;\n        pass = 0;\n      }\n      must_fail = 0;\n      check_msg = 0;\n      passed += pass;\n      continue;\n    }\n\n    if (!compiled) {\n      printf(\"*** Test program failed to compile at line %u: %s\\n\", lineno, prog);\n      goto fail;\n    }\n    if (verbose) {\n      printf(\"Disassembly:\\n\");\n      jq_dump_disassembly(jq, 2);\n      printf(\"\\n\");\n    }\n    if (!fgets(buf, sizeof(buf), testdata)) { invalid++; break; }\n    lineno++;\n    jv input = jv_parse(buf);\n    if (!jv_is_valid(input)) {\n      printf(\"*** Input is invalid on line %u: %s\\n\", lineno, buf);\n      goto fail;\n    }\n    jq_start(jq, input, verbose ? JQ_DEBUG_TRACE : 0);\n\n    while (fgets(buf, sizeof(buf), testdata)) {\n      lineno++;\n      if (skipline(buf)) break;\n      jv expected = jv_parse(buf);\n      if (!jv_is_valid(expected)) {\n        printf(\"*** Expected result is invalid on line %u: %s\\n\", lineno, buf);\n        goto fail;\n      }\n      jv actual = jq_next(jq);\n      if (!jv_is_valid(actual)) {\n        jv_free(expected);\n        jv_free(actual);\n        printf(\"*** Insufficient results for test at line number %u: %s\\n\", lineno, prog);\n        pass = 0;\n        break;\n      } else if (!jv_equal(jv_copy(expected), jv_copy(actual))) {\n        printf(\"*** Expected \");\n        jv_dump(jv_copy(expected), 0);\n        printf(\", but got \");\n        jv_dump(jv_copy(actual), 0);\n        printf(\" for test at line number %u: %s\\n\", lineno, prog);\n        pass = 0;\n      }\n#ifdef USE_DECNUM\n      jv as_string = jv_dump_string(jv_copy(expected), 0);\n      jv reparsed = jv_parse_sized(jv_string_value(as_string), jv_string_length_bytes(jv_copy(as_string)));\n      if (!jv_equal(jv_copy(expected), jv_copy(reparsed))) {\n        printf(\"*** Expected result should be equal after reparsing, but got \");\n        jv_dump(jv_copy(reparsed), 0);\n        printf(\" for test at line %u: %s\\n\", lineno, buf);\n        pass = 0;\n      }\n      jv_free(as_string);\n      jv_free(reparsed);\n#endif\n      jv_free(expected);\n      jv_free(actual);\n    }\n    if (pass) {\n      jv extra = jq_next(jq);\n      if (jv_is_valid(extra)) {\n        printf(\"*** Superfluous result: \");\n        jv_dump(extra, 0);\n        printf(\" for test at line number %u, %s\\n\", lineno, prog);\n        invalid++;\n        pass = 0;\n      } else {\n        jv_free(extra);\n      }\n    }\n    passed += pass;\n    continue;\n\nfail:\n    invalid++;\n\nnext:\n    while (fgets(buf, sizeof(buf), testdata)) {\n      lineno++;\n      if (skipline(buf)) break;\n    }\n    must_fail = 0;\n    check_msg = 0;\n  }\n  jq_teardown(&jq);\n\n  int total_skipped = tests_to_skip;\n\n  if (skip > 0) {\n    total_skipped = tests_to_skip - skip;\n  }\n\n  printf(\"%d of %d tests passed (%d malformed, %d skipped)\\n\",\n    passed, tests, invalid, total_skipped);\n\n  if (skip > 0) {\n    printf(\"WARN: skipped past the end of file, exiting with status 2\\n\");\n    exit(2);\n  }\n\n  if (passed != tests) exit(1);\n}\n\n\nstatic int test_start_state(jq_state *jq, char *prog) {\n  int pass = 1;\n  jv message = jq_get_error_message(jq);\n  if (jv_is_valid(message)) {\n    printf(\"*** Expected error_message to be invalid after jq_start: %s\\n\", prog);\n    pass = 0;\n  }\n  jv_free(message);\n\n  jv exit_code = jq_get_exit_code(jq);\n  if (jv_is_valid(exit_code)) {\n    printf(\"*** Expected exit_code to be invalid after jq_start: %s\\n\", prog);\n    pass = 0;\n  }\n  jv_free(exit_code);\n\n  if (jq_halted(jq)) {\n    printf(\"*** Expected jq to not be halted after jq_start: %s\\n\", prog);\n    pass = 0;\n  }\n\n  return pass;\n}\n\n// Test jq_state is reset after subsequent calls to jq_start.\nstatic void test_jq_start_resets_state(char *prog, const char *input) {\n  printf(\"Test jq_state: %s\\n\", prog);\n  jq_state *jq = jq_init();\n  assert(jq);\n\n  int compiled = jq_compile(jq, prog);\n  assert(compiled);\n\n  // First call to jq_start. Run until completion.\n  jv parsed_input = jv_parse(input);\n  assert(jv_is_valid(parsed_input));\n  jq_start(jq, parsed_input, 0);\n  assert(test_start_state(jq, prog));\n  while (1) {\n    jv result = jq_next(jq);\n    int valid = jv_is_valid(result);\n    jv_free(result);\n    if (!valid) { break; }\n  }\n\n  // Second call to jq_start.\n  jv parsed_input2 = jv_parse(input);\n  assert(jv_is_valid(parsed_input2));\n  jq_start(jq, parsed_input2, 0);\n  assert(test_start_state(jq, prog));\n\n  jq_teardown(&jq);\n}\n\nstatic void run_jq_start_state_tests(void) {\n  test_jq_start_resets_state(\".[]\", \"[1,2,3]\");\n  test_jq_start_resets_state(\".[] | if .%2 == 0 then halt_error else . end\", \"[1,2,3]\");\n}\n\nstatic void compile_args_and_check(jq_state *jq, const char *prog,\n                                   jv args, jv input, jv expected) {\n  printf(\"  subtest: %s\\n\", prog);\n  int compiled = jq_compile_args(jq, prog, args);\n  assert(compiled);\n\n  jq_start(jq, input, 0);\n  jv result = jq_next(jq);\n  assert(jv_is_valid(result));\n  assert(jv_equal(result, expected));\n\n  jv extra = jq_next(jq);\n  assert(!jv_is_valid(extra));\n  jv_free(extra);\n}\n\n// Test that jq_compile_args() with array arguments handles jv\n// refcounting correctly in args2obj(). The array path converts\n// [{\"name\":\"k\",\"value\":\"v\"}, ...] into {\"k\":\"v\", ...}.\nstatic void run_jq_compile_args_tests(void) {\n  printf(\"Test jq_compile_args with array args\\n\");\n  jq_state *jq = jq_init();\n  assert(jq);\n\n  // Empty array: loop body never runs, kk/vk allocated and freed\n  compile_args_and_check(jq, \"42\",\n    jv_array(), jv_null(), jv_number(42));\n\n  // Single element: one iteration, no reuse of kk/vk\n  compile_args_and_check(jq, \"$val\",\n    JV_ARRAY(JV_OBJECT(jv_string(\"name\"), jv_string(\"val\"),\n                       jv_string(\"value\"), jv_number(42))),\n    jv_null(), jv_number(42));\n\n  // Two elements: minimum to trigger former UAF on iteration 2\n  compile_args_and_check(jq, \"$x + $y\",\n    JV_ARRAY(JV_OBJECT(jv_string(\"name\"), jv_string(\"x\"),\n                       jv_string(\"value\"), jv_number(1)),\n             JV_OBJECT(jv_string(\"name\"), jv_string(\"y\"),\n                       jv_string(\"value\"), jv_number(2))),\n    jv_null(), jv_number(3));\n\n  // Three elements: exercises further loop iterations\n  compile_args_and_check(jq, \"$a + $b + $c\",\n    JV_ARRAY(JV_OBJECT(jv_string(\"name\"), jv_string(\"a\"),\n                       jv_string(\"value\"), jv_string(\"hello\")),\n             JV_OBJECT(jv_string(\"name\"), jv_string(\"b\"),\n                       jv_string(\"value\"), jv_string(\" \")),\n             JV_OBJECT(jv_string(\"name\"), jv_string(\"c\"),\n                       jv_string(\"value\"), jv_string(\"world\"))),\n    jv_null(), jv_string(\"hello world\"));\n\n  // Object args: bypasses args2obj loop via early return\n  compile_args_and_check(jq, \"$x * $y\",\n    JV_OBJECT(jv_string(\"x\"), jv_number(10),\n              jv_string(\"y\"), jv_number(20)),\n    jv_null(), jv_number(200));\n\n  jq_teardown(&jq);\n}\n\n\n// Test that recompiling on the same jq_state doesn't leak or\n// double-free the previous bytecode, and that switching between\n// jq_compile and jq_compile_args works correctly.\nstatic void run_jq_recompile_tests(void) {\n  printf(\"Test jq recompile on same state\\n\");\n  jq_state *jq = jq_init();\n  assert(jq);\n\n  // First program via jq_compile\n  int compiled = jq_compile(jq, \". + 1\");\n  assert(compiled);\n  jq_start(jq, jv_number(1), 0);\n  jv r = jq_next(jq);\n  assert(jv_is_valid(r));\n  assert(jv_number_value(r) == 2);\n  jv_free(r);\n  r = jq_next(jq);\n  assert(!jv_is_valid(r));\n  jv_free(r);\n\n  // Recompile with a different program on the same state\n  compiled = jq_compile(jq, \". * 2\");\n  assert(compiled);\n  jq_start(jq, jv_number(5), 0);\n  r = jq_next(jq);\n  assert(jv_is_valid(r));\n  assert(jv_number_value(r) == 10);\n  jv_free(r);\n  r = jq_next(jq);\n  assert(!jv_is_valid(r));\n  jv_free(r);\n\n  // Recompile via jq_compile_args with array args (args2obj path)\n  compiled = jq_compile_args(jq, \"$n + $m\",\n    JV_ARRAY(JV_OBJECT(jv_string(\"name\"), jv_string(\"n\"),\n                       jv_string(\"value\"), jv_number(100)),\n             JV_OBJECT(jv_string(\"name\"), jv_string(\"m\"),\n                       jv_string(\"value\"), jv_number(7))));\n  assert(compiled);\n  jq_start(jq, jv_null(), 0);\n  r = jq_next(jq);\n  assert(jv_is_valid(r));\n  assert(jv_number_value(r) == 107);\n  jv_free(r);\n  r = jq_next(jq);\n  assert(!jv_is_valid(r));\n  jv_free(r);\n\n  // Back to jq_compile after jq_compile_args\n  compiled = jq_compile(jq, \". - 1\");\n  assert(compiled);\n  jq_start(jq, jv_number(10), 0);\n  r = jq_next(jq);\n  assert(jv_is_valid(r));\n  assert(jv_number_value(r) == 9);\n  jv_free(r);\n  r = jq_next(jq);\n  assert(!jv_is_valid(r));\n  jv_free(r);\n\n  jq_teardown(&jq);\n}\n\n\n// Test that exhausting jq_next doesn't corrupt state, and that\n// the same jq_state can be reused with jq_start after exhaustion.\nstatic void run_jq_exhaust_and_reuse_tests(void) {\n  printf(\"Test jq exhaust and reuse\\n\");\n  jq_state *jq = jq_init();\n  assert(jq);\n\n  int compiled = jq_compile(jq, \".[]\");\n  assert(compiled);\n\n  // First run: drain all results\n  jq_start(jq, jv_parse(\"[1,2,3]\"), 0);\n  for (int i = 1; i <= 3; i++) {\n    jv r = jq_next(jq);\n    assert(jv_is_valid(r));\n    assert(jv_number_value(r) == i);\n    jv_free(r);\n  }\n  jv r = jq_next(jq);\n  assert(!jv_is_valid(r));\n  jv_free(r);\n\n  // Reuse with new input on the same compiled program\n  jq_start(jq, jv_parse(\"[10,20]\"), 0);\n  r = jq_next(jq);\n  assert(jv_is_valid(r));\n  assert(jv_number_value(r) == 10);\n  jv_free(r);\n  r = jq_next(jq);\n  assert(jv_is_valid(r));\n  assert(jv_number_value(r) == 20);\n  jv_free(r);\n  r = jq_next(jq);\n  assert(!jv_is_valid(r));\n  jv_free(r);\n\n  // Reuse again with empty array (zero results)\n  jq_start(jq, jv_parse(\"[]\"), 0);\n  r = jq_next(jq);\n  assert(!jv_is_valid(r));\n  jv_free(r);\n\n  // Reuse once more after zero-result run\n  jq_start(jq, jv_parse(\"[99]\"), 0);\n  r = jq_next(jq);\n  assert(jv_is_valid(r));\n  assert(jv_number_value(r) == 99);\n  jv_free(r);\n  r = jq_next(jq);\n  assert(!jv_is_valid(r));\n  jv_free(r);\n\n  jq_teardown(&jq);\n}\n\n\n/// pthread regression test\n#ifdef HAVE_PTHREAD\n#define NUMBER_OF_THREADS 3\nstruct test_pthread_data {\n    int result;\n};\n\nstatic int test_pthread_jq_parse(jq_state *jq, struct jv_parser *parser)\n{\n    int rv = 0;\n    jv value;\n\n    value = jv_parser_next(parser);\n    while (jv_is_valid(value)) {\n        jq_start(jq, value, 0);\n        jv result = jq_next(jq);\n\n        while (jv_is_valid(result)) {\n            jv_free(result);\n            result = jq_next(jq);\n        }\n        jv_free(result);\n        value = jv_parser_next(parser);\n    }\n    jv_free(value);\n    return rv;\n}\n\nstatic void *test_pthread_run(void *ptr) {\n    int rv;\n    jq_state *jq;\n    const char *prg = \".data\";\n    const char *buf = \"{ \\\"data\\\": 1 }\";\n    struct test_pthread_data *data = ptr;\n\n    jq = jq_init();\n    if (jq_compile(jq, prg) == 0) {\n        jq_teardown(&jq);\n        return NULL;\n    }\n\n    struct jv_parser *parser = jv_parser_new(0);\n    jv_parser_set_buf(parser, buf, strlen(buf), 0);\n    rv = test_pthread_jq_parse(jq, parser);\n\n    data->result = rv;\n\n    jv_parser_free(parser);\n    jq_teardown(&jq);\n    return NULL;\n}\n\nstatic void run_jq_pthread_tests(void) {\n    pthread_t threads[NUMBER_OF_THREADS];\n    struct test_pthread_data data[NUMBER_OF_THREADS];\n    int createerror;\n    int a;\n\n    memset(&threads, 0, sizeof(threads));\n    memset(&data, 0, sizeof(data));\n\n    // Create all threads\n    for (a = 0; a < NUMBER_OF_THREADS; ++a) {\n        createerror = pthread_create(&threads[a], NULL, test_pthread_run, &data[a]);\n        assert(createerror == 0);\n    }\n\n    // wait for all threads\n    for(a = 0; a < NUMBER_OF_THREADS; ++a) {\n#ifdef __MVS__\n        if (threads[a].__ != 0) {\n#else\n        if (threads[a] != 0) {\n#endif\n            pthread_join(threads[a], NULL);\n        }\n    }\n\n    // check results\n    for(a = 0; a < NUMBER_OF_THREADS; ++a) {\n        assert(data[a].result == 0);\n    }\n}\n#endif // HAVE_PTHREAD\n\n\nstatic void jv_test(void) {\n  /// JSON parser regression tests\n  {\n    jv v = jv_parse(\"{\\\"a':\\\"12\\\"}\");\n    assert(jv_get_kind(v) == JV_KIND_INVALID);\n    v = jv_invalid_get_msg(v);\n    assert(strcmp(jv_string_value(v), \"Expected separator between values at line 1, column 9 (while parsing '{\\\"a':\\\"12\\\"}')\") == 0);\n    jv_free(v);\n  }\n  /// Arrays and numbers\n  {\n    jv a = jv_array();\n    assert(jv_get_kind(a) == JV_KIND_ARRAY);\n    assert(jv_array_length(jv_copy(a)) == 0);\n    assert(jv_array_length(jv_copy(a)) == 0);\n\n    a = jv_array_append(a, jv_number(42));\n    assert(jv_array_length(jv_copy(a)) == 1);\n    assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42);\n\n    jv a2 = jv_array_append(jv_array(), jv_number(42));\n    assert(jv_equal(jv_copy(a), jv_copy(a)));\n    assert(jv_equal(jv_copy(a2), jv_copy(a2)));\n    assert(jv_equal(jv_copy(a), jv_copy(a2)));\n    assert(jv_equal(jv_copy(a2), jv_copy(a)));\n    jv_free(a2);\n\n    a2 = jv_array_append(jv_array(), jv_number(19));\n    assert(!jv_equal(jv_copy(a), jv_copy(a2)));\n    assert(!jv_equal(jv_copy(a2), jv_copy(a)));\n    jv_free(a2);\n\n\n    assert(jv_get_refcnt(a) == 1);\n    a = jv_array_append(a, jv_copy(a));\n    assert(jv_get_refcnt(a) == 1);\n\n    assert(jv_array_length(jv_copy(a)) == 2);\n    assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42);\n\n    for (int i=0; i<10; i++) {\n      jv subarray = jv_array_get(jv_copy(a), 1);\n      assert(jv_get_kind(subarray) == JV_KIND_ARRAY);\n      assert(jv_array_length(jv_copy(subarray)) == 1);\n      assert(jv_number_value(jv_array_get(jv_copy(subarray), 0)) == 42);\n      jv_free(subarray);\n    }\n\n\n    jv subarray = jv_array_get(jv_copy(a), 1);\n    assert(jv_get_kind(subarray) == JV_KIND_ARRAY);\n    assert(jv_array_length(jv_copy(subarray)) == 1);\n    assert(jv_number_value(jv_array_get(jv_copy(subarray), 0)) == 42);\n\n    jv sub2 = jv_copy(subarray);\n    sub2 = jv_array_append(sub2, jv_number(19));\n\n    assert(jv_get_kind(sub2) == JV_KIND_ARRAY);\n    assert(jv_array_length(jv_copy(sub2)) == 2);\n    assert(jv_number_value(jv_array_get(jv_copy(sub2), 0)) == 42);\n    assert(jv_number_value(jv_array_get(jv_copy(sub2), 1)) == 19);\n\n    assert(jv_get_kind(subarray) == JV_KIND_ARRAY);\n    assert(jv_array_length(jv_copy(subarray)) == 1);\n    assert(jv_number_value(jv_array_get(jv_copy(subarray), 0)) == 42);\n\n    jv_free(subarray);\n\n    void* before = sub2.u.ptr;\n    sub2 = jv_array_append(sub2, jv_number(200));\n    void* after = sub2.u.ptr;\n    assert(before == after);\n    jv_free(sub2);\n\n    jv a3 = jv_array_append(jv_copy(a), jv_number(19));\n    assert(jv_array_length(jv_copy(a3)) == 3);\n    assert(jv_number_value(jv_array_get(jv_copy(a3), 0)) == 42);\n    assert(jv_array_length(jv_array_get(jv_copy(a3), 1)) == 1);\n    assert(jv_number_value(jv_array_get(jv_copy(a3), 2)) == 19);\n    jv_free(a3);\n\n\n    jv a4 = jv_array();\n    a4 = jv_array_append(a4, jv_number(1));\n    a4 = jv_array_append(a4, jv_number(2));\n    jv a5 = jv_copy(a4);\n    a4 = jv_array_append(a4, jv_number(3));\n    a4 = jv_array_slice(a4, 0, 1);\n    assert(jv_array_length(jv_copy(a4)) == 1);\n    a4 = jv_array_append(a4, jv_number(4));\n    assert(jv_array_length(jv_copy(a4)) == 2);\n    assert(jv_array_length(jv_copy(a5)) == 2);\n    jv_free(a4);\n    jv_free(a5);\n\n\n    assert(jv_array_length(jv_copy(a)) == 2);\n    assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42);\n    assert(jv_array_length(jv_array_get(jv_copy(a), 1)) == 1);\n\n\n    //jv_dump(jv_copy(a), 0); printf(\"\\n\");\n    jv_free(a);\n  }\n\n\n  /// Strings\n  {\n    assert(jv_equal(jv_string(\"foo\"), jv_string_sized(\"foo\", 3)));\n    char nasty[] = \"foo\\0\";\n    jv shortstr = jv_string(nasty), longstr = jv_string_sized(nasty, sizeof(nasty));\n    assert(jv_string_length_bytes(jv_copy(shortstr)) == (int)strlen(nasty));\n    assert(jv_string_length_bytes(jv_copy(longstr)) == (int)sizeof(nasty));\n    jv_free(shortstr);\n    jv_free(longstr);\n\n\n    char a1s[] = \"hello\", a2s[] = \"hello\", bs[] = \"goodbye\";\n    jv a1 = jv_string(a1s), a2 = jv_string(a2s), b = jv_string(bs);\n    assert(jv_equal(jv_copy(a1), jv_copy(a2)));\n    assert(jv_equal(jv_copy(a2), jv_copy(a1)));\n    assert(!jv_equal(jv_copy(a1), jv_copy(b)));\n\n    assert(jv_string_hash(jv_copy(a1)) == jv_string_hash(jv_copy(a1)));\n    assert(jv_string_hash(jv_copy(a1)) == jv_string_hash(jv_copy(a2)));\n    assert(jv_string_hash(jv_copy(b)) != jv_string_hash(jv_copy(a1)));\n    jv_free(a1);\n    jv_free(a2);\n    jv_free(b);\n\n    assert(jv_equal(jv_string(\"hello42!\"), jv_string_fmt(\"hello%d%s\", 42, \"!\")));\n    char big[20000];\n    for (int i=0; i<(int)sizeof(big); i++) big[i] = 'a';\n    big[sizeof(big)-1] = 0;\n    jv str = jv_string_fmt(\"%s\", big);\n    assert(jv_string_length_bytes(jv_copy(str)) == sizeof(big) - 1);\n    assert(!strcmp(big, jv_string_value(str)));\n    jv_free(str);\n  }\n\n  /// Objects\n  {\n    jv o1 = jv_object();\n    o1 = jv_object_set(o1, jv_string(\"foo\"), jv_number(42));\n    o1 = jv_object_set(o1, jv_string(\"bar\"), jv_number(24));\n    assert(jv_number_value(jv_object_get(jv_copy(o1), jv_string(\"foo\"))) == 42);\n    assert(jv_number_value(jv_object_get(jv_copy(o1), jv_string(\"bar\"))) == 24);\n\n    jv o2 = jv_object_set(jv_copy(o1), jv_string(\"foo\"), jv_number(420));\n    o2 = jv_object_set(o2, jv_string(\"bar\"), jv_number(240));\n    assert(jv_number_value(jv_object_get(jv_copy(o1), jv_string(\"foo\"))) == 42);\n    assert(jv_number_value(jv_object_get(jv_copy(o1), jv_string(\"bar\"))) == 24);\n    assert(jv_number_value(jv_object_get(jv_copy(o2), jv_string(\"foo\"))) == 420);\n    jv_free(o1);\n    assert(jv_number_value(jv_object_get(jv_copy(o2), jv_string(\"bar\"))) == 240);\n\n    //jv_dump(jv_copy(o2), 0); printf(\"\\n\");\n    jv_free(o2);\n  }\n}\n"
  },
  {
    "path": "src/jv.c",
    "content": "/*\n * Portions Copyright (c) 2016 Kungliga Tekniska Högskolan\n * (Royal Institute of Technology, Stockholm, Sweden).\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\n * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\n * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n\n#include <stdint.h>\n#include <stddef.h>\n#include <assert.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <stdarg.h>\n#include <limits.h>\n#include <math.h>\n#include <float.h>\n\n#include \"jv_alloc.h\"\n#include \"jv.h\"\n#include \"jv_unicode.h\"\n#include \"util.h\"\n\n/*\n * Internal refcounting helpers\n */\n\ntypedef struct jv_refcnt {\n  int count;\n} jv_refcnt;\n\nstatic const jv_refcnt JV_REFCNT_INIT = {1};\n\nstatic void jvp_refcnt_inc(jv_refcnt* c) {\n  c->count++;\n}\n\nstatic int jvp_refcnt_dec(jv_refcnt* c) {\n  c->count--;\n  return c->count == 0;\n}\n\nstatic int jvp_refcnt_unshared(jv_refcnt* c) {\n  assert(c->count > 0);\n  return c->count == 1;\n}\n\n#define KIND_MASK   0xF\n#define PFLAGS_MASK 0xF0\n#define PTYPE_MASK  0x70\n\ntypedef enum {\n  JVP_PAYLOAD_NONE = 0,\n  JVP_PAYLOAD_ALLOCATED = 0x80,\n} payload_flags;\n\n#define JVP_MAKE_PFLAGS(ptype, allocated) ((((ptype) << 4) & PTYPE_MASK) | ((allocated) ? JVP_PAYLOAD_ALLOCATED : 0))\n#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))\n\n#define JVP_FLAGS(j)  ((j).kind_flags)\n#define JVP_KIND(j)   (JVP_FLAGS(j) & KIND_MASK)\n\n#define JVP_HAS_FLAGS(j, flags) (JVP_FLAGS(j) == flags)\n#define JVP_HAS_KIND(j, kind)   (JVP_KIND(j) == kind)\n\n#define JVP_IS_ALLOCATED(j) (j.kind_flags & JVP_PAYLOAD_ALLOCATED)\n\n#define JVP_FLAGS_NULL      JVP_MAKE_FLAGS(JV_KIND_NULL, JVP_PAYLOAD_NONE)\n#define JVP_FLAGS_INVALID   JVP_MAKE_FLAGS(JV_KIND_INVALID, JVP_PAYLOAD_NONE)\n#define JVP_FLAGS_FALSE     JVP_MAKE_FLAGS(JV_KIND_FALSE, JVP_PAYLOAD_NONE)\n#define JVP_FLAGS_TRUE      JVP_MAKE_FLAGS(JV_KIND_TRUE, JVP_PAYLOAD_NONE)\n\njv_kind jv_get_kind(jv x) {\n  return JVP_KIND(x);\n}\n\nconst char* jv_kind_name(jv_kind k) {\n  switch (k) {\n  case JV_KIND_INVALID: return \"<invalid>\";\n  case JV_KIND_NULL:    return \"null\";\n  case JV_KIND_FALSE:   return \"boolean\";\n  case JV_KIND_TRUE:    return \"boolean\";\n  case JV_KIND_NUMBER:  return \"number\";\n  case JV_KIND_STRING:  return \"string\";\n  case JV_KIND_ARRAY:   return \"array\";\n  case JV_KIND_OBJECT:  return \"object\";\n  }\n  assert(0 && \"invalid kind\");\n  return \"<unknown>\";\n}\n\nconst jv JV_NULL = {JVP_FLAGS_NULL, 0, 0, 0, {0}};\nconst jv JV_INVALID = {JVP_FLAGS_INVALID, 0, 0, 0, {0}};\nconst jv JV_FALSE = {JVP_FLAGS_FALSE, 0, 0, 0, {0}};\nconst jv JV_TRUE = {JVP_FLAGS_TRUE, 0, 0, 0, {0}};\n\njv jv_true(void) {\n  return JV_TRUE;\n}\n\njv jv_false(void) {\n  return JV_FALSE;\n}\n\njv jv_null(void) {\n  return JV_NULL;\n}\n\njv jv_bool(int x) {\n  return x ? JV_TRUE : JV_FALSE;\n}\n\n/*\n * Invalid objects, with optional error messages\n */\n\n#define JVP_FLAGS_INVALID_MSG   JVP_MAKE_FLAGS(JV_KIND_INVALID, JVP_PAYLOAD_ALLOCATED)\n\ntypedef struct {\n  jv_refcnt refcnt;\n  jv errmsg;\n} jvp_invalid;\n\njv jv_invalid_with_msg(jv err) {\n  jvp_invalid* i = jv_mem_alloc(sizeof(jvp_invalid));\n  i->refcnt = JV_REFCNT_INIT;\n  i->errmsg = err;\n\n  jv x = {JVP_FLAGS_INVALID_MSG, 0, 0, 0, {&i->refcnt}};\n  return x;\n}\n\njv jv_invalid(void) {\n  return JV_INVALID;\n}\n\njv jv_invalid_get_msg(jv inv) {\n  assert(JVP_HAS_KIND(inv, JV_KIND_INVALID));\n\n  jv x;\n  if (JVP_HAS_FLAGS(inv, JVP_FLAGS_INVALID_MSG)) {\n    x = jv_copy(((jvp_invalid*)inv.u.ptr)->errmsg);\n  }\n  else {\n    x = jv_null();\n  }\n\n  jv_free(inv);\n  return x;\n}\n\nint jv_invalid_has_msg(jv inv) {\n  assert(JVP_HAS_KIND(inv, JV_KIND_INVALID));\n  int r = JVP_HAS_FLAGS(inv, JVP_FLAGS_INVALID_MSG);\n  jv_free(inv);\n  return r;\n}\n\nstatic void jvp_invalid_free(jv x) {\n  assert(JVP_HAS_KIND(x, JV_KIND_INVALID));\n  if (JVP_HAS_FLAGS(x, JVP_FLAGS_INVALID_MSG) && jvp_refcnt_dec(x.u.ptr)) {\n    jv_free(((jvp_invalid*)x.u.ptr)->errmsg);\n    jv_mem_free(x.u.ptr);\n  }\n}\n\n/*\n * Numbers\n */\n\n#ifdef USE_DECNUM\n#include \"jv_dtoa.h\"\n#include \"jv_dtoa_tsd.h\"\n\n// we will manage the space for the struct\n#define DECNUMDIGITS 1\n#include \"decNumber/decNumber.h\"\n\nenum {\n  JVP_NUMBER_NATIVE = 0,\n  JVP_NUMBER_DECIMAL = 1\n};\n\n#define JVP_FLAGS_NUMBER_NATIVE       JVP_MAKE_FLAGS(JV_KIND_NUMBER, JVP_MAKE_PFLAGS(JVP_NUMBER_NATIVE, 0))\n#define JVP_FLAGS_NUMBER_LITERAL      JVP_MAKE_FLAGS(JV_KIND_NUMBER, JVP_MAKE_PFLAGS(JVP_NUMBER_DECIMAL, 1))\n\n// the decimal precision of binary double\n#define DEC_NUMBER_DOUBLE_PRECISION   (17)\n#define DEC_NUMBER_STRING_GUARD       (14)\n#define DEC_NUMBER_DOUBLE_EXTRA_UNITS ((DEC_NUMBER_DOUBLE_PRECISION - DECNUMDIGITS + DECDPUN - 1)/DECDPUN)\n\n#include \"jv_thread.h\"\n#ifdef WIN32\n#ifndef __MINGW32__\n/* Copied from Heimdal: thread-specific keys; see lib/base/dll.c in Heimdal */\n\n/*\n * This is an implementation of thread-specific storage with\n * destructors.  WIN32 doesn't quite have this.  Instead it has\n * DllMain(), an entry point in every DLL that gets called to notify the\n * DLL of thread/process \"attach\"/\"detach\" events.\n *\n * We use __thread (or __declspec(thread)) for the thread-local itself\n * and DllMain() DLL_THREAD_DETACH events to drive destruction of\n * thread-local values.\n *\n * When building in maintainer mode on non-Windows pthread systems this\n * uses a single pthread key instead to implement multiple keys.  This\n * keeps the code from rotting when modified by non-Windows developers.\n */\n\n/* Logical array of keys that grows lock-lessly */\ntypedef struct tls_keys tls_keys;\nstruct tls_keys {\n    void (**keys_dtors)(void *);    /* array of destructors         */\n    size_t keys_start_idx;          /* index of first destructor    */\n    size_t keys_num;\n    tls_keys *keys_next;\n};\n\n/*\n * Well, not quite locklessly.  We need synchronization primitives to do\n * this locklessly.  An atomic CAS will do.\n */\nstatic pthread_mutex_t tls_key_defs_lock = PTHREAD_MUTEX_INITIALIZER;\nstatic tls_keys *tls_key_defs;\n\n/* Logical array of values (per-thread; no locking needed here) */\nstruct tls_values {\n    void **values; /* realloc()ed */\n    size_t values_num;\n};\n\n#ifdef _MSC_VER\nstatic __declspec(thread) struct nomem_handler nomem_handler;\n#else\nstatic __thread struct tls_values values;\n#endif\n\n#define DEAD_KEY ((void *)8)\n\nstatic void\nw32_service_thread_detach(void *unused)\n{\n    tls_keys *key_defs;\n    void (*dtor)(void*);\n    size_t i;\n\n    pthread_mutex_lock(&tls_key_defs_lock);\n    key_defs = tls_key_defs;\n    pthread_mutex_unlock(&tls_key_defs_lock);\n\n    if (key_defs == NULL)\n        return;\n\n    for (i = 0; i < values.values_num; i++) {\n        assert(i >= key_defs->keys_start_idx);\n        if (i >= key_defs->keys_start_idx + key_defs->keys_num) {\n            pthread_mutex_lock(&tls_key_defs_lock);\n            key_defs = key_defs->keys_next;\n            pthread_mutex_unlock(&tls_key_defs_lock);\n\n            assert(key_defs != NULL);\n            assert(i >= key_defs->keys_start_idx);\n            assert(i < key_defs->keys_start_idx + key_defs->keys_num);\n        }\n        dtor = key_defs->keys_dtors[i - key_defs->keys_start_idx];\n        if (values.values[i] != NULL && dtor != NULL && dtor != DEAD_KEY)\n            dtor(values.values[i]);\n        values.values[i] = NULL;\n    }\n}\n\nextern void jv_tsd_dtoa_ctx_init();\nextern void jv_tsd_dtoa_ctx_fini();\nvoid jv_tsd_dec_ctx_fini();\nvoid jv_tsd_dec_ctx_init();\n\nBOOL WINAPI DllMain(HINSTANCE hinstDLL,\n                    DWORD fdwReason,\n                    LPVOID lpvReserved)\n{\n    switch (fdwReason) {\n    case DLL_PROCESS_ATTACH:\n\t/*create_pt_key();*/\n\tjv_tsd_dtoa_ctx_init();\n\tjv_tsd_dec_ctx_init();\n\treturn TRUE;\n    case DLL_PROCESS_DETACH:\n\tjv_tsd_dtoa_ctx_fini();\n\tjv_tsd_dec_ctx_fini();\n\treturn TRUE;\n    case DLL_THREAD_ATTACH: return 0;\n    case DLL_THREAD_DETACH:\n        w32_service_thread_detach(NULL);\n        return TRUE;\n    default: return TRUE;\n    }\n}\n\nint\npthread_key_create(pthread_key_t *key, void (*dtor)(void *))\n{\n    tls_keys *key_defs, *new_key_defs;\n    size_t i, k;\n    int ret = ENOMEM;\n\n    pthread_mutex_lock(&tls_key_defs_lock);\n    if (tls_key_defs == NULL) {\n        /* First key */\n        new_key_defs = calloc(1, sizeof(*new_key_defs));\n        if (new_key_defs == NULL) {\n            pthread_mutex_unlock(&tls_key_defs_lock);\n            return ENOMEM;\n        }\n        new_key_defs->keys_num = 8;\n        new_key_defs->keys_dtors = calloc(new_key_defs->keys_num,\n                                          sizeof(*new_key_defs->keys_dtors));\n        if (new_key_defs->keys_dtors == NULL) {\n            pthread_mutex_unlock(&tls_key_defs_lock);\n            free(new_key_defs);\n            return ENOMEM;\n        }\n        tls_key_defs = new_key_defs;\n        new_key_defs->keys_dtors[0] = dtor;\n        for (i = 1; i < new_key_defs->keys_num; i++)\n            new_key_defs->keys_dtors[i] = NULL;\n        pthread_mutex_unlock(&tls_key_defs_lock);\n        return 0;\n    }\n\n    for (key_defs = tls_key_defs;\n         key_defs != NULL;\n         key_defs = key_defs->keys_next) {\n        k = key_defs->keys_start_idx;\n        for (i = 0; i < key_defs->keys_num; i++, k++) {\n            if (key_defs->keys_dtors[i] == NULL) {\n                /* Found free slot; use it */\n                key_defs->keys_dtors[i] = dtor;\n                *key = k;\n                pthread_mutex_unlock(&tls_key_defs_lock);\n                return 0;\n            }\n        }\n        if (key_defs->keys_next != NULL)\n            continue;\n\n        /* Grow the registration array */\n        /* XXX DRY */\n        new_key_defs = calloc(1, sizeof(*new_key_defs));\n        if (new_key_defs == NULL)\n            break;\n\n        new_key_defs->keys_dtors =\n            calloc(key_defs->keys_num + key_defs->keys_num / 2,\n                   sizeof(*new_key_defs->keys_dtors));\n        if (new_key_defs->keys_dtors == NULL) {\n            free(new_key_defs);\n            break;\n        }\n        new_key_defs->keys_start_idx = key_defs->keys_start_idx +\n            key_defs->keys_num;\n        new_key_defs->keys_num = key_defs->keys_num + key_defs->keys_num / 2;\n        new_key_defs->keys_dtors[i] = dtor;\n        for (i = 1; i < new_key_defs->keys_num; i++)\n            new_key_defs->keys_dtors[i] = NULL;\n        key_defs->keys_next = new_key_defs;\n        ret = 0;\n        break;\n    }\n    pthread_mutex_unlock(&tls_key_defs_lock);\n    return ret;\n}\n\nstatic void\nkey_lookup(pthread_key_t key, tls_keys **kd,\n           size_t *dtor_idx, void (**dtor)(void *))\n{\n    tls_keys *key_defs;\n\n    if (kd != NULL)\n        *kd = NULL;\n    if (dtor_idx != NULL)\n        *dtor_idx = 0;\n    if (dtor != NULL)\n        *dtor = NULL;\n\n    pthread_mutex_lock(&tls_key_defs_lock);\n    key_defs = tls_key_defs;\n    pthread_mutex_unlock(&tls_key_defs_lock);\n\n    while (key_defs != NULL) {\n        if (key >= key_defs->keys_start_idx &&\n            key < key_defs->keys_start_idx + key_defs->keys_num) {\n            if (kd != NULL)\n                *kd = key_defs;\n            if (dtor_idx != NULL)\n                *dtor_idx = key - key_defs->keys_start_idx;\n            if (dtor != NULL)\n                *dtor = key_defs->keys_dtors[key - key_defs->keys_start_idx];\n            return;\n        }\n\n        pthread_mutex_lock(&tls_key_defs_lock);\n        key_defs = key_defs->keys_next;\n        pthread_mutex_unlock(&tls_key_defs_lock);\n        assert(key_defs != NULL);\n        assert(key >= key_defs->keys_start_idx);\n    }\n}\n\nint\npthread_setspecific(pthread_key_t key, void *value)\n{\n    void **new_values;\n    size_t new_num;\n    void (*dtor)(void *);\n    size_t i;\n\n    key_lookup(key, NULL, NULL, &dtor);\n    if (dtor == NULL)\n        return EINVAL;\n\n    if (key >= values.values_num) {\n        if (values.values_num == 0) {\n            values.values = NULL;\n            new_num = 8;\n        } else {\n            new_num = (values.values_num + values.values_num / 2);\n        }\n        new_values = realloc(values.values, sizeof(void *) * new_num);\n        if (new_values == NULL)\n            return ENOMEM;\n        for (i = values.values_num; i < new_num; i++)\n            new_values[i] = NULL;\n        values.values = new_values;\n        values.values_num = new_num;\n    }\n\n    assert(key < values.values_num);\n\n    if (values.values[key] != NULL && dtor != NULL && dtor != DEAD_KEY)\n        dtor(values.values[key]);\n\n    values.values[key] = value;\n    return 0;\n}\n\nvoid *\npthread_getspecific(pthread_key_t key)\n{\n    if (key >= values.values_num)\n        return NULL;\n    return values.values[key];\n}\n#else\n#include <pthread.h>\n#endif\n#else\n#include <pthread.h>\n#endif\n\nstatic pthread_key_t dec_ctx_key;\nstatic pthread_once_t dec_ctx_once = PTHREAD_ONCE_INIT;\n\n#define DEC_CONTEXT() tsd_dec_ctx_get(&dec_ctx_key)\n\n// atexit finalizer to clean up the tsd dec contexts if main() exits\n// without having called pthread_exit()\nvoid jv_tsd_dec_ctx_fini(void) {\n  jv_mem_free(pthread_getspecific(dec_ctx_key));\n  pthread_setspecific(dec_ctx_key, NULL);\n}\n\nvoid jv_tsd_dec_ctx_init(void) {\n  if (pthread_key_create(&dec_ctx_key, jv_mem_free) != 0) {\n    fprintf(stderr, \"error: cannot create thread specific key\");\n    abort();\n  }\n  atexit(jv_tsd_dec_ctx_fini);\n}\n\nstatic decContext* tsd_dec_ctx_get(pthread_key_t *key) {\n  pthread_once(&dec_ctx_once, jv_tsd_dec_ctx_init); // cannot fail\n  decContext *ctx = (decContext*)pthread_getspecific(*key);\n  if (ctx) {\n    return ctx;\n  }\n\n  ctx = malloc(sizeof(decContext));\n  if (ctx) {\n    if (key == &dec_ctx_key)\n    {\n      decContextDefault(ctx, DEC_INIT_BASE);\n      // make sure (Int)D2U(rhs->exponent-lhs->exponent) does not overflow\n      ctx->digits = MIN(DEC_MAX_DIGITS,\n          INT32_MAX - (DECDPUN - 1) - (ctx->emax - ctx->emin - 1));\n      ctx->traps = 0; /*no errors*/\n    }\n    if (pthread_setspecific(*key, ctx) != 0) {\n      fprintf(stderr, \"error: cannot store thread specific data\");\n      abort();\n    }\n  }\n  return ctx;\n}\n\ntypedef struct {\n  jv_refcnt refcnt;\n  double num_double;\n  char * literal_data;\n  decNumber num_decimal; // must be the last field in the structure for memory management\n} jvp_literal_number;\n\ntypedef struct {\n  decNumber number;\n  decNumberUnit units[DEC_NUMBER_DOUBLE_EXTRA_UNITS];\n} decNumberDoublePrecision;\n\n\nstatic inline int jvp_number_is_literal(jv n) {\n  assert(JVP_HAS_KIND(n, JV_KIND_NUMBER));\n  return JVP_HAS_FLAGS(n, JVP_FLAGS_NUMBER_LITERAL);\n}\n\nstatic jvp_literal_number* jvp_literal_number_ptr(jv j) {\n  assert(JVP_HAS_FLAGS(j, JVP_FLAGS_NUMBER_LITERAL));\n  return (jvp_literal_number*)j.u.ptr;\n}\n\nstatic decNumber* jvp_dec_number_ptr(jv j) {\n  assert(JVP_HAS_FLAGS(j, JVP_FLAGS_NUMBER_LITERAL));\n  return &(((jvp_literal_number*)j.u.ptr)->num_decimal);\n}\n\nstatic jvp_literal_number* jvp_literal_number_alloc(unsigned literal_length) {\n  /* The number of units needed is ceil(DECNUMDIGITS/DECDPUN)         */\n  int units = ((literal_length+DECDPUN-1)/DECDPUN);\n\n  jvp_literal_number* n = jv_mem_alloc(\n    sizeof(jvp_literal_number)\n    + sizeof(decNumberUnit) * units\n  );\n\n  n->refcnt = JV_REFCNT_INIT;\n  n->num_double = NAN;\n  n->literal_data = NULL;\n  return n;\n}\n\nstatic jv jvp_literal_number_new(const char * literal) {\n  jvp_literal_number* n = jvp_literal_number_alloc(strlen(literal));\n\n  decContext *ctx = DEC_CONTEXT();\n  decContextClearStatus(ctx, DEC_Conversion_syntax);\n  decNumberFromString(&n->num_decimal, literal, ctx);\n\n  if (ctx->status & DEC_Conversion_syntax) {\n    jv_mem_free(n);\n    return JV_INVALID;\n  }\n  if (decNumberIsNaN(&n->num_decimal)) {\n    // Reject NaN with payload.\n    if (n->num_decimal.digits > 1 || *n->num_decimal.lsu != 0) {\n      jv_mem_free(n);\n      return JV_INVALID;\n    }\n    jv_mem_free(n);\n    return jv_number(NAN);\n  }\n\n  jv r = {JVP_FLAGS_NUMBER_LITERAL, 0, 0, 0, {&n->refcnt}};\n  return r;\n}\n\nstatic double jvp_literal_number_to_double(jv j) {\n  assert(JVP_HAS_FLAGS(j, JVP_FLAGS_NUMBER_LITERAL));\n  decContext dblCtx;\n\n  // init as decimal64 but change digits to allow conversion to binary64 (double)\n  decContextDefault(&dblCtx, DEC_INIT_DECIMAL64);\n  dblCtx.digits = DEC_NUMBER_DOUBLE_PRECISION;\n\n  decNumber *p_dec_number = jvp_dec_number_ptr(j);\n  decNumberDoublePrecision dec_double;\n  char literal[DEC_NUMBER_DOUBLE_PRECISION + DEC_NUMBER_STRING_GUARD + 1];\n\n  // reduce the number to the shortest possible form\n  // that fits into the 64 bit floating point representation\n  decNumberReduce(&dec_double.number, p_dec_number, &dblCtx);\n\n  decNumberToString(&dec_double.number, literal);\n\n  char *end;\n  return jvp_strtod(tsd_dtoa_context_get(), literal, &end);\n}\n\nstatic const char* jvp_literal_number_literal(jv n) {\n  assert(JVP_HAS_FLAGS(n, JVP_FLAGS_NUMBER_LITERAL));\n  decNumber *pdec = jvp_dec_number_ptr(n);\n  jvp_literal_number* plit = jvp_literal_number_ptr(n);\n\n  if (decNumberIsNaN(pdec)) {\n    return \"null\";\n  }\n\n  if (decNumberIsInfinite(pdec)) {\n    // We cannot preserve the literal data of numbers outside the limited\n    // range of exponent. Since `decNumberToString` returns \"Infinity\"\n    // (or \"-Infinity\"), and to reduce stack allocations as possible, we\n    // normalize infinities in the callers instead of printing the maximum\n    // (or minimum) double here.\n    return NULL;\n  }\n\n  if (plit->literal_data == NULL) {\n    int len = jvp_dec_number_ptr(n)->digits + 15 /* 14 + NUL */;\n    plit->literal_data = jv_mem_alloc(len);\n\n    // Preserve the actual precision as we have parsed it\n    // don't do decNumberTrim(pdec);\n\n    decNumberToString(pdec, plit->literal_data);\n  }\n\n  return plit->literal_data;\n}\n\nint jv_number_has_literal(jv n) {\n  assert(JVP_HAS_KIND(n, JV_KIND_NUMBER));\n  return JVP_HAS_FLAGS(n, JVP_FLAGS_NUMBER_LITERAL);\n}\n\nconst char* jv_number_get_literal(jv n) {\n  assert(JVP_HAS_KIND(n, JV_KIND_NUMBER));\n\n  if (JVP_HAS_FLAGS(n, JVP_FLAGS_NUMBER_LITERAL)) {\n    return jvp_literal_number_literal(n);\n  } else {\n    return NULL;\n  }\n}\n\njv jv_number_with_literal(const char * literal) {\n  return jvp_literal_number_new(literal);\n}\n#endif /* USE_DECNUM */\n\njv jv_number(double x) {\n  jv j = {\n#ifdef USE_DECNUM\n    JVP_FLAGS_NUMBER_NATIVE,\n#else\n    JV_KIND_NUMBER,\n#endif\n    0, 0, 0, {.number = x}\n  };\n  return j;\n}\n\nstatic void jvp_number_free(jv j) {\n  assert(JVP_HAS_KIND(j, JV_KIND_NUMBER));\n#ifdef USE_DECNUM\n  if (JVP_HAS_FLAGS(j, JVP_FLAGS_NUMBER_LITERAL) && jvp_refcnt_dec(j.u.ptr)) {\n    jvp_literal_number* n = jvp_literal_number_ptr(j);\n    if (n->literal_data) {\n      jv_mem_free(n->literal_data);\n    }\n    jv_mem_free(n);\n  }\n#endif\n}\n\ndouble jv_number_value(jv j) {\n  assert(JVP_HAS_KIND(j, JV_KIND_NUMBER));\n#ifdef USE_DECNUM\n  if (JVP_HAS_FLAGS(j, JVP_FLAGS_NUMBER_LITERAL)) {\n    jvp_literal_number* n = jvp_literal_number_ptr(j);\n\n    if (isnan(n->num_double)) {\n      n->num_double = jvp_literal_number_to_double(j);\n    }\n\n    return n->num_double;\n  }\n#endif\n  return j.u.number;\n}\n\nint jv_is_integer(jv j){\n  if (!JVP_HAS_KIND(j, JV_KIND_NUMBER)){\n    return 0;\n  }\n\n  double x = jv_number_value(j);\n\n  double ipart;\n  double fpart = modf(x, &ipart);\n\n  return fabs(fpart) < DBL_EPSILON;\n}\n\nint jvp_number_is_nan(jv n) {\n  assert(JVP_HAS_KIND(n, JV_KIND_NUMBER));\n\n#ifdef USE_DECNUM\n  if (JVP_HAS_FLAGS(n, JVP_FLAGS_NUMBER_LITERAL)) {\n    decNumber *pdec = jvp_dec_number_ptr(n);\n    return decNumberIsNaN(pdec);\n  }\n#endif\n  return isnan(n.u.number);\n}\n\njv jv_number_abs(jv n) {\n  assert(JVP_HAS_KIND(n, JV_KIND_NUMBER));\n\n#ifdef USE_DECNUM\n  if (JVP_HAS_FLAGS(n, JVP_FLAGS_NUMBER_LITERAL)) {\n    jvp_literal_number* m = jvp_literal_number_alloc(jvp_dec_number_ptr(n)->digits);\n\n    decNumberAbs(&m->num_decimal, jvp_dec_number_ptr(n), DEC_CONTEXT());\n    jv r = {JVP_FLAGS_NUMBER_LITERAL, 0, 0, 0, {&m->refcnt}};\n    return r;\n  }\n#endif\n  return jv_number(fabs(jv_number_value(n)));\n}\n\njv jv_number_negate(jv n) {\n  assert(JVP_HAS_KIND(n, JV_KIND_NUMBER));\n\n#ifdef USE_DECNUM\n  if (JVP_HAS_FLAGS(n, JVP_FLAGS_NUMBER_LITERAL)) {\n    jvp_literal_number* m = jvp_literal_number_alloc(jvp_dec_number_ptr(n)->digits);\n\n    decNumberMinus(&m->num_decimal, jvp_dec_number_ptr(n), DEC_CONTEXT());\n    jv r = {JVP_FLAGS_NUMBER_LITERAL, 0, 0, 0, {&m->refcnt}};\n    return r;\n  }\n#endif\n  return jv_number(-jv_number_value(n));\n}\n\nint jvp_number_cmp(jv a, jv b) {\n  assert(JVP_HAS_KIND(a, JV_KIND_NUMBER));\n  assert(JVP_HAS_KIND(b, JV_KIND_NUMBER));\n\n#ifdef USE_DECNUM\n  if (JVP_HAS_FLAGS(a, JVP_FLAGS_NUMBER_LITERAL) && JVP_HAS_FLAGS(b, JVP_FLAGS_NUMBER_LITERAL)) {\n    struct {\n      decNumber number;\n      decNumberUnit units[1];\n    } res;\n\n    decNumberCompare(&res.number,\n                     jvp_dec_number_ptr(a),\n                     jvp_dec_number_ptr(b),\n                     DEC_CONTEXT()\n                     );\n    if (decNumberIsZero(&res.number)) {\n      return 0;\n    } else if (decNumberIsNegative(&res.number)) {\n      return -1;\n    } else {\n      return 1;\n    }\n  }\n#endif\n  double da = jv_number_value(a), db = jv_number_value(b);\n  if (da < db) {\n    return -1;\n  } else if (da == db) {\n    return 0;\n  } else {\n    return 1;\n  }\n}\n\nstatic int jvp_number_equal(jv a, jv b) {\n  return jvp_number_cmp(a, b) == 0;\n}\n\n/*\n * Arrays (internal helpers)\n */\n\n#define ARRAY_SIZE_ROUND_UP(n) (((n)*3)/2)\n#define JVP_FLAGS_ARRAY   JVP_MAKE_FLAGS(JV_KIND_ARRAY, JVP_PAYLOAD_ALLOCATED)\n\nstatic int imax(int a, int b) {\n  if (a>b) return a;\n  else return b;\n}\n\n//FIXME signed vs unsigned\ntypedef struct {\n  jv_refcnt refcnt;\n  int length, alloc_length;\n  jv elements[];\n} jvp_array;\n\nstatic jvp_array* jvp_array_ptr(jv a) {\n  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));\n  return (jvp_array*)a.u.ptr;\n}\n\nstatic jvp_array* jvp_array_alloc(unsigned size) {\n  jvp_array* a = jv_mem_alloc(sizeof(jvp_array) + sizeof(jv) * size);\n  a->refcnt.count = 1;\n  a->length = 0;\n  a->alloc_length = size;\n  return a;\n}\n\nstatic jv jvp_array_new(unsigned size) {\n  jv r = {JVP_FLAGS_ARRAY, 0, 0, 0, {&jvp_array_alloc(size)->refcnt}};\n  return r;\n}\n\nstatic void jvp_array_free(jv a) {\n  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));\n  if (jvp_refcnt_dec(a.u.ptr)) {\n    jvp_array* array = jvp_array_ptr(a);\n    for (int i=0; i<array->length; i++) {\n      jv_free(array->elements[i]);\n    }\n    jv_mem_free(array);\n  }\n}\n\nstatic int jvp_array_length(jv a) {\n  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));\n  return a.size;\n}\n\nstatic int jvp_array_offset(jv a) {\n  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));\n  return a.offset;\n}\n\nstatic jv* jvp_array_read(jv a, int i) {\n  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));\n  if (i >= 0 && i < jvp_array_length(a)) {\n    jvp_array* array = jvp_array_ptr(a);\n    assert(i + jvp_array_offset(a) < array->length);\n    return &array->elements[i + jvp_array_offset(a)];\n  } else {\n    return 0;\n  }\n}\n\nstatic jv* jvp_array_write(jv* a, int i) {\n  assert(i >= 0);\n  jvp_array* array = jvp_array_ptr(*a);\n\n  int pos = i + jvp_array_offset(*a);\n  if (pos < array->alloc_length && jvp_refcnt_unshared(a->u.ptr)) {\n    // use existing array space\n    for (int j = array->length; j <= pos; j++) {\n      array->elements[j] = JV_NULL;\n    }\n    array->length = imax(pos + 1, array->length);\n    a->size = imax(i + 1, a->size);\n    return &array->elements[pos];\n  } else {\n    // allocate a new array\n    int new_length = imax(i + 1, jvp_array_length(*a));\n    jvp_array* new_array = jvp_array_alloc(ARRAY_SIZE_ROUND_UP(new_length));\n    int j;\n    for (j = 0; j < jvp_array_length(*a); j++) {\n      new_array->elements[j] =\n        jv_copy(array->elements[j + jvp_array_offset(*a)]);\n    }\n    for (; j < new_length; j++) {\n      new_array->elements[j] = JV_NULL;\n    }\n    new_array->length = new_length;\n    jvp_array_free(*a);\n    jv new_jv = {JVP_FLAGS_ARRAY, 0, 0, new_length, {&new_array->refcnt}};\n    *a = new_jv;\n    return &new_array->elements[i];\n  }\n}\n\nstatic int jvp_array_equal(jv a, jv b) {\n  if (jvp_array_length(a) != jvp_array_length(b))\n    return 0;\n  if (jvp_array_ptr(a) == jvp_array_ptr(b) &&\n      jvp_array_offset(a) == jvp_array_offset(b))\n    return 1;\n  for (int i=0; i<jvp_array_length(a); i++) {\n    if (!jv_equal(jv_copy(*jvp_array_read(a, i)),\n                  jv_copy(*jvp_array_read(b, i))))\n      return 0;\n  }\n  return 1;\n}\n\nstatic void jvp_clamp_slice_params(int len, int *pstart, int *pend)\n{\n  if (*pstart < 0) *pstart = len + *pstart;\n  if (*pend < 0) *pend = len + *pend;\n\n  if (*pstart < 0) *pstart = 0;\n  if (*pstart > len) *pstart = len;\n  if (*pend > len) *pend = len;\n  if (*pend < *pstart) *pend = *pstart;\n}\n\n\nstatic int jvp_array_contains(jv a, jv b) {\n  int r = 1;\n  jv_array_foreach(b, bi, belem) {\n    int ri = 0;\n    jv_array_foreach(a, ai, aelem) {\n      if (jv_contains(aelem, jv_copy(belem))) {\n        ri = 1;\n        break;\n      }\n    }\n    jv_free(belem);\n    if (!ri) {\n      r = 0;\n      break;\n    }\n  }\n  return r;\n}\n\n\n/*\n * Public\n */\n\nstatic jv jvp_array_slice(jv a, int start, int end) {\n  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));\n  int len = jvp_array_length(a);\n  jvp_clamp_slice_params(len, &start, &end);\n  assert(0 <= start && start <= end && end <= len);\n\n  // FIXME: maybe slice should reallocate if the slice is small enough\n  if (start == end) {\n    jv_free(a);\n    return jv_array();\n  }\n\n  if (a.offset + start >= 1 << (sizeof(a.offset) * CHAR_BIT)) {\n    jv r = jv_array_sized(end - start);\n    for (int i = start; i < end; i++)\n      r = jv_array_append(r, jv_array_get(jv_copy(a), i));\n    jv_free(a);\n    return r;\n  } else {\n    a.offset += start;\n    a.size = end - start;\n    return a;\n  }\n}\n\n/*\n * Arrays (public interface)\n */\n\njv jv_array_sized(int n) {\n  return jvp_array_new(n);\n}\n\njv jv_array(void) {\n  return jv_array_sized(16);\n}\n\nint jv_array_length(jv j) {\n  assert(JVP_HAS_KIND(j, JV_KIND_ARRAY));\n  int len = jvp_array_length(j);\n  jv_free(j);\n  return len;\n}\n\njv jv_array_get(jv j, int idx) {\n  assert(JVP_HAS_KIND(j, JV_KIND_ARRAY));\n  jv* slot = jvp_array_read(j, idx);\n  jv val;\n  if (slot) {\n    val = jv_copy(*slot);\n  } else {\n    val = jv_invalid();\n  }\n  jv_free(j);\n  return val;\n}\n\njv jv_array_set(jv j, int idx, jv val) {\n  assert(JVP_HAS_KIND(j, JV_KIND_ARRAY));\n\n  if (idx < 0)\n    idx = jvp_array_length(j) + idx;\n  if (idx < 0) {\n    jv_free(j);\n    jv_free(val);\n    return jv_invalid_with_msg(jv_string(\"Out of bounds negative array index\"));\n  }\n  if (idx > (INT_MAX >> 2) - jvp_array_offset(j)) {\n    jv_free(j);\n    jv_free(val);\n    return jv_invalid_with_msg(jv_string(\"Array index too large\"));\n  }\n  // copy/free of val,j coalesced\n  jv* slot = jvp_array_write(&j, idx);\n  jv_free(*slot);\n  *slot = val;\n  return j;\n}\n\njv jv_array_append(jv j, jv val) {\n  // copy/free of val,j coalesced\n  return jv_array_set(j, jv_array_length(jv_copy(j)), val);\n}\n\njv jv_array_concat(jv a, jv b) {\n  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));\n  assert(JVP_HAS_KIND(b, JV_KIND_ARRAY));\n\n  // FIXME: could be faster\n  jv_array_foreach(b, i, elem) {\n    a = jv_array_append(a, elem);\n    if (!jv_is_valid(a)) break;\n  }\n  jv_free(b);\n  return a;\n}\n\njv jv_array_slice(jv a, int start, int end) {\n  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));\n  // copy/free of a coalesced\n  return jvp_array_slice(a, start, end);\n}\n\njv jv_array_indexes(jv a, jv b) {\n  jv res = jv_array();\n  int idx = -1;\n  int alen = jv_array_length(jv_copy(a));\n  for (int ai = 0; ai < alen; ++ai) {\n    jv_array_foreach(b, bi, belem) {\n      if (!jv_equal(jv_array_get(jv_copy(a), ai + bi), belem))\n        idx = -1;\n      else if (bi == 0 && idx == -1)\n        idx = ai;\n    }\n    if (idx > -1)\n      res = jv_array_append(res, jv_number(idx));\n    idx = -1;\n  }\n  jv_free(a);\n  jv_free(b);\n  return res;\n}\n\n/*\n * Strings (internal helpers)\n */\n\n#define JVP_FLAGS_STRING  JVP_MAKE_FLAGS(JV_KIND_STRING, JVP_PAYLOAD_ALLOCATED)\n\ntypedef struct {\n  jv_refcnt refcnt;\n  uint32_t hash;\n  // high 31 bits are length, low bit is a flag\n  // indicating whether hash has been computed.\n  uint32_t length_hashed;\n  uint32_t alloc_length;\n  char data[];\n} jvp_string;\n\nstatic jvp_string* jvp_string_ptr(jv a) {\n  assert(JVP_HAS_KIND(a, JV_KIND_STRING));\n  return (jvp_string*)a.u.ptr;\n}\n\nstatic jvp_string* jvp_string_alloc(uint32_t size) {\n  jvp_string* s = jv_mem_alloc(sizeof(jvp_string) + size + 1);\n  s->refcnt.count = 1;\n  s->alloc_length = size;\n  return s;\n}\n\n/* Copy a UTF8 string, replacing all badly encoded points with U+FFFD */\nstatic jv jvp_string_copy_replace_bad(const char* data, uint32_t length) {\n  const char* end = data + length;\n  const char* i = data;\n\n  uint32_t maxlength = length * 3 + 1; // worst case: all bad bytes, each becomes a 3-byte U+FFFD\n  jvp_string* s = jvp_string_alloc(maxlength);\n  char* out = s->data;\n  int c = 0;\n\n  while ((i = jvp_utf8_next(i, end, &c))) {\n    if (c == -1) {\n      c = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER\n    }\n    out += jvp_utf8_encode(c, out);\n    assert(out < s->data + maxlength);\n  }\n  length = out - s->data;\n  s->data[length] = 0;\n  s->length_hashed = length << 1;\n  jv r = {JVP_FLAGS_STRING, 0, 0, 0, {&s->refcnt}};\n  return r;\n}\n\n/* Assumes valid UTF8 */\nstatic jv jvp_string_new(const char* data, uint32_t length) {\n  jvp_string* s = jvp_string_alloc(length);\n  s->length_hashed = length << 1;\n  if (data != NULL)\n    memcpy(s->data, data, length);\n  s->data[length] = 0;\n  jv r = {JVP_FLAGS_STRING, 0, 0, 0, {&s->refcnt}};\n  return r;\n}\n\nstatic jv jvp_string_empty_new(uint32_t length) {\n  jvp_string* s = jvp_string_alloc(length);\n  s->length_hashed = 0;\n  memset(s->data, 0, length);\n  s->data[length] = 0;\n  jv r = {JVP_FLAGS_STRING, 0, 0, 0, {&s->refcnt}};\n  return r;\n}\n\n\nstatic void jvp_string_free(jv js) {\n  jvp_string* s = jvp_string_ptr(js);\n  if (jvp_refcnt_dec(&s->refcnt)) {\n    jv_mem_free(s);\n  }\n}\n\nstatic uint32_t jvp_string_length(jvp_string* s) {\n  return s->length_hashed >> 1;\n}\n\nstatic uint32_t jvp_string_remaining_space(jvp_string* s) {\n  assert(s->alloc_length >= jvp_string_length(s));\n  uint32_t r = s->alloc_length - jvp_string_length(s);\n  return r;\n}\n\nstatic jv jvp_string_append(jv string, const char* data, uint32_t len) {\n  jvp_string* s = jvp_string_ptr(string);\n  uint32_t currlen = jvp_string_length(s);\n\n  if (jvp_refcnt_unshared(string.u.ptr) &&\n      jvp_string_remaining_space(s) >= len) {\n    // the next string fits at the end of a\n    memcpy(s->data + currlen, data, len);\n    s->data[currlen + len] = 0;\n    s->length_hashed = (currlen + len) << 1;\n    return string;\n  } else {\n    // allocate a bigger buffer and copy\n    uint32_t allocsz = (currlen + len) * 2;\n    if (allocsz < 32) allocsz = 32;\n    jvp_string* news = jvp_string_alloc(allocsz);\n    news->length_hashed = (currlen + len) << 1;\n    memcpy(news->data, s->data, currlen);\n    memcpy(news->data + currlen, data, len);\n    news->data[currlen + len] = 0;\n    jvp_string_free(string);\n    jv r = {JVP_FLAGS_STRING, 0, 0, 0, {&news->refcnt}};\n    return r;\n  }\n}\n\nstatic const uint32_t HASH_SEED = 0x432A9843;\n\nstatic uint32_t rotl32 (uint32_t x, int8_t r){\n  return (x << r) | (x >> (32 - r));\n}\n\nstatic uint32_t jvp_string_hash(jv jstr) {\n  jvp_string* str = jvp_string_ptr(jstr);\n  if (str->length_hashed & 1)\n    return str->hash;\n\n  /* The following is based on MurmurHash3.\n     MurmurHash3 was written by Austin Appleby, and is placed\n     in the public domain. */\n\n  const uint8_t* data = (const uint8_t*)str->data;\n  int len = (int)jvp_string_length(str);\n  const int nblocks = len / 4;\n\n  uint32_t h1 = HASH_SEED;\n\n  const uint32_t c1 = 0xcc9e2d51;\n  const uint32_t c2 = 0x1b873593;\n  const uint32_t* blocks = (const uint32_t *)(data + nblocks*4);\n\n  for(int i = -nblocks; i; i++) {\n    uint32_t k1 = blocks[i]; //FIXME: endianness/alignment\n\n    k1 *= c1;\n    k1 = rotl32(k1,15);\n    k1 *= c2;\n\n    h1 ^= k1;\n    h1 = rotl32(h1,13);\n    h1 = h1*5+0xe6546b64;\n  }\n\n  const uint8_t* tail = (const uint8_t*)(data + nblocks*4);\n\n  uint32_t k1 = 0;\n\n  switch(len & 3) {\n  case 3: k1 ^= tail[2] << 16;\n          JQ_FALLTHROUGH;\n  case 2: k1 ^= tail[1] << 8;\n          JQ_FALLTHROUGH;\n  case 1: k1 ^= tail[0];\n          k1 *= c1; k1 = rotl32(k1,15); k1 *= c2; h1 ^= k1;\n  }\n\n  h1 ^= len;\n\n  h1 ^= h1 >> 16;\n  h1 *= 0x85ebca6b;\n  h1 ^= h1 >> 13;\n  h1 *= 0xc2b2ae35;\n  h1 ^= h1 >> 16;\n\n  str->length_hashed |= 1;\n  str->hash = h1;\n\n  return h1;\n}\n\n\nstatic int jvp_string_equal(jv a, jv b) {\n  assert(JVP_HAS_KIND(a, JV_KIND_STRING));\n  assert(JVP_HAS_KIND(b, JV_KIND_STRING));\n  jvp_string* stra = jvp_string_ptr(a);\n  jvp_string* strb = jvp_string_ptr(b);\n  if (jvp_string_length(stra) != jvp_string_length(strb)) return 0;\n  return memcmp(stra->data, strb->data, jvp_string_length(stra)) == 0;\n}\n\n/*\n * Strings (public API)\n */\n\njv jv_string_sized(const char* str, int len) {\n  return\n    jvp_utf8_is_valid(str, str+len) ?\n    jvp_string_new(str, len) :\n    jvp_string_copy_replace_bad(str, len);\n}\n\njv jv_string_empty(int len) {\n  return jvp_string_empty_new(len);\n}\n\njv jv_string(const char* str) {\n  return jv_string_sized(str, strlen(str));\n}\n\nint jv_string_length_bytes(jv j) {\n  assert(JVP_HAS_KIND(j, JV_KIND_STRING));\n  int r = jvp_string_length(jvp_string_ptr(j));\n  jv_free(j);\n  return r;\n}\n\nint jv_string_length_codepoints(jv j) {\n  assert(JVP_HAS_KIND(j, JV_KIND_STRING));\n  const char* i = jv_string_value(j);\n  const char* end = i + jv_string_length_bytes(jv_copy(j));\n  int c = 0, len = 0;\n  while ((i = jvp_utf8_next(i, end, &c))) len++;\n  jv_free(j);\n  return len;\n}\n\n\njv jv_string_indexes(jv j, jv k) {\n  assert(JVP_HAS_KIND(j, JV_KIND_STRING));\n  assert(JVP_HAS_KIND(k, JV_KIND_STRING));\n  const char *jstr = jv_string_value(j);\n  const char *idxstr = jv_string_value(k);\n  const char *p, *lp;\n  int jlen = jv_string_length_bytes(jv_copy(j));\n  int idxlen = jv_string_length_bytes(jv_copy(k));\n  jv a = jv_array();\n\n  if (idxlen != 0) {\n    int n = 0;\n    p = lp = jstr;\n    while ((p = _jq_memmem(p, (jstr + jlen) - p, idxstr, idxlen)) != NULL) {\n      while (lp < p) {\n        lp += jvp_utf8_decode_length(*lp);\n        n++;\n      }\n\n      a = jv_array_append(a, jv_number(n));\n      if (!jv_is_valid(a)) break;\n      p++;\n    }\n  }\n  jv_free(j);\n  jv_free(k);\n  return a;\n}\n\njv jv_string_repeat(jv j, int n) {\n  assert(JVP_HAS_KIND(j, JV_KIND_STRING));\n  if (n < 0) {\n    jv_free(j);\n    return jv_null();\n  }\n  int len = jv_string_length_bytes(jv_copy(j));\n  int64_t res_len = (int64_t)len * n;\n  if (res_len >= INT_MAX) {\n    jv_free(j);\n    return jv_invalid_with_msg(jv_string(\"Repeat string result too long\"));\n  }\n  if (res_len == 0) {\n    jv_free(j);\n    return jv_string(\"\");\n  }\n  jv res = jv_string_empty(res_len);\n  res = jvp_string_append(res, jv_string_value(j), len);\n  for (int curr = len, grow; curr < res_len; curr += grow) {\n    grow = MIN(res_len - curr, curr);\n    res = jvp_string_append(res, jv_string_value(res), grow);\n  }\n  jv_free(j);\n  return res;\n}\n\njv jv_string_split(jv j, jv sep) {\n  assert(JVP_HAS_KIND(j, JV_KIND_STRING));\n  assert(JVP_HAS_KIND(sep, JV_KIND_STRING));\n  const char *jstr = jv_string_value(j);\n  const char *jend = jstr + jv_string_length_bytes(jv_copy(j));\n  const char *sepstr = jv_string_value(sep);\n  const char *p, *s;\n  int seplen = jv_string_length_bytes(jv_copy(sep));\n  jv a = jv_array();\n\n  assert(jv_get_refcnt(a) == 1);\n\n  if (seplen == 0) {\n    int c;\n    while ((jstr = jvp_utf8_next(jstr, jend, &c))) {\n      a = jv_array_append(a, jv_string_append_codepoint(jv_string(\"\"), c));\n      if (!jv_is_valid(a)) break;\n    }\n  } else {\n    for (p = jstr; p < jend; p = s + seplen) {\n      s = _jq_memmem(p, jend - p, sepstr, seplen);\n      if (s == NULL)\n        s = jend;\n      a = jv_array_append(a, jv_string_sized(p, s - p));\n      if (!jv_is_valid(a)) break;\n      // Add an empty string to denote that j ends on a sep\n      if (s + seplen == jend && seplen != 0)\n        a = jv_array_append(a, jv_string(\"\"));\n    }\n  }\n  jv_free(j);\n  jv_free(sep);\n  return a;\n}\n\njv jv_string_explode(jv j) {\n  assert(JVP_HAS_KIND(j, JV_KIND_STRING));\n  const char* i = jv_string_value(j);\n  int len = jv_string_length_bytes(jv_copy(j));\n  const char* end = i + len;\n  jv a = jv_array_sized(len);\n  int c;\n  while ((i = jvp_utf8_next(i, end, &c))) {\n    a = jv_array_append(a, jv_number(c));\n    if (!jv_is_valid(a)) break;\n  }\n  jv_free(j);\n  return a;\n}\n\njv jv_string_implode(jv j) {\n  assert(JVP_HAS_KIND(j, JV_KIND_ARRAY));\n  int len = jv_array_length(jv_copy(j));\n  jv s = jv_string_empty(len);\n  int i;\n\n  assert(len >= 0);\n\n  for (i = 0; i < len; i++) {\n    jv n = jv_array_get(jv_copy(j), i);\n    assert(JVP_HAS_KIND(n, JV_KIND_NUMBER));\n    int nv = jv_number_value(n);\n    jv_free(n);\n    // outside codepoint range or in utf16 surrogate pair range\n    if (nv < 0 || nv > 0x10FFFF || (nv >= 0xD800 && nv <= 0xDFFF))\n      nv = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER\n    s = jv_string_append_codepoint(s, nv);\n  }\n\n  jv_free(j);\n  return s;\n}\n\nunsigned long jv_string_hash(jv j) {\n  assert(JVP_HAS_KIND(j, JV_KIND_STRING));\n  uint32_t hash = jvp_string_hash(j);\n  jv_free(j);\n  return hash;\n}\n\nconst char* jv_string_value(jv j) {\n  assert(JVP_HAS_KIND(j, JV_KIND_STRING));\n  return jvp_string_ptr(j)->data;\n}\n\njv jv_string_slice(jv j, int start, int end) {\n  assert(JVP_HAS_KIND(j, JV_KIND_STRING));\n  const char *s = jv_string_value(j);\n  int len = jv_string_length_bytes(jv_copy(j));\n  int i;\n  const char *p, *e;\n  int c;\n  jv res;\n\n  jvp_clamp_slice_params(len, &start, &end);\n  assert(0 <= start && start <= end && end <= len);\n\n  /* Look for byte offset corresponding to start codepoints */\n  for (p = s, i = 0; i < start; i++) {\n    p = jvp_utf8_next(p, s + len, &c);\n    if (p == NULL) {\n      jv_free(j);\n      return jv_string_empty(16);\n    }\n    if (c == -1) {\n      jv_free(j);\n      return jv_invalid_with_msg(jv_string(\"Invalid UTF-8 string\"));\n    }\n  }\n  /* Look for byte offset corresponding to end codepoints */\n  for (e = p; e != NULL && i < end; i++) {\n    e = jvp_utf8_next(e, s + len, &c);\n    if (e == NULL) {\n      e = s + len;\n      break;\n    }\n    if (c == -1) {\n      jv_free(j);\n      return jv_invalid_with_msg(jv_string(\"Invalid UTF-8 string\"));\n    }\n  }\n\n  /*\n   * NOTE: Ideally we should do here what jvp_array_slice() does instead\n   * of allocating a new string as we do!  However, we assume NUL-\n   * terminated strings all over, and in the jv API, so for now we waste\n   * memory like a drunken navy programmer.  There's probably nothing we\n   * can do about it.\n   */\n  res = jv_string_sized(p, e - p);\n  jv_free(j);\n  return res;\n}\n\njv jv_string_concat(jv a, jv b) {\n  a = jvp_string_append(a, jv_string_value(b),\n                        jvp_string_length(jvp_string_ptr(b)));\n  jv_free(b);\n  return a;\n}\n\njv jv_string_append_buf(jv a, const char* buf, int len) {\n  if (jvp_utf8_is_valid(buf, buf+len)) {\n    a = jvp_string_append(a, buf, len);\n  } else {\n    jv b = jvp_string_copy_replace_bad(buf, len);\n    a = jv_string_concat(a, b);\n  }\n  return a;\n}\n\njv jv_string_append_codepoint(jv a, uint32_t c) {\n  char buf[5];\n  int len = jvp_utf8_encode(c, buf);\n  a = jvp_string_append(a, buf, len);\n  return a;\n}\n\njv jv_string_append_str(jv a, const char* str) {\n  return jv_string_append_buf(a, str, strlen(str));\n}\n\njv jv_string_vfmt(const char* fmt, va_list ap) {\n  int size = 1024;\n  while (1) {\n    char* buf = jv_mem_alloc(size);\n    va_list ap2;\n    va_copy(ap2, ap);\n    int n = vsnprintf(buf, size, fmt, ap2);\n    va_end(ap2);\n    /*\n     * NOTE: here we support old vsnprintf()s that return -1 because the\n     * buffer is too small.\n     */\n    if (n >= 0 && n < size) {\n      jv ret = jv_string_sized(buf, n);\n      jv_mem_free(buf);\n      return ret;\n    } else {\n      jv_mem_free(buf);\n      size = (n > 0) ? /* standard */ (n * 2) : /* not standard */ (size * 2);\n    }\n  }\n}\n\njv jv_string_fmt(const char* fmt, ...) {\n  va_list args;\n  va_start(args, fmt);\n  jv res = jv_string_vfmt(fmt, args);\n  va_end(args);\n  return res;\n}\n\n/*\n * Objects (internal helpers)\n */\n\n#define JVP_FLAGS_OBJECT  JVP_MAKE_FLAGS(JV_KIND_OBJECT, JVP_PAYLOAD_ALLOCATED)\n\nstruct object_slot {\n  int next; /* next slot with same hash, for collisions */\n  uint32_t hash;\n  jv string;\n  jv value;\n};\n\ntypedef struct {\n  jv_refcnt refcnt;\n  int next_free;\n  struct object_slot elements[];\n} jvp_object;\n\n\n/* warning: nontrivial justification of alignment */\nstatic jv jvp_object_new(int size) {\n  // Allocates an object of (size) slots and (size*2) hash buckets.\n\n  // size must be a power of two\n  assert(size > 0 && (size & (size - 1)) == 0);\n\n  jvp_object* obj = jv_mem_alloc(sizeof(jvp_object) +\n                                 sizeof(struct object_slot) * size +\n                                 sizeof(int) * (size * 2));\n  obj->refcnt.count = 1;\n  for (int i=0; i<size; i++) {\n    obj->elements[i].next = i - 1;\n    obj->elements[i].string = JV_NULL;\n    obj->elements[i].hash = 0;\n    obj->elements[i].value = JV_NULL;\n  }\n  obj->next_free = 0;\n  int* hashbuckets = (int*)(&obj->elements[size]);\n  for (int i=0; i<size*2; i++) {\n    hashbuckets[i] = -1;\n  }\n  jv r = {JVP_FLAGS_OBJECT, 0, 0, size, {&obj->refcnt}};\n  return r;\n}\n\nstatic jvp_object* jvp_object_ptr(jv o) {\n  assert(JVP_HAS_KIND(o, JV_KIND_OBJECT));\n  return (jvp_object*)o.u.ptr;\n}\n\nstatic uint32_t jvp_object_mask(jv o) {\n  assert(JVP_HAS_KIND(o, JV_KIND_OBJECT));\n  return (o.size * 2) - 1;\n}\n\nstatic int jvp_object_size(jv o) {\n  assert(JVP_HAS_KIND(o, JV_KIND_OBJECT));\n  return o.size;\n}\n\nstatic int* jvp_object_buckets(jv o) {\n  return (int*)(&jvp_object_ptr(o)->elements[o.size]);\n}\n\nstatic int* jvp_object_find_bucket(jv object, jv key) {\n  return jvp_object_buckets(object) + (jvp_object_mask(object) & jvp_string_hash(key));\n}\n\nstatic struct object_slot* jvp_object_get_slot(jv object, int slot) {\n  assert(slot == -1 || (slot >= 0 && slot < jvp_object_size(object)));\n  if (slot == -1) return 0;\n  else return &jvp_object_ptr(object)->elements[slot];\n}\n\nstatic struct object_slot* jvp_object_next_slot(jv object, struct object_slot* slot) {\n  return jvp_object_get_slot(object, slot->next);\n}\n\nstatic struct object_slot* jvp_object_find_slot(jv object, jv keystr, int* bucket) {\n  uint32_t hash = jvp_string_hash(keystr);\n  for (struct object_slot* curr = jvp_object_get_slot(object, *bucket);\n       curr;\n       curr = jvp_object_next_slot(object, curr)) {\n    if (curr->hash == hash && jvp_string_equal(keystr, curr->string)) {\n      return curr;\n    }\n  }\n  return 0;\n}\n\nstatic struct object_slot* jvp_object_add_slot(jv object, jv key, int* bucket) {\n  jvp_object* o = jvp_object_ptr(object);\n  int newslot_idx = o->next_free;\n  if (newslot_idx == jvp_object_size(object)) return 0;\n  struct object_slot* newslot = jvp_object_get_slot(object, newslot_idx);\n  o->next_free++;\n  newslot->next = *bucket;\n  *bucket = newslot_idx;\n  newslot->hash = jvp_string_hash(key);\n  newslot->string = key;\n  return newslot;\n}\n\nstatic jv* jvp_object_read(jv object, jv key) {\n  assert(JVP_HAS_KIND(key, JV_KIND_STRING));\n  int* bucket = jvp_object_find_bucket(object, key);\n  struct object_slot* slot = jvp_object_find_slot(object, key, bucket);\n  if (slot == 0) return 0;\n  else return &slot->value;\n}\n\nstatic void jvp_object_free(jv o) {\n  assert(JVP_HAS_KIND(o, JV_KIND_OBJECT));\n  if (jvp_refcnt_dec(o.u.ptr)) {\n    for (int i=0; i<jvp_object_size(o); i++) {\n      struct object_slot* slot = jvp_object_get_slot(o, i);\n      if (jv_get_kind(slot->string) != JV_KIND_NULL) {\n        jvp_string_free(slot->string);\n        jv_free(slot->value);\n      }\n    }\n    jv_mem_free(jvp_object_ptr(o));\n  }\n}\n\nstatic int jvp_object_rehash(jv *objectp) {\n  jv object = *objectp;\n  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));\n  assert(jvp_refcnt_unshared(object.u.ptr));\n  int size = jvp_object_size(object);\n  if (size > INT_MAX >> 2)\n    return 0;\n  jv new_object = jvp_object_new(size * 2);\n  for (int i=0; i<size; i++) {\n    struct object_slot* slot = jvp_object_get_slot(object, i);\n    if (jv_get_kind(slot->string) == JV_KIND_NULL) continue;\n    int* new_bucket = jvp_object_find_bucket(new_object, slot->string);\n    assert(!jvp_object_find_slot(new_object, slot->string, new_bucket));\n    struct object_slot* new_slot = jvp_object_add_slot(new_object, slot->string, new_bucket);\n    assert(new_slot);\n    new_slot->value = slot->value;\n  }\n  // references are transported, just drop the old table\n  jv_mem_free(jvp_object_ptr(object));\n  *objectp = new_object;\n  return 1;\n}\n\nstatic jv jvp_object_unshare(jv object) {\n  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));\n  if (jvp_refcnt_unshared(object.u.ptr))\n    return object;\n\n  jv new_object = jvp_object_new(jvp_object_size(object));\n  jvp_object_ptr(new_object)->next_free = jvp_object_ptr(object)->next_free;\n  for (int i=0; i<jvp_object_size(new_object); i++) {\n    struct object_slot* old_slot = jvp_object_get_slot(object, i);\n    struct object_slot* new_slot = jvp_object_get_slot(new_object, i);\n    *new_slot = *old_slot;\n    if (jv_get_kind(old_slot->string) != JV_KIND_NULL) {\n      new_slot->string = jv_copy(old_slot->string);\n      new_slot->value = jv_copy(old_slot->value);\n    }\n  }\n\n  int* old_buckets = jvp_object_buckets(object);\n  int* new_buckets = jvp_object_buckets(new_object);\n  memcpy(new_buckets, old_buckets, sizeof(int) * jvp_object_size(new_object)*2);\n\n  jvp_object_free(object);\n  assert(jvp_refcnt_unshared(new_object.u.ptr));\n  return new_object;\n}\n\nstatic int jvp_object_write(jv* object, jv key, jv **valpp) {\n  *object = jvp_object_unshare(*object);\n  int* bucket = jvp_object_find_bucket(*object, key);\n  struct object_slot* slot = jvp_object_find_slot(*object, key, bucket);\n  if (slot) {\n    // already has the key\n    jvp_string_free(key);\n    *valpp = &slot->value;\n    return 1;\n  }\n  slot = jvp_object_add_slot(*object, key, bucket);\n  if (slot) {\n    slot->value = jv_invalid();\n  } else {\n    if (!jvp_object_rehash(object)) {\n      jvp_string_free(key);\n      *valpp = NULL;\n      return 0;\n    }\n    bucket = jvp_object_find_bucket(*object, key);\n    assert(!jvp_object_find_slot(*object, key, bucket));\n    slot = jvp_object_add_slot(*object, key, bucket);\n    assert(slot);\n    slot->value = jv_invalid();\n  }\n  *valpp = &slot->value;\n  return 1;\n}\n\nstatic int jvp_object_delete(jv* object, jv key) {\n  assert(JVP_HAS_KIND(key, JV_KIND_STRING));\n  *object = jvp_object_unshare(*object);\n  int* bucket = jvp_object_find_bucket(*object, key);\n  int* prev_ptr = bucket;\n  uint32_t hash = jvp_string_hash(key);\n  for (struct object_slot* curr = jvp_object_get_slot(*object, *bucket);\n       curr;\n       curr = jvp_object_next_slot(*object, curr)) {\n    if (hash == curr->hash && jvp_string_equal(key, curr->string)) {\n      *prev_ptr = curr->next;\n      jvp_string_free(curr->string);\n      curr->string = JV_NULL;\n      jv_free(curr->value);\n      return 1;\n    }\n    prev_ptr = &curr->next;\n  }\n  return 0;\n}\n\nstatic int jvp_object_length(jv object) {\n  int n = 0;\n  for (int i=0; i<jvp_object_size(object); i++) {\n    struct object_slot* slot = jvp_object_get_slot(object, i);\n    if (jv_get_kind(slot->string) != JV_KIND_NULL) n++;\n  }\n  return n;\n}\n\nstatic int jvp_object_equal(jv o1, jv o2) {\n  int len2 = jvp_object_length(o2);\n  int len1 = 0;\n  for (int i=0; i<jvp_object_size(o1); i++) {\n    struct object_slot* slot = jvp_object_get_slot(o1, i);\n    if (jv_get_kind(slot->string) == JV_KIND_NULL) continue;\n    jv* slot2 = jvp_object_read(o2, slot->string);\n    if (!slot2) return 0;\n    // FIXME: do less refcounting here\n    if (!jv_equal(jv_copy(slot->value), jv_copy(*slot2))) return 0;\n    len1++;\n  }\n  return len1 == len2;\n}\n\nstatic int jvp_object_contains(jv a, jv b) {\n  assert(JVP_HAS_KIND(a, JV_KIND_OBJECT));\n  assert(JVP_HAS_KIND(b, JV_KIND_OBJECT));\n  int r = 1;\n\n  jv_object_foreach(b, key, b_val) {\n    jv a_val = jv_object_get(jv_copy(a), key);\n\n    r = jv_contains(a_val, b_val);\n\n    if (!r) break;\n  }\n  return r;\n}\n\n/*\n * Objects (public interface)\n */\n#define DEFAULT_OBJECT_SIZE 8\njv jv_object(void) {\n  return jvp_object_new(8);\n}\n\njv jv_object_get(jv object, jv key) {\n  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));\n  assert(JVP_HAS_KIND(key, JV_KIND_STRING));\n  jv* slot = jvp_object_read(object, key);\n  jv val;\n  if (slot) {\n    val = jv_copy(*slot);\n  } else {\n    val = jv_invalid();\n  }\n  jv_free(object);\n  jv_free(key);\n  return val;\n}\n\nint jv_object_has(jv object, jv key) {\n  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));\n  assert(JVP_HAS_KIND(key, JV_KIND_STRING));\n  jv* slot = jvp_object_read(object, key);\n  int res = slot ? 1 : 0;\n  jv_free(object);\n  jv_free(key);\n  return res;\n}\n\njv jv_object_set(jv object, jv key, jv value) {\n  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));\n  assert(JVP_HAS_KIND(key, JV_KIND_STRING));\n  // copy/free of object, key, value coalesced\n  jv* slot;\n  if (!jvp_object_write(&object, key, &slot)) {\n    jv_free(object);\n    jv_free(value);\n    return jv_invalid_with_msg(jv_string(\"Object too big\"));\n  }\n  jv_free(*slot);\n  *slot = value;\n  return object;\n}\n\njv jv_object_delete(jv object, jv key) {\n  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));\n  assert(JVP_HAS_KIND(key, JV_KIND_STRING));\n  jvp_object_delete(&object, key);\n  jv_free(key);\n  return object;\n}\n\nint jv_object_length(jv object) {\n  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));\n  int n = jvp_object_length(object);\n  jv_free(object);\n  return n;\n}\n\njv jv_object_merge(jv a, jv b) {\n  assert(JVP_HAS_KIND(a, JV_KIND_OBJECT));\n  jv_object_foreach(b, k, v) {\n    a = jv_object_set(a, k, v);\n    if (!jv_is_valid(a)) break;\n  }\n  jv_free(b);\n  return a;\n}\n\njv jv_object_merge_recursive(jv a, jv b) {\n  assert(JVP_HAS_KIND(a, JV_KIND_OBJECT));\n  assert(JVP_HAS_KIND(b, JV_KIND_OBJECT));\n\n  jv_object_foreach(b, k, v) {\n    jv elem = jv_object_get(jv_copy(a), jv_copy(k));\n    if (jv_is_valid(elem) &&\n        JVP_HAS_KIND(elem, JV_KIND_OBJECT) &&\n        JVP_HAS_KIND(v, JV_KIND_OBJECT)) {\n      a = jv_object_set(a, k, jv_object_merge_recursive(elem, v));\n    } else {\n      jv_free(elem);\n      a = jv_object_set(a, k, v);\n    }\n    if (!jv_is_valid(a)) break;\n  }\n  jv_free(b);\n  return a;\n}\n\n/*\n * Object iteration (internal helpers)\n */\n\nenum { ITER_FINISHED = -2 };\n\nint jv_object_iter_valid(jv object, int i) {\n  return i != ITER_FINISHED;\n}\n\nint jv_object_iter(jv object) {\n  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));\n  return jv_object_iter_next(object, -1);\n}\n\nint jv_object_iter_next(jv object, int iter) {\n  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));\n  assert(iter != ITER_FINISHED);\n  struct object_slot* slot;\n  do {\n    iter++;\n    if (iter >= jvp_object_size(object))\n      return ITER_FINISHED;\n    slot = jvp_object_get_slot(object, iter);\n  } while (jv_get_kind(slot->string) == JV_KIND_NULL);\n  assert(jv_get_kind(jvp_object_get_slot(object,iter)->string)\n         == JV_KIND_STRING);\n  return iter;\n}\n\njv jv_object_iter_key(jv object, int iter) {\n  jv s = jvp_object_get_slot(object, iter)->string;\n  assert(JVP_HAS_KIND(s, JV_KIND_STRING));\n  return jv_copy(s);\n}\n\njv jv_object_iter_value(jv object, int iter) {\n  return jv_copy(jvp_object_get_slot(object, iter)->value);\n}\n\n/*\n * Memory management\n */\njv jv_copy(jv j) {\n  if (JVP_IS_ALLOCATED(j)) {\n    jvp_refcnt_inc(j.u.ptr);\n  }\n  return j;\n}\n\nvoid jv_free(jv j) {\n  switch(JVP_KIND(j)) {\n    case JV_KIND_ARRAY:\n      jvp_array_free(j);\n      break;\n    case JV_KIND_STRING:\n      jvp_string_free(j);\n      break;\n    case JV_KIND_OBJECT:\n      jvp_object_free(j);\n      break;\n    case JV_KIND_INVALID:\n      jvp_invalid_free(j);\n      break;\n    case JV_KIND_NUMBER:\n      jvp_number_free(j);\n      break;\n  }\n}\n\nint jv_get_refcnt(jv j) {\n  if (JVP_IS_ALLOCATED(j)) {\n    return j.u.ptr->count;\n  } else {\n    return 1;\n  }\n}\n\n/*\n * Higher-level operations\n */\n\nint jv_equal(jv a, jv b) {\n  int r;\n  if (jv_get_kind(a) != jv_get_kind(b)) {\n    r = 0;\n  } else if (JVP_IS_ALLOCATED(a) &&\n             JVP_IS_ALLOCATED(b) &&\n             a.kind_flags == b.kind_flags &&\n             a.size == b.size &&\n             a.u.ptr == b.u.ptr) {\n    r = 1;\n  } else {\n    switch (jv_get_kind(a)) {\n    case JV_KIND_NUMBER:\n      r = jvp_number_equal(a, b);\n      break;\n    case JV_KIND_ARRAY:\n      r = jvp_array_equal(a, b);\n      break;\n    case JV_KIND_STRING:\n      r = jvp_string_equal(a, b);\n      break;\n    case JV_KIND_OBJECT:\n      r = jvp_object_equal(a, b);\n      break;\n    default:\n      r = 1;\n      break;\n    }\n  }\n  jv_free(a);\n  jv_free(b);\n  return r;\n}\n\nint jv_identical(jv a, jv b) {\n  int r;\n  if (a.kind_flags != b.kind_flags\n      || a.offset != b.offset\n      || a.size != b.size) {\n    r = 0;\n  } else {\n    if (JVP_IS_ALLOCATED(a) /* b has the same flags */) {\n      r = a.u.ptr == b.u.ptr;\n    } else {\n      r = memcmp(&a.u.ptr, &b.u.ptr, sizeof(a.u)) == 0;\n    }\n  }\n  jv_free(a);\n  jv_free(b);\n  return r;\n}\n\nint jv_contains(jv a, jv b) {\n  int r = 1;\n  if (jv_get_kind(a) != jv_get_kind(b)) {\n    r = 0;\n  } else if (JVP_HAS_KIND(a, JV_KIND_OBJECT)) {\n    r = jvp_object_contains(a, b);\n  } else if (JVP_HAS_KIND(a, JV_KIND_ARRAY)) {\n    r = jvp_array_contains(a, b);\n  } else if (JVP_HAS_KIND(a, JV_KIND_STRING)) {\n    int b_len = jv_string_length_bytes(jv_copy(b));\n    if (b_len != 0) {\n      r = _jq_memmem(jv_string_value(a), jv_string_length_bytes(jv_copy(a)),\n                     jv_string_value(b), b_len) != 0;\n    } else {\n      r = 1;\n    }\n  } else {\n    r = jv_equal(jv_copy(a), jv_copy(b));\n  }\n  jv_free(a);\n  jv_free(b);\n  return r;\n}\n"
  },
  {
    "path": "src/jv.h",
    "content": "#ifndef JV_H\n#define JV_H\n\n#include <stdarg.h>\n#include <stdint.h>\n#include <stdio.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#if (defined(__GNUC__) && __GNUC__ >= 7) || \\\n    (defined(__clang__) && __clang_major__ >= 10)\n# define JQ_FALLTHROUGH __attribute__((fallthrough))\n#else\n# define JQ_FALLTHROUGH do {} while (0) /* fallthrough */\n#endif\n\ntypedef enum {\n  JV_KIND_INVALID,\n  JV_KIND_NULL,\n  JV_KIND_FALSE,\n  JV_KIND_TRUE,\n  JV_KIND_NUMBER,\n  JV_KIND_STRING,\n  JV_KIND_ARRAY,\n  JV_KIND_OBJECT\n} jv_kind;\n\nstruct jv_refcnt;\n\n/* All of the fields of this struct are private.\n   Really. Do not play with them. */\ntypedef struct {\n  unsigned char kind_flags;\n  unsigned char pad_;\n  unsigned short offset;  /* array offsets */\n  int size;\n  union {\n    struct jv_refcnt* ptr;\n    double number;\n  } u;\n} jv;\n\n/*\n * All jv_* functions consume (decref) input and produce (incref) output\n * Except jv_copy\n */\n\njv_kind jv_get_kind(jv);\nconst char* jv_kind_name(jv_kind);\nstatic int jv_is_valid(jv x) { return jv_get_kind(x) != JV_KIND_INVALID; }\n\njv jv_copy(jv);\nvoid jv_free(jv);\n\nint jv_get_refcnt(jv);\n\nint jv_equal(jv, jv);\nint jv_identical(jv, jv);\nint jv_contains(jv, jv);\n\njv jv_invalid(void);\njv jv_invalid_with_msg(jv);\njv jv_invalid_get_msg(jv);\nint jv_invalid_has_msg(jv);\n\njv jv_null(void);\njv jv_true(void);\njv jv_false(void);\njv jv_bool(int);\n\njv jv_number(double);\njv jv_number_with_literal(const char*);\ndouble jv_number_value(jv);\nint jv_is_integer(jv);\njv jv_number_abs(jv);\njv jv_number_negate(jv);\n\nint jv_number_has_literal(jv);\nconst char* jv_number_get_literal(jv);\n\njv jv_array(void);\njv jv_array_sized(int);\nint jv_array_length(jv);\njv jv_array_get(jv, int);\njv jv_array_set(jv, int, jv);\njv jv_array_append(jv, jv);\njv jv_array_concat(jv, jv);\njv jv_array_slice(jv, int, int);\njv jv_array_indexes(jv, jv);\n#define jv_array_foreach(a, i, x) \\\n  for (int jv_len__ = jv_array_length(jv_copy(a)), i=0, jv_j__ = 1;     \\\n       jv_j__; jv_j__ = 0)                                              \\\n    for (jv x;                                                          \\\n         i < jv_len__ ?                                                 \\\n           (x = jv_array_get(jv_copy(a), i), 1) : 0;                    \\\n         i++)\n\n#define JV_ARRAY_1(e) (jv_array_append(jv_array(),e))\n#define JV_ARRAY_2(e1,e2) (jv_array_append(JV_ARRAY_1(e1),e2))\n#define JV_ARRAY_3(e1,e2,e3) (jv_array_append(JV_ARRAY_2(e1,e2),e3))\n#define JV_ARRAY_4(e1,e2,e3,e4) (jv_array_append(JV_ARRAY_3(e1,e2,e3),e4))\n#define JV_ARRAY_5(e1,e2,e3,e4,e5) (jv_array_append(JV_ARRAY_4(e1,e2,e3,e4),e5))\n#define JV_ARRAY_6(e1,e2,e3,e4,e5,e6) (jv_array_append(JV_ARRAY_5(e1,e2,e3,e4,e5),e6))\n#define JV_ARRAY_7(e1,e2,e3,e4,e5,e6,e7) (jv_array_append(JV_ARRAY_6(e1,e2,e3,e4,e5,e6),e7))\n#define JV_ARRAY_8(e1,e2,e3,e4,e5,e6,e7,e8) (jv_array_append(JV_ARRAY_7(e1,e2,e3,e4,e5,e6,e7),e8))\n#define JV_ARRAY_9(e1,e2,e3,e4,e5,e6,e7,e8,e9) (jv_array_append(JV_ARRAY_8(e1,e2,e3,e4,e5,e6,e7,e8),e9))\n#define JV_ARRAY_IDX(_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME\n#define JV_ARRAY(...) \\\n  JV_ARRAY_IDX(__VA_ARGS__, JV_ARRAY_9, JV_ARRAY_8, JV_ARRAY_7, JV_ARRAY_6, JV_ARRAY_5, JV_ARRAY_4, JV_ARRAY_3, JV_ARRAY_2, JV_ARRAY_1, dummy)(__VA_ARGS__)\n\n#ifdef __GNUC__\n#define JV_PRINTF_LIKE(fmt_arg_num, args_num) \\\n  __attribute__ ((__format__( __printf__, fmt_arg_num, args_num)))\n#define JV_VPRINTF_LIKE(fmt_arg_num) \\\n  __attribute__ ((__format__( __printf__, fmt_arg_num, 0)))\n#else\n#define JV_PRINTF_LIKE(fmt_arg_num, args_num)\n#define JV_VPRINTF_LIKE(fmt_arg_num)\n#endif\n\n\njv jv_string(const char*);\njv jv_string_sized(const char*, int);\njv jv_string_empty(int len);\nint jv_string_length_bytes(jv);\nint jv_string_length_codepoints(jv);\nunsigned long jv_string_hash(jv);\nconst char* jv_string_value(jv);\njv jv_string_indexes(jv j, jv k);\njv jv_string_slice(jv j, int start, int end);\njv jv_string_concat(jv, jv);\njv jv_string_vfmt(const char*, va_list) JV_VPRINTF_LIKE(1);\njv jv_string_fmt(const char*, ...) JV_PRINTF_LIKE(1, 2);\njv jv_string_append_codepoint(jv a, uint32_t c);\njv jv_string_append_buf(jv a, const char* buf, int len);\njv jv_string_append_str(jv a, const char* str);\njv jv_string_repeat(jv j, int n);\njv jv_string_split(jv j, jv sep);\njv jv_string_explode(jv j);\njv jv_string_implode(jv j);\n\njv jv_object(void);\njv jv_object_get(jv object, jv key);\nint jv_object_has(jv object, jv key);\njv jv_object_set(jv object, jv key, jv value);\njv jv_object_delete(jv object, jv key);\nint jv_object_length(jv object);\njv jv_object_merge(jv, jv);\njv jv_object_merge_recursive(jv, jv);\n\nint jv_object_iter(jv);\nint jv_object_iter_next(jv, int);\nint jv_object_iter_valid(jv, int);\njv jv_object_iter_key(jv, int);\njv jv_object_iter_value(jv, int);\n#define jv_object_foreach(t, k, v)                                      \\\n  for (int jv_i__ = jv_object_iter(t), jv_j__ = 1; jv_j__; jv_j__ = 0)  \\\n    for (jv k, v;                                                       \\\n         jv_object_iter_valid((t), jv_i__) ?                            \\\n           (k = jv_object_iter_key(t, jv_i__),                          \\\n            v = jv_object_iter_value(t, jv_i__),                        \\\n            1)                                                          \\\n           : 0;                                                         \\\n         jv_i__ = jv_object_iter_next(t, jv_i__))                       \\\n\n#define jv_object_keys_foreach(t, k)                                 \\\n  for (int jv_i__ = jv_object_iter(t), jv_j__ = 1; jv_j__; jv_j__ = 0)  \\\n    for (jv k;                                                          \\\n         jv_object_iter_valid((t), jv_i__) ?                            \\\n           (k = jv_object_iter_key(t, jv_i__),                          \\\n            1)                                                          \\\n           : 0;                                                         \\\n         jv_i__ = jv_object_iter_next(t, jv_i__))\n\n#define JV_OBJECT_1(k1) (jv_object_set(jv_object(),(k1),jv_null()))\n#define JV_OBJECT_2(k1,v1) (jv_object_set(jv_object(),(k1),(v1)))\n#define JV_OBJECT_3(k1,v1,k2) (jv_object_set(JV_OBJECT_2((k1),(v1)),(k2),jv_null()))\n#define JV_OBJECT_4(k1,v1,k2,v2) (jv_object_set(JV_OBJECT_2((k1),(v1)),(k2),(v2)))\n#define JV_OBJECT_5(k1,v1,k2,v2,k3) (jv_object_set(JV_OBJECT_4((k1),(v1),(k2),(v2)),(k3),jv_null()))\n#define JV_OBJECT_6(k1,v1,k2,v2,k3,v3) (jv_object_set(JV_OBJECT_4((k1),(v1),(k2),(v2)),(k3),(v3)))\n#define JV_OBJECT_7(k1,v1,k2,v2,k3,v3,k4) (jv_object_set(JV_OBJECT_6((k1),(v1),(k2),(v2),(k3),(v3)),(k4),jv_null()))\n#define JV_OBJECT_8(k1,v1,k2,v2,k3,v3,k4,v4) (jv_object_set(JV_OBJECT_6((k1),(v1),(k2),(v2),(k3),(v3)),(k4),(v4)))\n#define JV_OBJECT_9(k1,v1,k2,v2,k3,v3,k4,v4,k5) \\\n    (jv_object_set(JV_OBJECT_8((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4)),(k5),jv_null()))\n#define JV_OBJECT_10(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5) \\\n    (jv_object_set(JV_OBJECT_8((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4)),(k5),(v5)))\n#define JV_OBJECT_11(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6) \\\n    (jv_object_set(JV_OBJECT_10((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5)),(k6),jv_null()))\n#define JV_OBJECT_12(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6) \\\n    (jv_object_set(JV_OBJECT_10((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5)),(k6),(v6)))\n#define JV_OBJECT_13(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7) \\\n    (jv_object_set(JV_OBJECT_12((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6)),(k7),jv_null()))\n#define JV_OBJECT_14(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7) \\\n    (jv_object_set(JV_OBJECT_12((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6)),(k7),(v7)))\n#define JV_OBJECT_15(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8) \\\n    (jv_object_set(JV_OBJECT_14((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6),(k7),(v7)),(k8),jv_null()))\n#define JV_OBJECT_16(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8) \\\n    (jv_object_set(JV_OBJECT_14((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6),(k7),(v7)),(k8),(v8)))\n#define JV_OBJECT_17(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8,k9) \\\n    (jv_object_set(JV_OBJECT_16((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6),(k7),(v7),(k8),(v8)),(k9),jv_null()))\n#define JV_OBJECT_18(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8,k9,v9) \\\n    (jv_object_set(JV_OBJECT_16((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6),(k7),(v7),(k8),(v8)),(k9),(v9)))\n#define JV_OBJECT_IDX(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,NAME,...) NAME\n#define JV_OBJECT(...) \\\n  JV_OBJECT_IDX(__VA_ARGS__, \\\n                JV_OBJECT_18, JV_OBJECT_17, JV_OBJECT_16, JV_OBJECT_15, \\\n                JV_OBJECT_14, JV_OBJECT_13, JV_OBJECT_12, JV_OBJECT_11, \\\n                JV_OBJECT_10, JV_OBJECT_9, JV_OBJECT_8, JV_OBJECT_7,    \\\n                JV_OBJECT_6, JV_OBJECT_5, JV_OBJECT_4, JV_OBJECT_3,     \\\n                JV_OBJECT_2, JV_OBJECT_1)(__VA_ARGS__)\n\n\n\nint jv_get_refcnt(jv);\n\nenum jv_print_flags {\n  JV_PRINT_PRETTY   = 1,\n  JV_PRINT_ASCII    = 2,\n  JV_PRINT_COLOR    = 4, JV_PRINT_COLOUR = 4,\n  JV_PRINT_SORTED   = 8,\n  JV_PRINT_INVALID  = 16,\n  JV_PRINT_REFCOUNT = 32,\n  JV_PRINT_TAB      = 64,\n  JV_PRINT_ISATTY   = 128,\n  JV_PRINT_SPACE0   = 256,\n  JV_PRINT_SPACE1   = 512,\n  JV_PRINT_SPACE2   = 1024,\n};\n#define JV_PRINT_INDENT_FLAGS(n) \\\n    ((n) < 0 || (n) > 7 ? JV_PRINT_TAB | JV_PRINT_PRETTY : (n) << 8 | JV_PRINT_PRETTY)\nvoid jv_dumpf(jv, FILE *f, int flags);\nvoid jv_dump(jv, int flags);\nvoid jv_show(jv, int flags);\njv jv_dump_string(jv, int flags);\nchar *jv_dump_string_trunc(jv x, char *outbuf, size_t bufsize);\n\nenum {\n  JV_PARSE_SEQ              = 1,\n  JV_PARSE_STREAMING        = 2,\n  JV_PARSE_STREAM_ERRORS    = 4,\n};\n\njv jv_parse(const char* string);\njv jv_parse_sized(const char* string, int length);\njv jv_parse_custom_flags(const char* string, int flags);\n\ntypedef void (*jv_nomem_handler_f)(void *);\nvoid jv_nomem_handler(jv_nomem_handler_f, void *);\n\njv jv_load_file(const char *, int);\n\ntypedef struct jv_parser jv_parser;\njv_parser* jv_parser_new(int);\nvoid jv_parser_set_buf(jv_parser*, const char*, int, int);\nint jv_parser_remaining(jv_parser*);\njv jv_parser_next(jv_parser*);\nvoid jv_parser_free(jv_parser*);\n\njv jv_get(jv, jv);\njv jv_set(jv, jv, jv);\njv jv_has(jv, jv);\njv jv_setpath(jv, jv, jv);\njv jv_getpath(jv, jv);\njv jv_delpaths(jv, jv);\njv jv_keys(jv /*object or array*/);\njv jv_keys_unsorted(jv /*object or array*/);\nint jv_cmp(jv, jv);\njv jv_sort(jv, jv);\njv jv_group(jv, jv);\njv jv_unique(jv, jv);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n\n/*\n\ntrue/false/null:\ncheck kind\n\nnumber:\nintroduce/eliminate jv\nto integer\n\narray:\ncopy\nfree\nslice\nindex\nupdate\n\nupdateslice?\n\n\n */\n"
  },
  {
    "path": "src/jv_alloc.c",
    "content": "#include <assert.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"jv.h\"\n\nstruct nomem_handler {\n    jv_nomem_handler_f handler;\n    void *data;\n};\n\n#if !defined(HAVE_PTHREAD_KEY_CREATE) || \\\n    !defined(HAVE_PTHREAD_ONCE) || \\\n    !defined(HAVE_ATEXIT)\n\n/* Try thread-local storage? */\n\n#ifdef _MSC_VER\n/* Visual C++: yes */\nstatic __declspec(thread) struct nomem_handler nomem_handler;\n#define USE_TLS\n#else\n#ifdef HAVE___THREAD\n/* GCC and friends: yes */\nstatic __thread struct nomem_handler nomem_handler;\n#define USE_TLS\n#endif /* HAVE___THREAD */\n#endif /* _MSC_VER */\n\n#endif /* !HAVE_PTHREAD_KEY_CREATE */\n\n#ifdef USE_TLS\nvoid jv_nomem_handler(jv_nomem_handler_f handler, void *data) {\n  nomem_handler.handler = handler;\n}\n\nstatic void memory_exhausted(void) {\n  if (nomem_handler.handler)\n    nomem_handler.handler(nomem_handler.data); // Maybe handler() will longjmp() to safety\n  // Or not\n  fprintf(stderr, \"jq: error: cannot allocate memory\\n\");\n  abort();\n}\n#else /* USE_TLS */\n\n#ifdef HAVE_PTHREAD_KEY_CREATE\n#include <pthread.h>\n\nstatic pthread_key_t nomem_handler_key;\nstatic pthread_once_t mem_once = PTHREAD_ONCE_INIT;\n\n/* tsd_fini is called on application exit */\n/* it clears the nomem_handler allocated in the main thread */\nstatic void tsd_fini(void) {\n  struct nomem_handler *nomem_handler;\n  nomem_handler = pthread_getspecific(nomem_handler_key);\n  if (nomem_handler) {\n    (void) pthread_setspecific(nomem_handler_key, NULL);\n    free(nomem_handler);\n  }\n}\n\n/* The tsd_fini_thread is a destructor set by calling */\n/* pthread_key_create(&nomem_handler_key, tsd_fini_thread) */\n/* It is called when thread ends */\nstatic void tsd_fini_thread(void *nomem_handler) {\n  free(nomem_handler);\n}\n\nstatic void tsd_init(void) {\n  if (pthread_key_create(&nomem_handler_key, tsd_fini_thread) != 0) {\n    fprintf(stderr, \"jq: error: cannot create thread specific key\");\n    abort();\n  }\n  if (atexit(tsd_fini) != 0) {\n    fprintf(stderr, \"jq: error: cannot set an exit handler\");\n    abort();\n  }\n}\n\nstatic void tsd_init_nomem_handler(void)\n{\n  if (pthread_getspecific(nomem_handler_key) == NULL) {\n    struct nomem_handler *nomem_handler = calloc(1, sizeof(struct nomem_handler));\n    if (pthread_setspecific(nomem_handler_key, nomem_handler) != 0) {\n      fprintf(stderr, \"jq: error: cannot set thread specific data\");\n      abort();\n    }\n  }\n}\n\nvoid jv_nomem_handler(jv_nomem_handler_f handler, void *data) {\n  pthread_once(&mem_once, tsd_init); // cannot fail\n  tsd_init_nomem_handler();\n\n  struct nomem_handler *nomem_handler;\n\n  nomem_handler = pthread_getspecific(nomem_handler_key);\n  if (nomem_handler == NULL) {\n    handler(data);\n    fprintf(stderr, \"jq: error: cannot allocate memory\\n\");\n    abort();\n  }\n  nomem_handler->handler = handler;\n  nomem_handler->data = data;\n}\n\nstatic void memory_exhausted(void) {\n  struct nomem_handler *nomem_handler;\n\n  pthread_once(&mem_once, tsd_init);\n  tsd_init_nomem_handler();\n\n  nomem_handler = pthread_getspecific(nomem_handler_key);\n  if (nomem_handler && nomem_handler->handler)\n    nomem_handler->handler(nomem_handler->data); // Maybe handler() will longjmp() to safety\n  // Or not\n  fprintf(stderr, \"jq: error: cannot allocate memory\\n\");\n  abort();\n}\n\n#else\n\n/* No thread-local storage of any kind that we know how to handle */\n\nstatic struct nomem_handler nomem_handler;\nvoid jv_nomem_handler(jv_nomem_handler_f handler, void *data) {\n  nomem_handler.handler = handler;\n  nomem_handler.data = data;\n}\n\nstatic void memory_exhausted(void) {\n  fprintf(stderr, \"jq: error: cannot allocate memory\\n\");\n  abort();\n}\n\n#endif /* HAVE_PTHREAD_KEY_CREATE */\n#endif /* USE_TLS */\n\n\nvoid* jv_mem_alloc(size_t sz) {\n  void* p = malloc(sz);\n  if (!p) {\n    memory_exhausted();\n  }\n  return p;\n}\n\nvoid* jv_mem_alloc_unguarded(size_t sz) {\n  return malloc(sz);\n}\n\nvoid* jv_mem_calloc(size_t nemb, size_t sz) {\n  assert(nemb > 0 && sz > 0);\n  void* p = calloc(nemb, sz);\n  if (!p) {\n    memory_exhausted();\n  }\n  return p;\n}\n\nvoid* jv_mem_calloc_unguarded(size_t nemb, size_t sz) {\n  assert(nemb > 0 && sz > 0);\n  return calloc(nemb, sz);\n}\n\nchar* jv_mem_strdup(const char *s) {\n  char *p = strdup(s);\n  if (!p) {\n    memory_exhausted();\n  }\n  return p;\n}\n\nchar* jv_mem_strdup_unguarded(const char *s) {\n  return strdup(s);\n}\n\nvoid jv_mem_free(void* p) {\n  free(p);\n}\n\nvoid* jv_mem_realloc(void* p, size_t sz) {\n  p = realloc(p, sz);\n  if (!p) {\n    memory_exhausted();\n  }\n  return p;\n}\n"
  },
  {
    "path": "src/jv_alloc.h",
    "content": "#ifndef JV_ALLOC_H\n#define JV_ALLOC_H\n\n#include <stddef.h>\n\nvoid* jv_mem_alloc(size_t);\nvoid* jv_mem_alloc_unguarded(size_t);\nvoid* jv_mem_calloc(size_t, size_t);\nvoid* jv_mem_calloc_unguarded(size_t, size_t);\nchar* jv_mem_strdup(const char *);\nchar* jv_mem_strdup_unguarded(const char *);\nvoid jv_mem_free(void*);\n__attribute__((warn_unused_result)) void* jv_mem_realloc(void*, size_t);\n\n#endif\n"
  },
  {
    "path": "src/jv_aux.c",
    "content": "#include <assert.h>\n#include <limits.h>\n#include <math.h>\n#include <string.h>\n#include <stdlib.h>\n#include \"jv.h\"\n#include \"jv_alloc.h\"\n#include \"jv_private.h\"\n\n// making this static verbose function here\n// until we introduce a less confusing naming scheme\n// of jv_* API with regards to the memory management\nstatic double jv_number_get_value_and_consume(jv number) {\n  double value = jv_number_value(number);\n  jv_free(number);\n  return value;\n}\n\nstatic jv parse_slice(jv j, jv slice, int* pstart, int* pend) {\n  // Array slices\n  jv start_jv = jv_object_get(jv_copy(slice), jv_string(\"start\"));\n  jv end_jv = jv_object_get(slice, jv_string(\"end\"));\n  if (jv_get_kind(start_jv) == JV_KIND_NULL) {\n    jv_free(start_jv);\n    start_jv = jv_number(0);\n  }\n  int len;\n  if (jv_get_kind(j) == JV_KIND_ARRAY) {\n    len = jv_array_length(j);\n  } else if (jv_get_kind(j) == JV_KIND_STRING) {\n    len = jv_string_length_codepoints(j);\n  } else {\n    /*\n     * XXX This should be dead code because callers shouldn't call this\n     * function if `j' is neither an array nor a string.\n     */\n    jv_free(j);\n    jv_free(start_jv);\n    jv_free(end_jv);\n    return jv_invalid_with_msg(jv_string(\"Only arrays and strings can be sliced\"));\n  }\n  if (jv_get_kind(end_jv) == JV_KIND_NULL) {\n    jv_free(end_jv);\n    end_jv = jv_number(len);\n  }\n  if (jv_get_kind(start_jv) != JV_KIND_NUMBER ||\n      jv_get_kind(end_jv) != JV_KIND_NUMBER) {\n    jv_free(start_jv);\n    jv_free(end_jv);\n    return jv_invalid_with_msg(jv_string(\"Array/string slice indices must be integers\"));\n  }\n\n  double dstart = jv_number_value(start_jv);\n  double dend = jv_number_value(end_jv);\n  int start, end;\n\n  jv_free(start_jv);\n  jv_free(end_jv);\n  if (isnan(dstart)) dstart = 0;\n  if (dstart < 0)    dstart += len;\n  if (dstart < 0)    dstart = 0;\n  if (dstart > len)  dstart = len;\n  start = dstart > INT_MAX ? INT_MAX : (int)dstart; // Rounds down\n\n  if (isnan(dend))   dend = len;\n  if (dend < 0)      dend += len;\n  if (dend < 0)      dend  = start;\n  end = dend > INT_MAX ? INT_MAX : (int)dend;\n  if (end > len)     end = len;\n  if (end < len)     end += end < dend ? 1 : 0; // We round start down\n                                                // but round end up\n\n  if (end < start) end = start;\n  assert(0 <= start && start <= end && end <= len);\n  *pstart = start;\n  *pend = end;\n  return jv_true();\n}\n\njv jv_get(jv t, jv k) {\n  jv v;\n  if (jv_get_kind(t) == JV_KIND_OBJECT && jv_get_kind(k) == JV_KIND_STRING) {\n    v = jv_object_get(t, k);\n    if (!jv_is_valid(v)) {\n      jv_free(v);\n      v = jv_null();\n    }\n  } else if (jv_get_kind(t) == JV_KIND_ARRAY && jv_get_kind(k) == JV_KIND_NUMBER) {\n    if (jvp_number_is_nan(k)) {\n      jv_free(t);\n      v = jv_null();\n    } else {\n      double didx = jv_number_value(k);\n      if (didx < INT_MIN) didx = INT_MIN;\n      if (didx > INT_MAX) didx = INT_MAX;\n      int idx = (int)didx;\n      if (idx < 0)\n        idx += jv_array_length(jv_copy(t));\n      v = jv_array_get(t, idx);\n      if (!jv_is_valid(v)) {\n        jv_free(v);\n        v = jv_null();\n      }\n    }\n    jv_free(k);\n  } else if (jv_get_kind(t) == JV_KIND_ARRAY && jv_get_kind(k) == JV_KIND_OBJECT) {\n    int start, end;\n    jv e = parse_slice(jv_copy(t), k, &start, &end);\n    if (jv_get_kind(e) == JV_KIND_TRUE) {\n      v = jv_array_slice(t, start, end);\n    } else {\n      jv_free(t);\n      v = e;\n    }\n  } else if (jv_get_kind(t) == JV_KIND_STRING && jv_get_kind(k) == JV_KIND_OBJECT) {\n    int start, end;\n    jv e = parse_slice(jv_copy(t), k, &start, &end);\n    if (jv_get_kind(e) == JV_KIND_TRUE) {\n      v = jv_string_slice(t, start, end);\n    } else {\n      jv_free(t);\n      v = e;\n    }\n  } else if (jv_get_kind(t) == JV_KIND_ARRAY && jv_get_kind(k) == JV_KIND_ARRAY) {\n    v = jv_array_indexes(t, k);\n  } else if (jv_get_kind(t) == JV_KIND_NULL &&\n             (jv_get_kind(k) == JV_KIND_STRING ||\n              jv_get_kind(k) == JV_KIND_NUMBER ||\n              jv_get_kind(k) == JV_KIND_OBJECT)) {\n    jv_free(t);\n    jv_free(k);\n    v = jv_null();\n  } else {\n    char errbuf[30];\n    v = jv_invalid_with_msg(jv_string_fmt(\n          \"Cannot index %s with %s (%s)\",\n          jv_kind_name(jv_get_kind(t)),\n          jv_kind_name(jv_get_kind(k)),\n          jv_dump_string_trunc(jv_copy(k), errbuf, sizeof(errbuf))));\n    jv_free(t);\n    jv_free(k);\n  }\n  return v;\n}\n\njv jv_set(jv t, jv k, jv v) {\n  if (!jv_is_valid(v)) {\n    jv_free(t);\n    jv_free(k);\n    return v;\n  }\n  int isnull = jv_get_kind(t) == JV_KIND_NULL;\n  if (jv_get_kind(k) == JV_KIND_STRING &&\n      (jv_get_kind(t) == JV_KIND_OBJECT || isnull)) {\n    if (isnull) t = jv_object();\n    t = jv_object_set(t, k, v);\n  } else if (jv_get_kind(k) == JV_KIND_NUMBER &&\n             (jv_get_kind(t) == JV_KIND_ARRAY || isnull)) {\n    if (jvp_number_is_nan(k)) {\n      jv_free(t);\n      jv_free(k);\n      jv_free(v);\n      t = jv_invalid_with_msg(jv_string(\"Cannot set array element at NaN index\"));\n    } else {\n      double didx = jv_number_value(k);\n      if (didx < INT_MIN) didx = INT_MIN;\n      if (didx > INT_MAX) didx = INT_MAX;\n      if (isnull) t = jv_array();\n      t = jv_array_set(t, (int)didx, v);\n      jv_free(k);\n    }\n  } else if (jv_get_kind(k) == JV_KIND_OBJECT &&\n             (jv_get_kind(t) == JV_KIND_ARRAY || isnull)) {\n    if (isnull) t = jv_array();\n    int start, end;\n    jv e = parse_slice(jv_copy(t), k, &start, &end);\n    if (jv_get_kind(e) == JV_KIND_TRUE) {\n      if (jv_get_kind(v) == JV_KIND_ARRAY) {\n        int array_len = jv_array_length(jv_copy(t));\n        assert(0 <= start && start <= end && end <= array_len);\n        int slice_len = end - start;\n        int insert_len = jv_array_length(jv_copy(v));\n        if (slice_len < insert_len) {\n          // array is growing\n          int shift = insert_len - slice_len;\n          for (int i = array_len - 1; i >= end && jv_is_valid(t); i--) {\n            t = jv_array_set(t, i + shift, jv_array_get(jv_copy(t), i));\n          }\n        } else if (slice_len > insert_len) {\n          // array is shrinking\n          int shift = slice_len - insert_len;\n          for (int i = end; i < array_len && jv_is_valid(t); i++) {\n            t = jv_array_set(t, i - shift, jv_array_get(jv_copy(t), i));\n          }\n          if (jv_is_valid(t))\n            t = jv_array_slice(t, 0, array_len - shift);\n        }\n        for (int i = 0; i < insert_len && jv_is_valid(t); i++) {\n          t = jv_array_set(t, start + i, jv_array_get(jv_copy(v), i));\n        }\n        jv_free(v);\n      } else {\n        jv_free(t);\n        jv_free(v);\n        t = jv_invalid_with_msg(jv_string_fmt(\"A slice of an array can only be assigned another array\"));\n      }\n    } else {\n      jv_free(t);\n      jv_free(v);\n      t = e;\n    }\n  } else if (jv_get_kind(k) == JV_KIND_OBJECT && jv_get_kind(t) == JV_KIND_STRING) {\n    jv_free(t);\n    jv_free(k);\n    jv_free(v);\n    /* Well, why not?  We should implement this... */\n    t = jv_invalid_with_msg(jv_string_fmt(\"Cannot update string slices\"));\n  } else {\n    jv err = jv_invalid_with_msg(jv_string_fmt(\"Cannot update field at %s index of %s\",\n                                               jv_kind_name(jv_get_kind(k)),\n                                               jv_kind_name(jv_get_kind(t))));\n    jv_free(t);\n    jv_free(k);\n    jv_free(v);\n    t = err;\n  }\n  return t;\n}\n\njv jv_has(jv t, jv k) {\n  assert(jv_is_valid(t));\n  assert(jv_is_valid(k));\n  jv ret;\n  if (jv_get_kind(t) == JV_KIND_NULL) {\n    jv_free(t);\n    jv_free(k);\n    ret = jv_false();\n  } else if (jv_get_kind(t) == JV_KIND_OBJECT &&\n             jv_get_kind(k) == JV_KIND_STRING) {\n    jv elem = jv_object_get(t, k);\n    ret = jv_bool(jv_is_valid(elem));\n    jv_free(elem);\n  } else if (jv_get_kind(t) == JV_KIND_ARRAY &&\n             jv_get_kind(k) == JV_KIND_NUMBER) {\n    if (jvp_number_is_nan(k)) {\n      jv_free(t);\n      ret = jv_false();\n    } else {\n      jv elem = jv_array_get(t, (int)jv_number_value(k));\n      ret = jv_bool(jv_is_valid(elem));\n      jv_free(elem);\n    }\n    jv_free(k);\n  } else {\n    ret = jv_invalid_with_msg(jv_string_fmt(\"Cannot check whether %s has a %s key\",\n                                            jv_kind_name(jv_get_kind(t)),\n                                            jv_kind_name(jv_get_kind(k))));\n    jv_free(t);\n    jv_free(k);\n  }\n  return ret;\n}\n\n// assumes keys is a sorted array\nstatic jv jv_dels(jv t, jv keys) {\n  assert(jv_get_kind(keys) == JV_KIND_ARRAY);\n  assert(jv_is_valid(t));\n\n  if (jv_get_kind(t) == JV_KIND_NULL || jv_array_length(jv_copy(keys)) == 0) {\n    // no change\n  } else if (jv_get_kind(t) == JV_KIND_ARRAY) {\n    // extract slices, they must be handled differently\n    jv neg_keys = jv_array();\n    jv nonneg_keys = jv_array();\n    jv new_array = jv_array();\n    jv starts = jv_array(), ends = jv_array();\n    jv_array_foreach(keys, i, key) {\n      if (jv_get_kind(key) == JV_KIND_NUMBER) {\n        if (jvp_number_is_nan(key)) {\n          jv_free(key);\n        } else if (jv_number_value(key) < 0) {\n          neg_keys = jv_array_append(neg_keys, key);\n        } else {\n          nonneg_keys = jv_array_append(nonneg_keys, key);\n        }\n      } else if (jv_get_kind(key) == JV_KIND_OBJECT) {\n        int start, end;\n        jv e = parse_slice(jv_copy(t), key, &start, &end);\n        if (jv_get_kind(e) == JV_KIND_TRUE) {\n          starts = jv_array_append(starts, jv_number(start));\n          ends = jv_array_append(ends, jv_number(end));\n        } else {\n          jv_free(new_array);\n          new_array = e;\n          goto arr_out;\n        }\n      } else {\n        jv_free(new_array);\n        new_array = jv_invalid_with_msg(jv_string_fmt(\"Cannot delete %s element of array\",\n                                                      jv_kind_name(jv_get_kind(key))));\n        jv_free(key);\n        goto arr_out;\n      }\n    }\n\n    int neg_idx = 0;\n    int nonneg_idx = 0;\n    int len = jv_array_length(jv_copy(t));\n    for (int i = 0; i < len; ++i) {\n      int del = 0;\n      while (neg_idx < jv_array_length(jv_copy(neg_keys))) {\n        int delidx = len + (int)jv_number_get_value_and_consume(jv_array_get(jv_copy(neg_keys), neg_idx));\n        if (i == delidx) {\n          del = 1;\n        }\n        if (i < delidx) {\n          break;\n        }\n        neg_idx++;\n      }\n      while (nonneg_idx < jv_array_length(jv_copy(nonneg_keys))) {\n        int delidx = (int)jv_number_get_value_and_consume(jv_array_get(jv_copy(nonneg_keys), nonneg_idx));\n        if (i == delidx) {\n          del = 1;\n        }\n        if (i < delidx) {\n          break;\n        }\n        nonneg_idx++;\n      }\n      for (int sidx=0; !del && sidx<jv_array_length(jv_copy(starts)); sidx++) {\n        if ((int)jv_number_get_value_and_consume(jv_array_get(jv_copy(starts), sidx)) <= i &&\n            i < (int)jv_number_get_value_and_consume(jv_array_get(jv_copy(ends), sidx))) {\n          del = 1;\n        }\n      }\n      if (!del)\n        new_array = jv_array_append(new_array, jv_array_get(jv_copy(t), i));\n    }\n  arr_out:\n    jv_free(neg_keys);\n    jv_free(nonneg_keys);\n    jv_free(starts);\n    jv_free(ends);\n    jv_free(t);\n    t = new_array;\n  } else if (jv_get_kind(t) == JV_KIND_OBJECT) {\n    jv_array_foreach(keys, i, k) {\n      if (jv_get_kind(k) != JV_KIND_STRING) {\n        jv_free(t);\n        t = jv_invalid_with_msg(jv_string_fmt(\"Cannot delete %s field of object\",\n                                              jv_kind_name(jv_get_kind(k))));\n        jv_free(k);\n        break;\n      }\n      t = jv_object_delete(t, k);\n    }\n  } else {\n    jv err = jv_invalid_with_msg(jv_string_fmt(\"Cannot delete fields from %s\",\n                                               jv_kind_name(jv_get_kind(t))));\n    jv_free(t);\n    t = err;\n  }\n  jv_free(keys);\n  return t;\n}\n\njv jv_setpath(jv root, jv path, jv value) {\n  if (jv_get_kind(path) != JV_KIND_ARRAY) {\n    jv_free(value);\n    jv_free(root);\n    jv_free(path);\n    return jv_invalid_with_msg(jv_string(\"Path must be specified as an array\"));\n  }\n  if (!jv_is_valid(root)){\n    jv_free(value);\n    jv_free(path);\n    return root;\n  }\n  if (jv_array_length(jv_copy(path)) == 0) {\n    jv_free(path);\n    jv_free(root);\n    return value;\n  }\n  jv pathcurr = jv_array_get(jv_copy(path), 0);\n  jv pathrest = jv_array_slice(path, 1, jv_array_length(jv_copy(path)));\n\n  /*\n   * We need to be careful not to make extra copies since that leads to\n   * quadratic behavior (e.g., when growing large data structures in a\n   * reduction with `setpath/2`, i.e., with `|=`.\n   */\n  if (jv_get_kind(pathcurr) == JV_KIND_OBJECT) {\n    // Assignment to slice -- dunno yet how to avoid the extra copy\n    return jv_set(root, pathcurr,\n                  jv_setpath(jv_get(jv_copy(root), jv_copy(pathcurr)), pathrest, value));\n  }\n\n  jv subroot = jv_get(jv_copy(root), jv_copy(pathcurr));\n  if (!jv_is_valid(subroot)) {\n    jv_free(root);\n    jv_free(pathcurr);\n    jv_free(pathrest);\n    jv_free(value);\n    return subroot;\n  }\n\n  // To avoid the extra copy we drop the reference from `root` by setting that\n  // to null first.\n  root = jv_set(root, jv_copy(pathcurr), jv_null());\n  if (!jv_is_valid(root)) {\n    jv_free(subroot);\n    jv_free(pathcurr);\n    jv_free(pathrest);\n    jv_free(value);\n    return root;\n  }\n  return jv_set(root, pathcurr, jv_setpath(subroot, pathrest, value));\n}\n\njv jv_getpath(jv root, jv path) {\n  if (jv_get_kind(path) != JV_KIND_ARRAY) {\n    jv_free(root);\n    jv_free(path);\n    return jv_invalid_with_msg(jv_string(\"Path must be specified as an array\"));\n  }\n  if (!jv_is_valid(root)) {\n    jv_free(path);\n    return root;\n  }\n  if (jv_array_length(jv_copy(path)) == 0) {\n    jv_free(path);\n    return root;\n  }\n  jv pathcurr = jv_array_get(jv_copy(path), 0);\n  jv pathrest = jv_array_slice(path, 1, jv_array_length(jv_copy(path)));\n  return jv_getpath(jv_get(root, pathcurr), pathrest);\n}\n\n// assumes paths is a sorted array of arrays\nstatic jv delpaths_sorted(jv object, jv paths, int start) {\n  jv delkeys = jv_array();\n  for (int i=0; i<jv_array_length(jv_copy(paths));) {\n    assert(jv_array_length(jv_array_get(jv_copy(paths), i)) > start);\n    int delkey = jv_array_length(jv_array_get(jv_copy(paths), i)) == start + 1;\n    jv key = jv_array_get(jv_array_get(jv_copy(paths), i), start);\n    int j = i;\n    do\n      j++;\n    while (j < jv_array_length(jv_copy(paths)) &&\n           jv_equal(jv_copy(key), jv_array_get(jv_array_get(jv_copy(paths), j), start)));\n    // if i <= entry < j, then entry starts with key\n    if (delkey) {\n      // deleting this entire key, we don't care about any more specific deletions\n      delkeys = jv_array_append(delkeys, key);\n    } else {\n      // deleting certain sub-parts of this key\n      jv subobject = jv_get(jv_copy(object), jv_copy(key));\n      if (!jv_is_valid(subobject)) {\n        jv_free(key);\n        jv_free(object);\n        object = subobject;\n        break;\n      } else if (jv_get_kind(subobject) == JV_KIND_NULL) {\n        jv_free(key);\n        jv_free(subobject);\n      } else {\n        jv newsubobject = delpaths_sorted(subobject, jv_array_slice(jv_copy(paths), i, j), start+1);\n        if (!jv_is_valid(newsubobject)) {\n          jv_free(key);\n          jv_free(object);\n          object = newsubobject;\n          break;\n        }\n        object = jv_set(object, key, newsubobject);\n      }\n      if (!jv_is_valid(object)) break;\n    }\n    i = j;\n  }\n  jv_free(paths);\n  if (jv_is_valid(object))\n    object = jv_dels(object, delkeys);\n  else\n    jv_free(delkeys);\n  return object;\n}\n\njv jv_delpaths(jv object, jv paths) {\n  if (jv_get_kind(paths) != JV_KIND_ARRAY) {\n    jv_free(object);\n    jv_free(paths);\n    return jv_invalid_with_msg(jv_string(\"Paths must be specified as an array\"));\n  }\n  paths = jv_sort(paths, jv_copy(paths));\n  jv_array_foreach(paths, i, elem) {\n    if (jv_get_kind(elem) != JV_KIND_ARRAY) {\n      jv_free(object);\n      jv_free(paths);\n      jv err = jv_invalid_with_msg(jv_string_fmt(\"Path must be specified as array, not %s\",\n                                                 jv_kind_name(jv_get_kind(elem))));\n      jv_free(elem);\n      return err;\n    }\n    jv_free(elem);\n  }\n  if (jv_array_length(jv_copy(paths)) == 0) {\n    // nothing is being deleted\n    jv_free(paths);\n    return object;\n  }\n  if (jv_array_length(jv_array_get(jv_copy(paths), 0)) == 0) {\n    // everything is being deleted\n    jv_free(paths);\n    jv_free(object);\n    return jv_null();\n  }\n  return delpaths_sorted(object, paths, 0);\n}\n\n\nstatic int string_cmp(const void* pa, const void* pb){\n  const jv* a = pa;\n  const jv* b = pb;\n  int lena = jv_string_length_bytes(jv_copy(*a));\n  int lenb = jv_string_length_bytes(jv_copy(*b));\n  int minlen = lena < lenb ? lena : lenb;\n  int r = memcmp(jv_string_value(*a), jv_string_value(*b), minlen);\n  if (r == 0) r = lena - lenb;\n  return r;\n}\n\njv jv_keys_unsorted(jv x) {\n  if (jv_get_kind(x) != JV_KIND_OBJECT)\n    return jv_keys(x);\n  jv answer = jv_array_sized(jv_object_length(jv_copy(x)));\n  jv_object_foreach(x, key, value) {\n    answer = jv_array_append(answer, key);\n    jv_free(value);\n  }\n  jv_free(x);\n  return answer;\n}\n\njv jv_keys(jv x) {\n  if (jv_get_kind(x) == JV_KIND_OBJECT) {\n    int nkeys = jv_object_length(jv_copy(x));\n    if (nkeys == 0) {\n      jv_free(x);\n      return jv_array();\n    }\n    jv* keys = jv_mem_calloc(nkeys, sizeof(jv));\n    int kidx = 0;\n    jv_object_foreach(x, key, value) {\n      keys[kidx++] = key;\n      jv_free(value);\n    }\n    qsort(keys, nkeys, sizeof(jv), string_cmp);\n    jv answer = jv_array_sized(nkeys);\n    for (int i = 0; i<nkeys; i++) {\n      answer = jv_array_append(answer, keys[i]);\n    }\n    jv_mem_free(keys);\n    jv_free(x);\n    return answer;\n  } else if (jv_get_kind(x) == JV_KIND_ARRAY) {\n    int n = jv_array_length(x);\n    jv answer = jv_array();\n    for (int i=0; i<n; i++){\n      answer = jv_array_set(answer, i, jv_number(i));\n    }\n    return answer;\n  } else {\n    assert(0 && \"jv_keys passed something neither object nor array\");\n    return jv_invalid();\n  }\n}\n\nint jv_cmp(jv a, jv b) {\n  if (jv_get_kind(a) != jv_get_kind(b)) {\n    int r = (int)jv_get_kind(a) - (int)jv_get_kind(b);\n    jv_free(a);\n    jv_free(b);\n    return r;\n  }\n  int r = 0;\n  switch (jv_get_kind(a)) {\n  default:\n    assert(0 && \"invalid kind passed to jv_cmp\");\n  case JV_KIND_NULL:\n  case JV_KIND_FALSE:\n  case JV_KIND_TRUE:\n    // there's only one of each of these values\n    r = 0;\n    break;\n\n  case JV_KIND_NUMBER: {\n    if (jvp_number_is_nan(a)) {\n      r = jv_cmp(jv_null(), jv_copy(b));\n    } else if (jvp_number_is_nan(b)) {\n      r = jv_cmp(jv_copy(a), jv_null());\n    } else {\n      r = jvp_number_cmp(a, b);\n    }\n    break;\n  }\n\n  case JV_KIND_STRING: {\n    r = string_cmp(&a, &b);\n    break;\n  }\n\n  case JV_KIND_ARRAY: {\n    // Lexical ordering of arrays\n    int i = 0;\n    while (r == 0) {\n      int a_done = i >= jv_array_length(jv_copy(a));\n      int b_done = i >= jv_array_length(jv_copy(b));\n      if (a_done || b_done) {\n        r = b_done - a_done; //suddenly, logic\n        break;\n      }\n      jv xa = jv_array_get(jv_copy(a), i);\n      jv xb = jv_array_get(jv_copy(b), i);\n      r = jv_cmp(xa, xb);\n      i++;\n    }\n    break;\n  }\n\n  case JV_KIND_OBJECT: {\n    jv keys_a = jv_keys(jv_copy(a));\n    jv keys_b = jv_keys(jv_copy(b));\n    r = jv_cmp(jv_copy(keys_a), keys_b);\n    if (r == 0) {\n      jv_array_foreach(keys_a, i, key) {\n        jv xa = jv_object_get(jv_copy(a), jv_copy(key));\n        jv xb = jv_object_get(jv_copy(b), key);\n        r = jv_cmp(xa, xb);\n        if (r) break;\n      }\n    }\n    jv_free(keys_a);\n    break;\n  }\n  }\n\n  jv_free(a);\n  jv_free(b);\n  return r;\n}\n\n\nstruct sort_entry {\n  jv object;\n  jv key;\n  int index;\n};\n\nstatic int sort_cmp(const void* pa, const void* pb) {\n  const struct sort_entry* a = pa;\n  const struct sort_entry* b = pb;\n  int r = jv_cmp(jv_copy(a->key), jv_copy(b->key));\n  // comparing by index if r == 0 makes the sort stable\n  return r ? r : (a->index - b->index);\n}\n\nstatic struct sort_entry* sort_items(jv objects, jv keys) {\n  assert(jv_get_kind(objects) == JV_KIND_ARRAY);\n  assert(jv_get_kind(keys) == JV_KIND_ARRAY);\n  assert(jv_array_length(jv_copy(objects)) == jv_array_length(jv_copy(keys)));\n  int n = jv_array_length(jv_copy(objects));\n  if (n == 0) {\n    jv_free(objects);\n    jv_free(keys);\n    return NULL;\n  }\n  struct sort_entry* entries = jv_mem_calloc(n, sizeof(struct sort_entry));\n  for (int i=0; i<n; i++) {\n    entries[i].object = jv_array_get(jv_copy(objects), i);\n    entries[i].key = jv_array_get(jv_copy(keys), i);\n    entries[i].index = i;\n  }\n  jv_free(objects);\n  jv_free(keys);\n  qsort(entries, n, sizeof(struct sort_entry), sort_cmp);\n  return entries;\n}\n\njv jv_sort(jv objects, jv keys) {\n  assert(jv_get_kind(objects) == JV_KIND_ARRAY);\n  assert(jv_get_kind(keys) == JV_KIND_ARRAY);\n  assert(jv_array_length(jv_copy(objects)) == jv_array_length(jv_copy(keys)));\n  int n = jv_array_length(jv_copy(objects));\n  struct sort_entry* entries = sort_items(objects, keys);\n  jv ret = jv_array();\n  for (int i=0; i<n; i++) {\n    jv_free(entries[i].key);\n    ret = jv_array_set(ret, i, entries[i].object);\n  }\n  jv_mem_free(entries);\n  return ret;\n}\n\njv jv_group(jv objects, jv keys) {\n  assert(jv_get_kind(objects) == JV_KIND_ARRAY);\n  assert(jv_get_kind(keys) == JV_KIND_ARRAY);\n  assert(jv_array_length(jv_copy(objects)) == jv_array_length(jv_copy(keys)));\n  int n = jv_array_length(jv_copy(objects));\n  struct sort_entry* entries = sort_items(objects, keys);\n  jv ret = jv_array();\n  if (n > 0) {\n    jv curr_key = entries[0].key;\n    jv group = jv_array_append(jv_array(), entries[0].object);\n    for (int i = 1; i < n; i++) {\n      if (jv_equal(jv_copy(curr_key), jv_copy(entries[i].key))) {\n        jv_free(entries[i].key);\n      } else {\n        jv_free(curr_key);\n        curr_key = entries[i].key;\n        ret = jv_array_append(ret, group);\n        group = jv_array();\n      }\n      group = jv_array_append(group, entries[i].object);\n    }\n    jv_free(curr_key);\n    ret = jv_array_append(ret, group);\n  }\n  jv_mem_free(entries);\n  return ret;\n}\n\njv jv_unique(jv objects, jv keys) {\n  assert(jv_get_kind(objects) == JV_KIND_ARRAY);\n  assert(jv_get_kind(keys) == JV_KIND_ARRAY);\n  assert(jv_array_length(jv_copy(objects)) == jv_array_length(jv_copy(keys)));\n  int n = jv_array_length(jv_copy(objects));\n  struct sort_entry* entries = sort_items(objects, keys);\n  jv ret = jv_array();\n  jv curr_key = jv_invalid();\n  for (int i = 0; i < n; i++) {\n    if (jv_equal(jv_copy(curr_key), jv_copy(entries[i].key))) {\n      jv_free(entries[i].key);\n      jv_free(entries[i].object);\n    } else {\n      jv_free(curr_key);\n      curr_key = entries[i].key;\n      ret = jv_array_append(ret, entries[i].object);\n    }\n  }\n  jv_free(curr_key);\n  jv_mem_free(entries);\n  return ret;\n}\n"
  },
  {
    "path": "src/jv_dtoa.c",
    "content": "\n/****************************************************************\n *\n * The author of this software is David M. Gay.\n *\n * Copyright (c) 1991, 2000, 2001 by Lucent Technologies.\n *\n * Permission to use, copy, modify, and distribute this software for any\n * purpose without fee is hereby granted, provided that this entire notice\n * is included in all copies of any software which is or includes a copy\n * or modification of this software and in all copies of the supporting\n * documentation for such software.\n *\n * THIS SOFTWARE IS BEING PROVIDED \"AS IS\", WITHOUT ANY EXPRESS OR IMPLIED\n * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY\n * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY\n * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.\n *\n ***************************************************************/\n\n/* Please send bug reports to David M. Gay (dmg at acm dot org,\n * with \" at \" changed at \"@\" and \" dot \" changed to \".\").\t*/\n\n/* On a machine with IEEE extended-precision registers, it is\n * necessary to specify double-precision (53-bit) rounding precision\n * before invoking strtod or dtoa.  If the machine uses (the equivalent\n * of) Intel 80x87 arithmetic, the call\n *\t_control87(PC_53, MCW_PC);\n * does this with many compilers.  Whether this or another call is\n * appropriate depends on the compiler; for this to work, it may be\n * necessary to #include \"float.h\" or another system-dependent header\n * file.\n */\n\n/* strtod for IEEE-, VAX-, and IBM-arithmetic machines.\n * (Note that IEEE arithmetic is disabled by gcc's -ffast-math flag.)\n *\n * This strtod returns a nearest machine number to the input decimal\n * string (or sets errno to ERANGE).  With IEEE arithmetic, ties are\n * broken by the IEEE round-even rule.  Otherwise ties are broken by\n * biased rounding (add half and chop).\n *\n * Inspired loosely by William D. Clinger's paper \"How to Read Floating\n * Point Numbers Accurately\" [Proc. ACM SIGPLAN '90, pp. 92-101].\n *\n * Modifications:\n *\n *\t1. We only require IEEE, IBM, or VAX double-precision\n *\t\tarithmetic (not IEEE double-extended).\n *\t2. We get by with floating-point arithmetic in a case that\n *\t\tClinger missed -- when we're computing d * 10^n\n *\t\tfor a small integer d and the integer n is not too\n *\t\tmuch larger than 22 (the maximum integer k for which\n *\t\twe can represent 10^k exactly), we may be able to\n *\t\tcompute (d*10^k) * 10^(e-k) with just one roundoff.\n *\t3. Rather than a bit-at-a-time adjustment of the binary\n *\t\tresult in the hard case, we use floating-point\n *\t\tarithmetic to determine the adjustment to within\n *\t\tone bit; only in really hard cases do we need to\n *\t\tcompute a second residual.\n *\t4. Because of 3., we don't need a large table of powers of 10\n *\t\tfor ten-to-e (just some small tables, e.g. of 10^k\n *\t\tfor 0 <= k <= 22).\n */\n\n/*\n * #define IEEE_8087 for IEEE-arithmetic machines where the least\n *\tsignificant byte has the lowest address.\n * #define IEEE_MC68k for IEEE-arithmetic machines where the most\n *\tsignificant byte has the lowest address.\n * #define Long int on machines with 32-bit ints and 64-bit longs.\n * #define IBM for IBM mainframe-style floating-point arithmetic.\n * #define VAX for VAX-style floating-point arithmetic (D_floating).\n * #define No_leftright to omit left-right logic in fast floating-point\n *\tcomputation of dtoa.  This will cause dtoa modes 4 and 5 to be\n *\ttreated the same as modes 2 and 3 for some inputs.\n * #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3\n *\tand strtod and dtoa should round accordingly.  Unless Trust_FLT_ROUNDS\n *\tis also #defined, fegetround() will be queried for the rounding mode.\n *\tNote that both FLT_ROUNDS and fegetround() are specified by the C99\n *\tstandard (and are specified to be consistent, with fesetround()\n *\taffecting the value of FLT_ROUNDS), but that some (Linux) systems\n *\tdo not work correctly in this regard, so using fegetround() is more\n *\tportable than using FLT_ROUNDS directly.\n * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3\n *\tand Honor_FLT_ROUNDS is not #defined.\n * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines\n *\tthat use extended-precision instructions to compute rounded\n *\tproducts and quotients) with IBM.\n * #define ROUND_BIASED for IEEE-format with biased rounding and arithmetic\n *\tthat rounds toward +Infinity.\n * #define ROUND_BIASED_without_Round_Up for IEEE-format with biased\n *\trounding when the underlying floating-point arithmetic uses\n *\tunbiased rounding.  This prevent using ordinary floating-point\n *\tarithmetic when the result could be computed with one rounding error.\n * #define Inaccurate_Divide for IEEE-format with correctly rounded\n *\tproducts but inaccurate quotients, e.g., for Intel i860.\n * #define NO_LONG_LONG on machines that do not have a \"long long\"\n *\tinteger type (of >= 64 bits).  On such machines, you can\n *\t#define Just_16 to store 16 bits per 32-bit Long when doing\n *\thigh-precision integer arithmetic.  Whether this speeds things\n *\tup or slows things down depends on the machine and the number\n *\tbeing converted.  If long long is available and the name is\n *\tsomething other than \"long long\", #define Llong to be the name,\n *\tand if \"unsigned Llong\" does not work as an unsigned version of\n *\tLlong, #define #ULLong to be the corresponding unsigned type.\n * #define KR_headers for old-style C function headers.\n * #define Bad_float_h if your system lacks a float.h or if it does not\n *\tdefine some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,\n *\tFLT_RADIX, FLT_ROUNDS, and DBL_MAX.\n * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)\n *\tif memory is available and otherwise does something you deem\n *\tappropriate.  If MALLOC is undefined, malloc will be invoked\n *\tdirectly -- and assumed always to succeed.  Similarly, if you\n *\twant something other than the system's free() to be called to\n *\trecycle memory acquired from MALLOC, #define FREE to be the\n *\tname of the alternate routine.  (FREE or free is only called in\n *\tpathological cases, e.g., in a dtoa call after a dtoa return in\n *\tmode 3 with thousands of digits requested.)\n * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making\n *\tmemory allocations from a private pool of memory when possible.\n *\tWhen used, the private pool is PRIVATE_MEM bytes long:  2304 bytes,\n *\tunless #defined to be a different length.  This default length\n *\tsuffices to get rid of MALLOC calls except for unusual cases,\n *\tsuch as decimal-to-binary conversion of a very long string of\n *\tdigits.  The longest string dtoa can return is about 751 bytes\n *\tlong.  For conversions by strtod of strings of 800 digits and\n *\tall dtoa conversions in single-threaded executions with 8-byte\n *\tpointers, PRIVATE_MEM >= 7400 appears to suffice; with 4-byte\n *\tpointers, PRIVATE_MEM >= 7112 appears adequate.\n * #define NO_INFNAN_CHECK if you do not wish to have INFNAN_CHECK\n *\t#defined automatically on IEEE systems.  On such systems,\n *\twhen INFNAN_CHECK is #defined, strtod checks\n *\tfor Infinity and NaN (case insensitively).  On some systems\n *\t(e.g., some HP systems), it may be necessary to #define NAN_WORD0\n *\tappropriately -- to the most significant word of a quiet NaN.\n *\t(On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)\n *\tWhen INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,\n *\tstrtod also accepts (case insensitively) strings of the form\n *\tNaN(x), where x is a string of hexadecimal digits and spaces;\n *\tif there is only one string of hexadecimal digits, it is taken\n *\tfor the 52 fraction bits of the resulting NaN; if there are two\n *\tor more strings of hex digits, the first is for the high 20 bits,\n *\tthe second and subsequent for the low 32 bits, with intervening\n *\twhite space ignored; but if this results in none of the 52\n *\tfraction bits being on (an IEEE Infinity symbol), then NAN_WORD0\n *\tand NAN_WORD1 are used instead.\n * #define MULTIPLE_THREADS if the system offers preemptively scheduled\n *\tmultiple threads.  In this case, you must provide (or suitably\n *\t#define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed\n *\tby FREE_DTOA_LOCK(n) for n = 0 or 1.  (The second lock, accessed\n *\tin pow5mult, ensures lazy evaluation of only one copy of high\n *\tpowers of 5; omitting this lock would introduce a small\n *\tprobability of wasting memory, but would otherwise be harmless.)\n *\tYou must also invoke freedtoa(s) to free the value s returned by\n *\tdtoa.  You may do so whether or not MULTIPLE_THREADS is #defined.\n * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that\n *\tavoids underflows on inputs whose result does not underflow.\n *\tIf you #define NO_IEEE_Scale on a machine that uses IEEE-format\n *\tfloating-point numbers and flushes underflows to zero rather\n *\tthan implementing gradual underflow, then you must also #define\n *\tSudden_Underflow.\n * #define USE_LOCALE to use the current locale's decimal_point value.\n * #define SET_INEXACT if IEEE arithmetic is being used and extra\n *\tcomputation should be done to set the inexact flag when the\n *\tresult is inexact and avoid setting inexact when the result\n *\tis exact.  In this case, dtoa.c must be compiled in\n *\tan environment, perhaps provided by #include \"dtoa.c\" in a\n *\tsuitable wrapper, that defines two functions,\n *\t\tint get_inexact(void);\n *\t\tvoid clear_inexact(void);\n *\tsuch that get_inexact() returns a nonzero value if the\n *\tinexact bit is already set, and clear_inexact() sets the\n *\tinexact bit to 0.  When SET_INEXACT is #defined, strtod\n *\talso does extra computations to set the underflow and overflow\n *\tflags when appropriate (i.e., when the result is tiny and\n *\tinexact or when it is a numeric value rounded to +-infinity).\n * #define NO_ERRNO if strtod should not assign errno = ERANGE when\n *\tthe result overflows to +-Infinity or underflows to 0.\n * #define NO_HEX_FP to omit recognition of hexadecimal floating-point\n *\tvalues by strtod.\n * #define NO_STRTOD_BIGCOMP (on IEEE-arithmetic systems only for now)\n *\tto disable logic for \"fast\" testing of very long input strings\n *\tto strtod.  This testing proceeds by initially truncating the\n *\tinput string, then if necessary comparing the whole string with\n *\ta decimal expansion to decide close cases. This logic is only\n *\tused for input more than STRTOD_DIGLIM digits long (default 40).\n */\n\n#define NO_ERRNO\n#define NO_HEX_FP\n#define No_Hex_NaN\n#define Long int\n\n#include \"jv_dtoa.h\"\n\n#include \"jv_alloc.h\"\n#include \"jv.h\"\n#define MALLOC jv_mem_alloc\n#define FREE jv_mem_free\n\n\n\n#ifndef Long\n#define Long long\n#endif\n#ifndef ULong\ntypedef unsigned Long ULong;\n#endif\n\n#ifdef DEBUG\n#include \"stdio.h\"\n#define Bug(x) {fprintf(stderr, \"%s\\n\", x); exit(1);}\n#endif\n\n#include \"stdlib.h\"\n#include \"string.h\"\n\n#ifdef USE_LOCALE\n#include \"locale.h\"\n#endif\n\n#ifdef Honor_FLT_ROUNDS\n#ifndef Trust_FLT_ROUNDS\n#include <fenv.h>\n#endif\n#endif\n\n#ifdef MALLOC\nextern void *MALLOC(size_t);\n#else\n#define MALLOC malloc\n#endif\n\n#undef IEEE_Arith\n#undef Avoid_Underflow\n#ifdef IEEE_MC68k\n#define IEEE_Arith\n#endif\n#ifdef IEEE_8087\n#define IEEE_Arith\n#endif\n\n#ifdef IEEE_Arith\n#ifndef NO_INFNAN_CHECK\n#undef INFNAN_CHECK\n#define INFNAN_CHECK\n#endif\n#else\n#undef INFNAN_CHECK\n#define NO_STRTOD_BIGCOMP\n#endif\n\n#include \"errno.h\"\n\n#ifdef Bad_float_h\n\n#ifdef IEEE_Arith\n#define DBL_DIG 15\n#define DBL_MAX_10_EXP 308\n#define DBL_MAX_EXP 1024\n#define FLT_RADIX 2\n#endif /*IEEE_Arith*/\n\n#ifdef IBM\n#define DBL_DIG 16\n#define DBL_MAX_10_EXP 75\n#define DBL_MAX_EXP 63\n#define FLT_RADIX 16\n#define DBL_MAX 7.2370055773322621e+75\n#endif\n\n#ifdef VAX\n#define DBL_DIG 16\n#define DBL_MAX_10_EXP 38\n#define DBL_MAX_EXP 127\n#define FLT_RADIX 2\n#define DBL_MAX 1.7014118346046923e+38\n#endif\n\n#ifndef LONG_MAX\n#define LONG_MAX 2147483647\n#endif\n\n#else /* ifndef Bad_float_h */\n#include \"float.h\"\n#endif /* Bad_float_h */\n\n#ifndef __MATH_H__\n#include \"math.h\"\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef CONST\n#define CONST const\n#endif\n\n#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1\n#  error Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.\n#endif\n\ntypedef union { double d; ULong L[2]; } U;\n\n#ifdef IEEE_8087\n#define word0(x) (x)->L[1]\n#define word1(x) (x)->L[0]\n#else\n#define word0(x) (x)->L[0]\n#define word1(x) (x)->L[1]\n#endif\n#define dval(x) (x)->d\n\n#ifndef STRTOD_DIGLIM\n#define STRTOD_DIGLIM 40\n#endif\n\n#ifdef DIGLIM_DEBUG\nextern int strtod_diglim;\n#else\n#define strtod_diglim STRTOD_DIGLIM\n#endif\n\n/* The following definition of Storeinc is appropriate for MIPS processors.\n * An alternative that might be better on some machines is\n * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)\n */\n#if defined(IEEE_8087) + defined(VAX)\n#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \\\n((unsigned short *)a)[0] = (unsigned short)c, a++)\n#else\n#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \\\n((unsigned short *)a)[1] = (unsigned short)c, a++)\n#endif\n\n/* #define P DBL_MANT_DIG */\n/* Ten_pmax = floor(P*log(2)/log(5)) */\n/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */\n/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */\n/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */\n\n#ifdef IEEE_Arith\n#define Exp_shift  20\n#define Exp_shift1 20\n#define Exp_msk1    0x100000\n#define Exp_msk11   0x100000\n#define Exp_mask  0x7ff00000\n#define P 53\n#define Nbits 53\n#define Bias 1023\n#define Emax 1023\n#define Emin (-1022)\n#define Exp_1  0x3ff00000\n#define Exp_11 0x3ff00000\n#define Ebits 11\n#define Frac_mask  0xfffff\n#define Frac_mask1 0xfffff\n#define Ten_pmax 22\n#define Bletch 0x10\n#define Bndry_mask  0xfffff\n#define Bndry_mask1 0xfffff\n#define LSB 1\n#define Sign_bit 0x80000000\n#define Log2P 1\n#define Tiny0 0\n#define Tiny1 1\n#define Quick_max 14\n#define Int_max 14\n#ifndef NO_IEEE_Scale\n#define Avoid_Underflow\n#ifdef Flush_Denorm\t/* debugging option */\n#undef Sudden_Underflow\n#endif\n#endif\n\n#ifndef Flt_Rounds\n#ifdef FLT_ROUNDS\n#define Flt_Rounds FLT_ROUNDS\n#else\n#define Flt_Rounds 1\n#endif\n#endif /*Flt_Rounds*/\n\n#ifdef Honor_FLT_ROUNDS\n#undef Check_FLT_ROUNDS\n#define Check_FLT_ROUNDS\n#else\n#define Rounding Flt_Rounds\n#endif\n\n#else /* ifndef IEEE_Arith */\n#undef Check_FLT_ROUNDS\n#undef Honor_FLT_ROUNDS\n#undef SET_INEXACT\n#undef  Sudden_Underflow\n#define Sudden_Underflow\n#ifdef IBM\n#undef Flt_Rounds\n#define Flt_Rounds 0\n#define Exp_shift  24\n#define Exp_shift1 24\n#define Exp_msk1   0x1000000\n#define Exp_msk11  0x1000000\n#define Exp_mask  0x7f000000\n#define P 14\n#define Nbits 56\n#define Bias 65\n#define Emax 248\n#define Emin (-260)\n#define Exp_1  0x41000000\n#define Exp_11 0x41000000\n#define Ebits 8\t/* exponent has 7 bits, but 8 is the right value in b2d */\n#define Frac_mask  0xffffff\n#define Frac_mask1 0xffffff\n#define Bletch 4\n#define Ten_pmax 22\n#define Bndry_mask  0xefffff\n#define Bndry_mask1 0xffffff\n#define LSB 1\n#define Sign_bit 0x80000000\n#define Log2P 4\n#define Tiny0 0x100000\n#define Tiny1 0\n#define Quick_max 14\n#define Int_max 15\n#else /* VAX */\n#undef Flt_Rounds\n#define Flt_Rounds 1\n#define Exp_shift  23\n#define Exp_shift1 7\n#define Exp_msk1    0x80\n#define Exp_msk11   0x800000\n#define Exp_mask  0x7f80\n#define P 56\n#define Nbits 56\n#define Bias 129\n#define Emax 126\n#define Emin (-129)\n#define Exp_1  0x40800000\n#define Exp_11 0x4080\n#define Ebits 8\n#define Frac_mask  0x7fffff\n#define Frac_mask1 0xffff007f\n#define Ten_pmax 24\n#define Bletch 2\n#define Bndry_mask  0xffff007f\n#define Bndry_mask1 0xffff007f\n#define LSB 0x10000\n#define Sign_bit 0x8000\n#define Log2P 1\n#define Tiny0 0x80\n#define Tiny1 0\n#define Quick_max 15\n#define Int_max 15\n#endif /* IBM, VAX */\n#endif /* IEEE_Arith */\n\n#ifndef IEEE_Arith\n#define ROUND_BIASED\n#else\n#ifdef ROUND_BIASED_without_Round_Up\n#undef  ROUND_BIASED\n#define ROUND_BIASED\n#endif\n#endif\n\n#ifdef RND_PRODQUOT\n#define rounded_product(a,b) a = rnd_prod(a, b)\n#define rounded_quotient(a,b) a = rnd_quot(a, b)\nextern double rnd_prod(double, double), rnd_quot(double, double);\n#else\n#define rounded_product(a,b) a *= b\n#define rounded_quotient(a,b) a /= b\n#endif\n\n#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))\n#define Big1 0xffffffff\n\n#ifndef Pack_32\n#define Pack_32\n#endif\n\ntypedef struct BCinfo BCinfo;\n struct\nBCinfo { int dp0, dp1, dplen, dsign, e0, inexact, nd, nd0, rounding, scale, uflchk; };\n\n#define FFFFFFFF 0xffffffffUL\n\n#ifdef NO_LONG_LONG\n#undef ULLong\n#ifdef Just_16\n#undef Pack_32\n/* When Pack_32 is not defined, we store 16 bits per 32-bit Long.\n * This makes some inner loops simpler and sometimes saves work\n * during multiplications, but it often seems to make things slightly\n * slower.  Hence the default is now to store 32 bits per Long.\n */\n#endif\n#else\t/* long long available */\n#ifndef Llong\n#define Llong long long\n#endif\n#ifndef ULLong\n#define ULLong unsigned Llong\n#endif\n#endif /* NO_LONG_LONG */\n\n\n\n struct\nBigint {\n\tstruct Bigint *next;\n\tint k, maxwds, sign, wds;\n\tULong x[1];\n\t};\n\n typedef struct Bigint Bigint;\n\n\nvoid jvp_dtoa_context_init(struct dtoa_context* C) {\n  int i;\n  for (i=0; i<(int)(sizeof(C->freelist)/sizeof(C->freelist[0])); i++) {\n    C->freelist[i] = 0;\n  }\n  C->p5s = 0;\n}\n\n static Bigint *\n Balloc(struct dtoa_context* C, int k)\n{\n\tint x;\n\tBigint *rv;\n\n\t/* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */\n\t/* but this case seems very unlikely. */\n\tif (k <= Kmax && (rv = C->freelist[k]))\n\t\tC->freelist[k] = rv->next;\n\telse {\n\t\tx = 1 << k;\n\t\trv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));\n\t\trv->k = k;\n\t\trv->maxwds = x;\n\t\t}\n\trv->sign = rv->wds = 0;\n\treturn rv;\n\t}\n\n static void\nBfree\n (struct dtoa_context* C, Bigint *v)\n{\n\tif (v) {\n\t\tif (v->k > Kmax)\n#ifdef FREE\n\t\t\tFREE((void*)v);\n#else\n\t\t\tfree((void*)v);\n#endif\n\t\telse {\n\t\t\tv->next = C->freelist[v->k];\n\t\t\tC->freelist[v->k] = v;\n\t\t\t}\n\t\t}\n\t}\n\n\nvoid jvp_dtoa_context_free(struct dtoa_context* C) {\n  int k;\n  while (C->p5s) {\n    Bigint* p5 = C->p5s;\n    C->p5s = p5->next;\n    Bfree(C, p5);\n  }\n  for (k=0; k<(int)(sizeof(C->freelist)/sizeof(C->freelist[0])); k++) {\n    while (C->freelist[k]) {\n      Bigint* v = C->freelist[k];\n      C->freelist[k] = v->next;\n      FREE(v);\n    }\n  }\n}\n\n\n#define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \\\ny->wds*sizeof(Long) + 2*sizeof(int))\n\n static Bigint *\nmultadd\n (struct dtoa_context* C, Bigint *b, int m, int a)\t/* multiply by m and add a */\n{\n\tint i, wds;\n#ifdef ULLong\n\tULong *x;\n\tULLong carry, y;\n#else\n\tULong carry, *x, y;\n#ifdef Pack_32\n\tULong xi, z;\n#endif\n#endif\n\tBigint *b1;\n\n\twds = b->wds;\n\tx = b->x;\n\ti = 0;\n\tcarry = a;\n\tdo {\n#ifdef ULLong\n\t\ty = *x * (ULLong)m + carry;\n\t\tcarry = y >> 32;\n\t\t*x++ = y & FFFFFFFF;\n#else\n#ifdef Pack_32\n\t\txi = *x;\n\t\ty = (xi & 0xffff) * m + carry;\n\t\tz = (xi >> 16) * m + (y >> 16);\n\t\tcarry = z >> 16;\n\t\t*x++ = (z << 16) + (y & 0xffff);\n#else\n\t\ty = *x * m + carry;\n\t\tcarry = y >> 16;\n\t\t*x++ = y & 0xffff;\n#endif\n#endif\n\t\t}\n\t\twhile(++i < wds);\n\tif (carry) {\n\t\tif (wds >= b->maxwds) {\n\t\t\tb1 = Balloc(C, b->k+1);\n\t\t\tBcopy(b1, b);\n\t\t\tBfree(C, b);\n\t\t\tb = b1;\n\t\t\t}\n\t\tb->x[wds++] = carry;\n\t\tb->wds = wds;\n\t\t}\n\treturn b;\n\t}\n\n static Bigint *\ns2b\n (struct dtoa_context* C, const char *s, int nd0, int nd, ULong y9, int dplen)\n{\n\tBigint *b;\n\tint i, k;\n\tLong x, y;\n\n\tx = (nd + 8) / 9;\n\tfor(k = 0, y = 1; x > y; y <<= 1, k++) ;\n#ifdef Pack_32\n\tb = Balloc(C, k);\n\tb->x[0] = y9;\n\tb->wds = 1;\n#else\n\tb = Balloc(C, k+1);\n\tb->x[0] = y9 & 0xffff;\n\tb->wds = (b->x[1] = y9 >> 16) ? 2 : 1;\n#endif\n\n\ti = 9;\n\tif (9 < nd0) {\n\t\ts += 9;\n\t\tdo b = multadd(C, b, 10, *s++ - '0');\n\t\t\twhile(++i < nd0);\n\t\ts += dplen;\n\t\t}\n\telse\n\t\ts += dplen + 9;\n\tfor(; i < nd; i++)\n\t\tb = multadd(C, b, 10, *s++ - '0');\n\treturn b;\n\t}\n\n static int\nhi0bits\n (struct dtoa_context* C, ULong x)\n{\n\tint k = 0;\n\n\tif (!(x & 0xffff0000)) {\n\t\tk = 16;\n\t\tx <<= 16;\n\t\t}\n\tif (!(x & 0xff000000)) {\n\t\tk += 8;\n\t\tx <<= 8;\n\t\t}\n\tif (!(x & 0xf0000000)) {\n\t\tk += 4;\n\t\tx <<= 4;\n\t\t}\n\tif (!(x & 0xc0000000)) {\n\t\tk += 2;\n\t\tx <<= 2;\n\t\t}\n\tif (!(x & 0x80000000)) {\n\t\tk++;\n\t\tif (!(x & 0x40000000))\n\t\t\treturn 32;\n\t\t}\n\treturn k;\n\t}\n\n static int\nlo0bits\n (struct dtoa_context* C, ULong *y)\n{\n\tint k;\n\tULong x = *y;\n\n\tif (x & 7) {\n\t\tif (x & 1)\n\t\t\treturn 0;\n\t\tif (x & 2) {\n\t\t\t*y = x >> 1;\n\t\t\treturn 1;\n\t\t\t}\n\t\t*y = x >> 2;\n\t\treturn 2;\n\t\t}\n\tk = 0;\n\tif (!(x & 0xffff)) {\n\t\tk = 16;\n\t\tx >>= 16;\n\t\t}\n\tif (!(x & 0xff)) {\n\t\tk += 8;\n\t\tx >>= 8;\n\t\t}\n\tif (!(x & 0xf)) {\n\t\tk += 4;\n\t\tx >>= 4;\n\t\t}\n\tif (!(x & 0x3)) {\n\t\tk += 2;\n\t\tx >>= 2;\n\t\t}\n\tif (!(x & 1)) {\n\t\tk++;\n\t\tx >>= 1;\n\t\tif (!x)\n\t\t\treturn 32;\n\t\t}\n\t*y = x;\n\treturn k;\n\t}\n\n static Bigint *\ni2b\n (struct dtoa_context* C, int i)\n{\n\tBigint *b;\n\n\tb = Balloc(C, 1);\n\tb->x[0] = i;\n\tb->wds = 1;\n\treturn b;\n\t}\n\n static Bigint *\nmult\n (struct dtoa_context* C, Bigint *a, Bigint *b)\n{\n\tBigint *c;\n\tint k, wa, wb, wc;\n\tULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;\n\tULong y;\n#ifdef ULLong\n\tULLong carry, z;\n#else\n\tULong carry, z;\n#ifdef Pack_32\n\tULong z2;\n#endif\n#endif\n\n\tif (a->wds < b->wds) {\n\t\tc = a;\n\t\ta = b;\n\t\tb = c;\n\t\t}\n\tk = a->k;\n\twa = a->wds;\n\twb = b->wds;\n\twc = wa + wb;\n\tif (wc > a->maxwds)\n\t\tk++;\n\tc = Balloc(C, k);\n\tfor(x = c->x, xa = x + wc; x < xa; x++)\n\t\t*x = 0;\n\txa = a->x;\n\txae = xa + wa;\n\txb = b->x;\n\txbe = xb + wb;\n\txc0 = c->x;\n#ifdef ULLong\n\tfor(; xb < xbe; xc0++) {\n\t\tif ((y = *xb++)) {\n\t\t\tx = xa;\n\t\t\txc = xc0;\n\t\t\tcarry = 0;\n\t\t\tdo {\n\t\t\t\tz = *x++ * (ULLong)y + *xc + carry;\n\t\t\t\tcarry = z >> 32;\n\t\t\t\t*xc++ = z & FFFFFFFF;\n\t\t\t\t}\n\t\t\t\twhile(x < xae);\n\t\t\t*xc = carry;\n\t\t\t}\n\t\t}\n#else\n#ifdef Pack_32\n\tfor(; xb < xbe; xb++, xc0++) {\n\t\tif (y = *xb & 0xffff) {\n\t\t\tx = xa;\n\t\t\txc = xc0;\n\t\t\tcarry = 0;\n\t\t\tdo {\n\t\t\t\tz = (*x & 0xffff) * y + (*xc & 0xffff) + carry;\n\t\t\t\tcarry = z >> 16;\n\t\t\t\tz2 = (*x++ >> 16) * y + (*xc >> 16) + carry;\n\t\t\t\tcarry = z2 >> 16;\n\t\t\t\tStoreinc(xc, z2, z);\n\t\t\t\t}\n\t\t\t\twhile(x < xae);\n\t\t\t*xc = carry;\n\t\t\t}\n\t\tif (y = *xb >> 16) {\n\t\t\tx = xa;\n\t\t\txc = xc0;\n\t\t\tcarry = 0;\n\t\t\tz2 = *xc;\n\t\t\tdo {\n\t\t\t\tz = (*x & 0xffff) * y + (*xc >> 16) + carry;\n\t\t\t\tcarry = z >> 16;\n\t\t\t\tStoreinc(xc, z, z2);\n\t\t\t\tz2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;\n\t\t\t\tcarry = z2 >> 16;\n\t\t\t\t}\n\t\t\t\twhile(x < xae);\n\t\t\t*xc = z2;\n\t\t\t}\n\t\t}\n#else\n\tfor(; xb < xbe; xc0++) {\n\t\tif (y = *xb++) {\n\t\t\tx = xa;\n\t\t\txc = xc0;\n\t\t\tcarry = 0;\n\t\t\tdo {\n\t\t\t\tz = *x++ * y + *xc + carry;\n\t\t\t\tcarry = z >> 16;\n\t\t\t\t*xc++ = z & 0xffff;\n\t\t\t\t}\n\t\t\t\twhile(x < xae);\n\t\t\t*xc = carry;\n\t\t\t}\n\t\t}\n#endif\n#endif\n\tfor(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ;\n\tc->wds = wc;\n\treturn c;\n\t}\n\n\n static Bigint *\npow5mult\n (struct dtoa_context* C, Bigint *b, int k)\n{\n\tBigint *b1, *p5, *p51;\n\tint i;\n\tstatic const int p05[3] = { 5, 25, 125 };\n\n\tif ((i = k & 3))\n\t\tb = multadd(C, b, p05[i-1], 0);\n\n\tif (!(k >>= 2))\n\t\treturn b;\n\tif (!(p5 = C->p5s)) {\n\t\t/* first time */\n\t\tp5 = C->p5s = i2b(C, 625);\n\t\tp5->next = 0;\n\t\t}\n\tfor(;;) {\n\t\tif (k & 1) {\n\t\t\tb1 = mult(C, b, p5);\n\t\t\tBfree(C, b);\n\t\t\tb = b1;\n\t\t\t}\n\t\tif (!(k >>= 1))\n\t\t\tbreak;\n\t\tif (!(p51 = p5->next)) {\n\t\t\tp51 = p5->next = mult(C, p5,p5);\n\t\t\tp51->next = 0;\n\t\t\t}\n\t\tp5 = p51;\n\t\t}\n\treturn b;\n\t}\n\n static Bigint *\nlshift\n (struct dtoa_context* C, Bigint *b, int k)\n{\n\tint i, k1, n, n1;\n\tBigint *b1;\n\tULong *x, *x1, *xe, z;\n\n#ifdef Pack_32\n\tn = k >> 5;\n#else\n\tn = k >> 4;\n#endif\n\tk1 = b->k;\n\tn1 = n + b->wds + 1;\n\tfor(i = b->maxwds; n1 > i; i <<= 1)\n\t\tk1++;\n\tb1 = Balloc(C, k1);\n\tx1 = b1->x;\n\tfor(i = 0; i < n; i++)\n\t\t*x1++ = 0;\n\tx = b->x;\n\txe = x + b->wds;\n#ifdef Pack_32\n\tif (k &= 0x1f) {\n\t\tk1 = 32 - k;\n\t\tz = 0;\n\t\tdo {\n\t\t\t*x1++ = *x << k | z;\n\t\t\tz = *x++ >> k1;\n\t\t\t}\n\t\t\twhile(x < xe);\n\t\tif ((*x1 = z))\n\t\t\t++n1;\n\t\t}\n#else\n\tif (k &= 0xf) {\n\t\tk1 = 16 - k;\n\t\tz = 0;\n\t\tdo {\n\t\t\t*x1++ = *x << k  & 0xffff | z;\n\t\t\tz = *x++ >> k1;\n\t\t\t}\n\t\t\twhile(x < xe);\n\t\tif (*x1 = z)\n\t\t\t++n1;\n\t\t}\n#endif\n\telse do\n\t\t*x1++ = *x++;\n\t\twhile(x < xe);\n\tb1->wds = n1 - 1;\n\tBfree(C, b);\n\treturn b1;\n\t}\n\n static int\ncmp\n (struct dtoa_context* C, Bigint *a, Bigint *b)\n{\n\tULong *xa, *xa0, *xb, *xb0;\n\tint i, j;\n\n\ti = a->wds;\n\tj = b->wds;\n#ifdef DEBUG\n\tif (i > 1 && !a->x[i-1])\n\t\tBug(\"cmp called with a->x[a->wds-1] == 0\");\n\tif (j > 1 && !b->x[j-1])\n\t\tBug(\"cmp called with b->x[b->wds-1] == 0\");\n#endif\n\tif (i -= j)\n\t\treturn i;\n\txa0 = a->x;\n\txa = xa0 + j;\n\txb0 = b->x;\n\txb = xb0 + j;\n\tfor(;;) {\n\t\tif (*--xa != *--xb)\n\t\t\treturn *xa < *xb ? -1 : 1;\n\t\tif (xa <= xa0)\n\t\t\tbreak;\n\t\t}\n\treturn 0;\n\t}\n\n static Bigint *\ndiff\n (struct dtoa_context* C, Bigint *a, Bigint *b)\n{\n\tBigint *c;\n\tint i, wa, wb;\n\tULong *xa, *xae, *xb, *xbe, *xc;\n#ifdef ULLong\n\tULLong borrow, y;\n#else\n\tULong borrow, y;\n#ifdef Pack_32\n\tULong z;\n#endif\n#endif\n\n\ti = cmp(C, a,b);\n\tif (!i) {\n\t\tc = Balloc(C, 0);\n\t\tc->wds = 1;\n\t\tc->x[0] = 0;\n\t\treturn c;\n\t\t}\n\tif (i < 0) {\n\t\tc = a;\n\t\ta = b;\n\t\tb = c;\n\t\ti = 1;\n\t\t}\n\telse\n\t\ti = 0;\n\tc = Balloc(C, a->k);\n\tc->sign = i;\n\twa = a->wds;\n\txa = a->x;\n\txae = xa + wa;\n\twb = b->wds;\n\txb = b->x;\n\txbe = xb + wb;\n\txc = c->x;\n\tborrow = 0;\n#ifdef ULLong\n\tdo {\n\t\ty = (ULLong)*xa++ - *xb++ - borrow;\n\t\tborrow = y >> 32 & (ULong)1;\n\t\t*xc++ = y & FFFFFFFF;\n\t\t}\n\t\twhile(xb < xbe);\n\twhile(xa < xae) {\n\t\ty = *xa++ - borrow;\n\t\tborrow = y >> 32 & (ULong)1;\n\t\t*xc++ = y & FFFFFFFF;\n\t\t}\n#else\n#ifdef Pack_32\n\tdo {\n\t\ty = (*xa & 0xffff) - (*xb & 0xffff) - borrow;\n\t\tborrow = (y & 0x10000) >> 16;\n\t\tz = (*xa++ >> 16) - (*xb++ >> 16) - borrow;\n\t\tborrow = (z & 0x10000) >> 16;\n\t\tStoreinc(xc, z, y);\n\t\t}\n\t\twhile(xb < xbe);\n\twhile(xa < xae) {\n\t\ty = (*xa & 0xffff) - borrow;\n\t\tborrow = (y & 0x10000) >> 16;\n\t\tz = (*xa++ >> 16) - borrow;\n\t\tborrow = (z & 0x10000) >> 16;\n\t\tStoreinc(xc, z, y);\n\t\t}\n#else\n\tdo {\n\t\ty = *xa++ - *xb++ - borrow;\n\t\tborrow = (y & 0x10000) >> 16;\n\t\t*xc++ = y & 0xffff;\n\t\t}\n\t\twhile(xb < xbe);\n\twhile(xa < xae) {\n\t\ty = *xa++ - borrow;\n\t\tborrow = (y & 0x10000) >> 16;\n\t\t*xc++ = y & 0xffff;\n\t\t}\n#endif\n#endif\n\twhile(!*--xc)\n\t\twa--;\n\tc->wds = wa;\n\treturn c;\n\t}\n\n static double\nulp\n (struct dtoa_context* C, U *x)\n{\n\tLong L;\n\tU u;\n\n\tL = (word0(x) & Exp_mask) - (P-1)*Exp_msk1;\n#ifndef Avoid_Underflow\n#ifndef Sudden_Underflow\n\tif (L > 0) {\n#endif\n#endif\n#ifdef IBM\n\t\tL |= Exp_msk1 >> 4;\n#endif\n\t\tword0(&u) = L;\n\t\tword1(&u) = 0;\n#ifndef Avoid_Underflow\n#ifndef Sudden_Underflow\n\t\t}\n\telse {\n\t\tL = -L >> Exp_shift;\n\t\tif (L < Exp_shift) {\n\t\t\tword0(&u) = 0x80000 >> L;\n\t\t\tword1(&u) = 0;\n\t\t\t}\n\t\telse {\n\t\t\tword0(&u) = 0;\n\t\t\tL -= Exp_shift;\n\t\t\tword1(&u) = L >= 31 ? 1 : 1 << 31 - L;\n\t\t\t}\n\t\t}\n#endif\n#endif\n\treturn dval(&u);\n\t}\n\n static double\nb2d\n (struct dtoa_context* C, Bigint *a, int *e)\n{\n\tULong *xa, *xa0, w, y, z;\n\tint k;\n\tU d;\n#ifdef VAX\n\tULong d0, d1;\n#else\n#define d0 word0(&d)\n#define d1 word1(&d)\n#endif\n\n\txa0 = a->x;\n\txa = xa0 + a->wds;\n\ty = *--xa;\n#ifdef DEBUG\n\tif (!y) Bug(\"zero y in b2d\");\n#endif\n\tk = hi0bits(C, y);\n\t*e = 32 - k;\n#ifdef Pack_32\n\tif (k < Ebits) {\n\t\td0 = Exp_1 | y >> (Ebits - k);\n\t\tw = xa > xa0 ? *--xa : 0;\n\t\td1 = y << ((32-Ebits) + k) | w >> (Ebits - k);\n\t\tgoto ret_d;\n\t\t}\n\tz = xa > xa0 ? *--xa : 0;\n\tif (k -= Ebits) {\n\t\td0 = Exp_1 | y << k | z >> (32 - k);\n\t\ty = xa > xa0 ? *--xa : 0;\n\t\td1 = z << k | y >> (32 - k);\n\t\t}\n\telse {\n\t\td0 = Exp_1 | y;\n\t\td1 = z;\n\t\t}\n#else\n\tif (k < Ebits + 16) {\n\t\tz = xa > xa0 ? *--xa : 0;\n\t\td0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;\n\t\tw = xa > xa0 ? *--xa : 0;\n\t\ty = xa > xa0 ? *--xa : 0;\n\t\td1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;\n\t\tgoto ret_d;\n\t\t}\n\tz = xa > xa0 ? *--xa : 0;\n\tw = xa > xa0 ? *--xa : 0;\n\tk -= Ebits + 16;\n\td0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;\n\ty = xa > xa0 ? *--xa : 0;\n\td1 = w << k + 16 | y << k;\n#endif\n ret_d:\n#ifdef VAX\n\tword0(&d) = d0 >> 16 | d0 << 16;\n\tword1(&d) = d1 >> 16 | d1 << 16;\n#else\n#undef d0\n#undef d1\n#endif\n\treturn dval(&d);\n\t}\n\n static Bigint *\nd2b\n (struct dtoa_context* C, U *d, int *e, int *bits)\n{\n\tBigint *b;\n\tint de, k;\n\tULong *x, y, z;\n#ifndef Sudden_Underflow\n\tint i;\n#endif\n#ifdef VAX\n\tULong d0, d1;\n\td0 = word0(d) >> 16 | word0(d) << 16;\n\td1 = word1(d) >> 16 | word1(d) << 16;\n#else\n#define d0 word0(d)\n#define d1 word1(d)\n#endif\n\n#ifdef Pack_32\n\tb = Balloc(C, 1);\n#else\n\tb = Balloc(C, 2);\n#endif\n\tx = b->x;\n\n\tz = d0 & Frac_mask;\n\td0 &= 0x7fffffff;\t/* clear sign bit, which we ignore */\n#ifdef Sudden_Underflow\n\tde = (int)(d0 >> Exp_shift);\n#ifndef IBM\n\tz |= Exp_msk11;\n#endif\n#else\n\tif ((de = (int)(d0 >> Exp_shift)))\n\t\tz |= Exp_msk1;\n#endif\n#ifdef Pack_32\n\tif ((y = d1)) {\n\t\tif ((k = lo0bits(C, &y))) {\n\t\t\tx[0] = y | z << (32 - k);\n\t\t\tz >>= k;\n\t\t\t}\n\t\telse\n\t\t\tx[0] = y;\n#ifndef Sudden_Underflow\n\t\ti =\n#endif\n\t\t    b->wds = (x[1] = z) ? 2 : 1;\n\t\t}\n\telse {\n\t\tk = lo0bits(C, &z);\n\t\tx[0] = z;\n#ifndef Sudden_Underflow\n\t\ti =\n#endif\n\t\t    b->wds = 1;\n\t\tk += 32;\n\t\t}\n#else\n\tif (y = d1) {\n\t\tif (k = lo0bits(C, &y))\n\t\t\tif (k >= 16) {\n\t\t\t\tx[0] = y | z << 32 - k & 0xffff;\n\t\t\t\tx[1] = z >> k - 16 & 0xffff;\n\t\t\t\tx[2] = z >> k;\n\t\t\t\ti = 2;\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\tx[0] = y & 0xffff;\n\t\t\t\tx[1] = y >> 16 | z << 16 - k & 0xffff;\n\t\t\t\tx[2] = z >> k & 0xffff;\n\t\t\t\tx[3] = z >> k+16;\n\t\t\t\ti = 3;\n\t\t\t\t}\n\t\telse {\n\t\t\tx[0] = y & 0xffff;\n\t\t\tx[1] = y >> 16;\n\t\t\tx[2] = z & 0xffff;\n\t\t\tx[3] = z >> 16;\n\t\t\ti = 3;\n\t\t\t}\n\t\t}\n\telse {\n#ifdef DEBUG\n\t\tif (!z)\n\t\t\tBug(\"Zero passed to d2b\");\n#endif\n\t\tk = lo0bits(C, &z);\n\t\tif (k >= 16) {\n\t\t\tx[0] = z;\n\t\t\ti = 0;\n\t\t\t}\n\t\telse {\n\t\t\tx[0] = z & 0xffff;\n\t\t\tx[1] = z >> 16;\n\t\t\ti = 1;\n\t\t\t}\n\t\tk += 32;\n\t\t}\n\twhile(!x[i])\n\t\t--i;\n\tb->wds = i + 1;\n#endif\n#ifndef Sudden_Underflow\n\tif (de) {\n#endif\n#ifdef IBM\n\t\t*e = (de - Bias - (P-1) << 2) + k;\n\t\t*bits = 4*P + 8 - k - hi0bits(C, word0(d) & Frac_mask);\n#else\n\t\t*e = de - Bias - (P-1) + k;\n\t\t*bits = P - k;\n#endif\n#ifndef Sudden_Underflow\n\t\t}\n\telse {\n\t\t*e = de - Bias - (P-1) + 1 + k;\n#ifdef Pack_32\n\t\t*bits = 32*i - hi0bits(C, x[i-1]);\n#else\n\t\t*bits = (i+2)*16 - hi0bits(C, x[i]);\n#endif\n\t\t}\n#endif\n\treturn b;\n\t}\n#undef d0\n#undef d1\n\n static double\nratio\n (struct dtoa_context* C, Bigint *a, Bigint *b)\n{\n\tU da, db;\n\tint k, ka, kb;\n\n\tdval(&da) = b2d(C, a, &ka);\n\tdval(&db) = b2d(C, b, &kb);\n#ifdef Pack_32\n\tk = ka - kb + 32*(a->wds - b->wds);\n#else\n\tk = ka - kb + 16*(a->wds - b->wds);\n#endif\n#ifdef IBM\n\tif (k > 0) {\n\t\tword0(&da) += (k >> 2)*Exp_msk1;\n\t\tif (k &= 3)\n\t\t\tdval(&da) *= 1 << k;\n\t\t}\n\telse {\n\t\tk = -k;\n\t\tword0(&db) += (k >> 2)*Exp_msk1;\n\t\tif (k &= 3)\n\t\t\tdval(&db) *= 1 << k;\n\t\t}\n#else\n\tif (k > 0)\n\t\tword0(&da) += k*Exp_msk1;\n\telse {\n\t\tk = -k;\n\t\tword0(&db) += k*Exp_msk1;\n\t\t}\n#endif\n\treturn dval(&da) / dval(&db);\n\t}\n\n static CONST double\ntens[] = {\n\t\t1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,\n\t\t1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,\n\t\t1e20, 1e21, 1e22\n#ifdef VAX\n\t\t, 1e23, 1e24\n#endif\n\t\t};\n\n static CONST double\n#ifdef IEEE_Arith\nbigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 };\nstatic CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128,\n#ifdef Avoid_Underflow\n\t\t9007199254740992.*9007199254740992.e-256\n\t\t/* = 2^106 * 1e-256 */\n#else\n\t\t1e-256\n#endif\n\t\t};\n/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */\n/* flag unnecessarily.  It leads to a song and dance at the end of strtod. */\n#define Scale_Bit 0x10\n#define n_bigtens 5\n#else\n#ifdef IBM\nbigtens[] = { 1e16, 1e32, 1e64 };\nstatic CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 };\n#define n_bigtens 3\n#else\nbigtens[] = { 1e16, 1e32 };\nstatic CONST double tinytens[] = { 1e-16, 1e-32 };\n#define n_bigtens 2\n#endif\n#endif\n\n#undef Need_Hexdig\n#ifdef INFNAN_CHECK\n#ifndef No_Hex_NaN\n#define Need_Hexdig\n#endif\n#endif\n\n#ifndef Need_Hexdig\n#ifndef NO_HEX_FP\n#define Need_Hexdig\n#endif\n#endif\n\n#ifdef Need_Hexdig /*{*/\nstatic unsigned char hexdig[256];\n\n static void\nhtinit(unsigned char *h, unsigned char *s, int inc)\n{\n\tint i, j;\n\tfor(i = 0; (j = s[i]) !=0; i++)\n\t\th[j] = i + inc;\n\t}\n\n static void\nhexdig_init(void)\n{\n#define USC (unsigned char *)\n\thtinit(hexdig, USC \"0123456789\", 0x10);\n\thtinit(hexdig, USC \"abcdef\", 0x10 + 10);\n\thtinit(hexdig, USC \"ABCDEF\", 0x10 + 10);\n\t}\n#endif /* } Need_Hexdig */\n\n#ifdef INFNAN_CHECK\n\n#ifndef NAN_WORD0\n#define NAN_WORD0 0x7ff80000\n#endif\n\n#ifndef NAN_WORD1\n#define NAN_WORD1 0\n#endif\n\n static int\nmatch\n (struct dtoa_context* C, const char **sp, const char *t)\n{\n\tint c, d;\n\tCONST char *s = *sp;\n\n\twhile((d = *t++)) {\n\t\tif ((c = *++s) >= 'A' && c <= 'Z')\n\t\t\tc += 'a' - 'A';\n\t\tif (c != d)\n\t\t\treturn 0;\n\t\t}\n\t*sp = s + 1;\n\treturn 1;\n\t}\n\n#ifndef No_Hex_NaN\n static void\nhexnan\n (struct dtoa_context* C, U *rvp, const char **sp)\n{\n\tULong c, x[2];\n\tCONST char *s;\n\tint c1, havedig, udx0, xshift;\n\n\tif (!hexdig['0'])\n\t\thexdig_init();\n\tx[0] = x[1] = 0;\n\thavedig = xshift = 0;\n\tudx0 = 1;\n\ts = *sp;\n\t/* allow optional initial 0x or 0X */\n\twhile((c = *(CONST unsigned char*)(s+1)) && c <= ' ')\n\t\t++s;\n\tif (s[1] == '0' && (s[2] == 'x' || s[2] == 'X'))\n\t\ts += 2;\n\twhile((c = *(CONST unsigned char*)++s)) {\n\t\tif ((c1 = hexdig[c]))\n\t\t\tc  = c1 & 0xf;\n\t\telse if (c <= ' ') {\n\t\t\tif (udx0 && havedig) {\n\t\t\t\tudx0 = 0;\n\t\t\t\txshift = 1;\n\t\t\t\t}\n\t\t\tcontinue;\n\t\t\t}\n#ifdef GDTOA_NON_PEDANTIC_NANCHECK\n\t\telse if (/*(*/ c == ')' && havedig) {\n\t\t\t*sp = s + 1;\n\t\t\tbreak;\n\t\t\t}\n\t\telse\n\t\t\treturn;\t/* invalid form: don't change *sp */\n#else\n\t\telse {\n\t\t\tdo {\n\t\t\t\tif (/*(*/ c == ')') {\n\t\t\t\t\t*sp = s + 1;\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} while((c = *++s));\n\t\t\tbreak;\n\t\t\t}\n#endif\n\t\thavedig = 1;\n\t\tif (xshift) {\n\t\t\txshift = 0;\n\t\t\tx[0] = x[1];\n\t\t\tx[1] = 0;\n\t\t\t}\n\t\tif (udx0)\n\t\t\tx[0] = (x[0] << 4) | (x[1] >> 28);\n\t\tx[1] = (x[1] << 4) | c;\n\t\t}\n\tif ((x[0] &= 0xfffff) || x[1]) {\n\t\tword0(rvp) = Exp_mask | x[0];\n\t\tword1(rvp) = x[1];\n\t\t}\n\t}\n#endif /*No_Hex_NaN*/\n#endif /* INFNAN_CHECK */\n\n#ifdef Pack_32\n#define ULbits 32\n#define kshift 5\n#define kmask 31\n#else\n#define ULbits 16\n#define kshift 4\n#define kmask 15\n#endif\n\n#if !defined(NO_HEX_FP) || defined(Honor_FLT_ROUNDS) /*{*/\n static Bigint *\nincrement(struct dtoa_context* C, Bigint *b)\n{\n\tULong *x, *xe;\n\tBigint *b1;\n\n\tx = b->x;\n\txe = x + b->wds;\n\tdo {\n\t\tif (*x < (ULong)0xffffffffL) {\n\t\t\t++*x;\n\t\t\treturn b;\n\t\t\t}\n\t\t*x++ = 0;\n\t\t} while(x < xe);\n\t{\n\t\tif (b->wds >= b->maxwds) {\n\t\t\tb1 = Balloc(C, b->k+1);\n\t\t\tBcopy(b1,b);\n\t\t\tBfree(C, b);\n\t\t\tb = b1;\n\t\t\t}\n\t\tb->x[b->wds++] = 1;\n\t\t}\n\treturn b;\n\t}\n\n#endif /*}*/\n\n#ifndef NO_HEX_FP /*{*/\n\n static void\nrshift(struct dtoa_context* C, Bigint *b, int k)\n{\n\tULong *x, *x1, *xe, y;\n\tint n;\n\n\tx = x1 = b->x;\n\tn = k >> kshift;\n\tif (n < b->wds) {\n\t\txe = x + b->wds;\n\t\tx += n;\n\t\tif (k &= kmask) {\n\t\t\tn = 32 - k;\n\t\t\ty = *x++ >> k;\n\t\t\twhile(x < xe) {\n\t\t\t\t*x1++ = (y | (*x << n)) & 0xffffffff;\n\t\t\t\ty = *x++ >> k;\n\t\t\t\t}\n\t\t\tif ((*x1 = y) !=0)\n\t\t\t\tx1++;\n\t\t\t}\n\t\telse\n\t\t\twhile(x < xe)\n\t\t\t\t*x1++ = *x++;\n\t\t}\n\tif ((b->wds = x1 - b->x) == 0)\n\t\tb->x[0] = 0;\n\t}\n\n static ULong\nany_on(Bigint *b, int k)\n{\n\tint n, nwds;\n\tULong *x, *x0, x1, x2;\n\n\tx = b->x;\n\tnwds = b->wds;\n\tn = k >> kshift;\n\tif (n > nwds)\n\t\tn = nwds;\n\telse if (n < nwds && (k &= kmask)) {\n\t\tx1 = x2 = x[n];\n\t\tx1 >>= k;\n\t\tx1 <<= k;\n\t\tif (x1 != x2)\n\t\t\treturn 1;\n\t\t}\n\tx0 = x;\n\tx += n;\n\twhile(x > x0)\n\t\tif (*--x)\n\t\t\treturn 1;\n\treturn 0;\n\t}\n\nenum {\t/* rounding values: same as FLT_ROUNDS */\n\tRound_zero = 0,\n\tRound_near = 1,\n\tRound_up = 2,\n\tRound_down = 3\n\t};\n\nstatic void\ngethex(struct dtoa_context* C,  CONST char **sp, U *rvp, int rounding, int sign)\n{\n\tBigint *b;\n\tCONST unsigned char *decpt, *s0, *s, *s1;\n\tLong e, e1;\n\tULong L, lostbits, *x;\n\tint big, denorm, esign, havedig, k, n, nbits, up, zret;\n#ifdef IBM\n\tint j;\n#endif\n\tenum {\n#ifdef IEEE_Arith /*{{*/\n\t\temax = 0x7fe - Bias - P + 1,\n\t\temin = Emin - P + 1\n#else /*}{*/\n\t\temin = Emin - P,\n#ifdef VAX\n\t\temax = 0x7ff - Bias - P + 1\n#endif\n#ifdef IBM\n\t\temax = 0x7f - Bias - P\n#endif\n#endif /*}}*/\n\t\t};\n#ifdef USE_LOCALE\n\tint i;\n#ifdef NO_LOCALE_CACHE\n\tconst unsigned char *decimalpoint = (unsigned char*)\n\t\tlocaleconv()->decimal_point;\n#else\n\tconst unsigned char *decimalpoint;\n\tstatic unsigned char *decimalpoint_cache;\n\tif (!(s0 = decimalpoint_cache)) {\n\t\ts0 = (unsigned char*)localeconv()->decimal_point;\n\t\tif ((decimalpoint_cache = (unsigned char*)\n\t\t\t\tMALLOC(strlen((CONST char*)s0) + 1))) {\n\t\t\tstrcpy((char*)decimalpoint_cache, (CONST char*)s0);\n\t\t\ts0 = decimalpoint_cache;\n\t\t\t}\n\t\t}\n\tdecimalpoint = s0;\n#endif\n#endif\n\n\tif (!hexdig['0'])\n\t\thexdig_init();\n\thavedig = 0;\n\ts0 = *(CONST unsigned char **)sp + 2;\n\twhile(s0[havedig] == '0')\n\t\thavedig++;\n\ts0 += havedig;\n\ts = s0;\n\tdecpt = 0;\n\tzret = 0;\n\te = 0;\n\tif (hexdig[*s])\n\t\thavedig++;\n\telse {\n\t\tzret = 1;\n#ifdef USE_LOCALE\n\t\tfor(i = 0; decimalpoint[i]; ++i) {\n\t\t\tif (s[i] != decimalpoint[i])\n\t\t\t\tgoto pcheck;\n\t\t\t}\n\t\tdecpt = s += i;\n#else\n\t\tif (*s != '.')\n\t\t\tgoto pcheck;\n\t\tdecpt = ++s;\n#endif\n\t\tif (!hexdig[*s])\n\t\t\tgoto pcheck;\n\t\twhile(*s == '0')\n\t\t\ts++;\n\t\tif (hexdig[*s])\n\t\t\tzret = 0;\n\t\thavedig = 1;\n\t\ts0 = s;\n\t\t}\n\twhile(hexdig[*s])\n\t\ts++;\n#ifdef USE_LOCALE\n\tif (*s == *decimalpoint && !decpt) {\n\t\tfor(i = 1; decimalpoint[i]; ++i) {\n\t\t\tif (s[i] != decimalpoint[i])\n\t\t\t\tgoto pcheck;\n\t\t\t}\n\t\tdecpt = s += i;\n#else\n\tif (*s == '.' && !decpt) {\n\t\tdecpt = ++s;\n#endif\n\t\twhile(hexdig[*s])\n\t\t\ts++;\n\t\t}/*}*/\n\tif (decpt)\n\t\te = -(((Long)(s-decpt)) << 2);\n pcheck:\n\ts1 = s;\n\tbig = esign = 0;\n\tswitch(*s) {\n\t  case 'p':\n\t  case 'P':\n\t\tswitch(*++s) {\n\t\t  case '-':\n\t\t\tesign = 1;\n\t\t\t/* no break */\n\t\t\tJQ_FALLTHROUGH;\n\t\t  case '+':\n\t\t\ts++;\n\t\t  }\n\t\tif ((n = hexdig[*s]) == 0 || n > 0x19) {\n\t\t\ts = s1;\n\t\t\tbreak;\n\t\t\t}\n\t\te1 = n - 0x10;\n\t\twhile((n = hexdig[*++s]) !=0 && n <= 0x19) {\n\t\t\tif (e1 & 0xf8000000)\n\t\t\t\tbig = 1;\n\t\t\te1 = 10*e1 + n - 0x10;\n\t\t\t}\n\t\tif (esign)\n\t\t\te1 = -e1;\n\t\te += e1;\n\t  }\n\t*sp = (char*)s;\n\tif (!havedig)\n\t\t*sp = (char*)s0 - 1;\n\tif (zret)\n\t\tgoto retz1;\n\tif (big) {\n\t\tif (esign) {\n#ifdef IEEE_Arith\n\t\t\tswitch(rounding) {\n\t\t\t  case Round_up:\n\t\t\t\tif (sign)\n\t\t\t\t\tbreak;\n\t\t\t\tgoto ret_tiny;\n\t\t\t  case Round_down:\n\t\t\t\tif (!sign)\n\t\t\t\t\tbreak;\n\t\t\t\tgoto ret_tiny;\n\t\t\t  }\n#endif\n\t\t\tgoto retz;\n#ifdef IEEE_Arith\n ret_tiny:\n#ifndef NO_ERRNO\n\t\t\terrno = ERANGE;\n#endif\n\t\t\tword0(rvp) = 0;\n\t\t\tword1(rvp) = 1;\n\t\t\treturn;\n#endif /* IEEE_Arith */\n\t\t\t}\n\t\tswitch(rounding) {\n\t\t  case Round_near:\n\t\t\tgoto ovfl1;\n\t\t  case Round_up:\n\t\t\tif (!sign)\n\t\t\t\tgoto ovfl1;\n\t\t\tgoto ret_big;\n\t\t  case Round_down:\n\t\t\tif (sign)\n\t\t\t\tgoto ovfl1;\n\t\t\tgoto ret_big;\n\t\t  }\n ret_big:\n\t\tword0(rvp) = Big0;\n\t\tword1(rvp) = Big1;\n\t\treturn;\n\t\t}\n\tn = s1 - s0 - 1;\n\tfor(k = 0; n > (1 << (kshift-2)) - 1; n >>= 1)\n\t\tk++;\n\tb = Balloc(C, k);\n\tx = b->x;\n\tn = 0;\n\tL = 0;\n#ifdef USE_LOCALE\n\tfor(i = 0; decimalpoint[i+1]; ++i);\n#endif\n\twhile(s1 > s0) {\n#ifdef USE_LOCALE\n\t\tif (*--s1 == decimalpoint[i]) {\n\t\t\ts1 -= i;\n\t\t\tcontinue;\n\t\t\t}\n#else\n\t\tif (*--s1 == '.')\n\t\t\tcontinue;\n#endif\n\t\tif (n == ULbits) {\n\t\t\t*x++ = L;\n\t\t\tL = 0;\n\t\t\tn = 0;\n\t\t\t}\n\t\tL |= (hexdig[*s1] & 0x0f) << n;\n\t\tn += 4;\n\t\t}\n\t*x++ = L;\n\tb->wds = n = x - b->x;\n\tn = ULbits*n - hi0bits(C, L);\n\tnbits = Nbits;\n\tlostbits = 0;\n\tx = b->x;\n\tif (n > nbits) {\n\t\tn -= nbits;\n\t\tif (any_on(b,n)) {\n\t\t\tlostbits = 1;\n\t\t\tk = n - 1;\n\t\t\tif (x[k>>kshift] & 1 << (k & kmask)) {\n\t\t\t\tlostbits = 2;\n\t\t\t\tif (k > 0 && any_on(b,k))\n\t\t\t\t\tlostbits = 3;\n\t\t\t\t}\n\t\t\t}\n\t\trshift(C, b, n);\n\t\te += n;\n\t\t}\n\telse if (n < nbits) {\n\t\tn = nbits - n;\n\t\tb = lshift(C, b, n);\n\t\te -= n;\n\t\tx = b->x;\n\t\t}\n\tif (e > Emax) {\n ovfl:\n\t\tBfree(C, b);\n ovfl1:\n#ifndef NO_ERRNO\n\t\terrno = ERANGE;\n#endif\n\t\tword0(rvp) = Exp_mask;\n\t\tword1(rvp) = 0;\n\t\treturn;\n\t\t}\n\tdenorm = 0;\n\tif (e < emin) {\n\t\tdenorm = 1;\n\t\tn = emin - e;\n\t\tif (n >= nbits) {\n#ifdef IEEE_Arith /*{*/\n\t\t\tswitch (rounding) {\n\t\t\t  case Round_near:\n\t\t\t\tif (n == nbits && (n < 2 || any_on(b,n-1)))\n\t\t\t\t\tgoto ret_tiny;\n\t\t\t\tbreak;\n\t\t\t  case Round_up:\n\t\t\t\tif (!sign)\n\t\t\t\t\tgoto ret_tiny;\n\t\t\t\tbreak;\n\t\t\t  case Round_down:\n\t\t\t\tif (sign)\n\t\t\t\t\tgoto ret_tiny;\n\t\t\t  }\n#endif /* } IEEE_Arith */\n\t\t\tBfree(C, b);\n retz:\n#ifndef NO_ERRNO\n\t\t\terrno = ERANGE;\n#endif\n retz1:\n\t\t\trvp->d = 0.;\n\t\t\treturn;\n\t\t\t}\n\t\tk = n - 1;\n\t\tif (lostbits)\n\t\t\tlostbits = 1;\n\t\telse if (k > 0)\n\t\t\tlostbits = any_on(b,k);\n\t\tif (x[k>>kshift] & 1 << (k & kmask))\n\t\t\tlostbits |= 2;\n\t\tnbits -= n;\n\t\trshift(C, b,n);\n\t\te = emin;\n\t\t}\n\tif (lostbits) {\n\t\tup = 0;\n\t\tswitch(rounding) {\n\t\t  case Round_zero:\n\t\t\tbreak;\n\t\t  case Round_near:\n\t\t\tif (lostbits & 2\n\t\t\t && (lostbits & 1) | (x[0] & 1))\n\t\t\t\tup = 1;\n\t\t\tbreak;\n\t\t  case Round_up:\n\t\t\tup = 1 - sign;\n\t\t\tbreak;\n\t\t  case Round_down:\n\t\t\tup = sign;\n\t\t  }\n\t\tif (up) {\n\t\t\tk = b->wds;\n\t\t\tb = increment(C, b);\n\t\t\tx = b->x;\n\t\t\tif (denorm) {\n#if 0\n\t\t\t\tif (nbits == Nbits - 1\n\t\t\t\t && x[nbits >> kshift] & 1 << (nbits & kmask))\n\t\t\t\t\tdenorm = 0; /* not currently used */\n#endif\n\t\t\t\t}\n\t\t\telse if (b->wds > k\n\t\t\t || ((n = nbits & kmask) !=0\n\t\t\t     && hi0bits(C, x[k-1]) < 32-n)) {\n\t\t\t\trshift(C, b,1);\n\t\t\t\tif (++e > Emax)\n\t\t\t\t\tgoto ovfl;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n#ifdef IEEE_Arith\n\tif (denorm)\n\t\tword0(rvp) = b->wds > 1 ? b->x[1] & ~0x100000 : 0;\n\telse\n\t\tword0(rvp) = (b->x[1] & ~0x100000) | ((e + 0x3ff + 52) << 20);\n\tword1(rvp) = b->x[0];\n#endif\n#ifdef IBM\n\tif ((j = e & 3)) {\n\t\tk = b->x[0] & ((1 << j) - 1);\n\t\trshift(C, b,j);\n\t\tif (k) {\n\t\t\tswitch(rounding) {\n\t\t\t  case Round_up:\n\t\t\t\tif (!sign)\n\t\t\t\t\tincrement(b);\n\t\t\t\tbreak;\n\t\t\t  case Round_down:\n\t\t\t\tif (sign)\n\t\t\t\t\tincrement(b);\n\t\t\t\tbreak;\n\t\t\t  case Round_near:\n\t\t\t\tj = 1 << (j-1);\n\t\t\t\tif (k & j && ((k & (j-1)) | lostbits))\n\t\t\t\t\tincrement(b);\n\t\t\t  }\n\t\t\t}\n\t\t}\n\te >>= 2;\n\tword0(rvp) = b->x[1] | ((e + 65 + 13) << 24);\n\tword1(rvp) = b->x[0];\n#endif\n#ifdef VAX\n\t/* The next two lines ignore swap of low- and high-order 2 bytes. */\n\t/* word0(rvp) = (b->x[1] & ~0x800000) | ((e + 129 + 55) << 23); */\n\t/* word1(rvp) = b->x[0]; */\n\tword0(rvp) = ((b->x[1] & ~0x800000) >> 16) | ((e + 129 + 55) << 7) | (b->x[1] << 16);\n\tword1(rvp) = (b->x[0] >> 16) | (b->x[0] << 16);\n#endif\n\tBfree(C, b);\n\t}\n#endif /*!NO_HEX_FP}*/\n\n static int\ndshift(struct dtoa_context* C, Bigint *b, int p2)\n{\n\tint rv = hi0bits(C, b->x[b->wds-1]) - 4;\n\tif (p2 > 0)\n\t\trv -= p2;\n\treturn rv & kmask;\n\t}\n\n static int\nquorem\n (struct dtoa_context* C, Bigint *b, Bigint *S)\n{\n\tint n;\n\tULong *bx, *bxe, q, *sx, *sxe;\n#ifdef ULLong\n\tULLong borrow, carry, y, ys;\n#else\n\tULong borrow, carry, y, ys;\n#ifdef Pack_32\n\tULong si, z, zs;\n#endif\n#endif\n\n\tn = S->wds;\n#ifdef DEBUG\n\t/*debug*/ if (b->wds > n)\n\t/*debug*/\tBug(\"oversize b in quorem\");\n#endif\n\tif (b->wds < n)\n\t\treturn 0;\n\tsx = S->x;\n\tsxe = sx + --n;\n\tbx = b->x;\n\tbxe = bx + n;\n\tq = *bxe / (*sxe + 1);\t/* ensure q <= true quotient */\n#ifdef DEBUG\n#ifdef NO_STRTOD_BIGCOMP\n\t/*debug*/ if (q > 9)\n#else\n\t/* An oversized q is possible when quorem is called from bigcomp and */\n\t/* the input is near, e.g., twice the smallest denormalized number. */\n\t/*debug*/ if (q > 15)\n#endif\n\t/*debug*/\tBug(\"oversized quotient in quorem\");\n#endif\n\tif (q) {\n\t\tborrow = 0;\n\t\tcarry = 0;\n\t\tdo {\n#ifdef ULLong\n\t\t\tys = *sx++ * (ULLong)q + carry;\n\t\t\tcarry = ys >> 32;\n\t\t\ty = *bx - (ys & FFFFFFFF) - borrow;\n\t\t\tborrow = y >> 32 & (ULong)1;\n\t\t\t*bx++ = y & FFFFFFFF;\n#else\n#ifdef Pack_32\n\t\t\tsi = *sx++;\n\t\t\tys = (si & 0xffff) * q + carry;\n\t\t\tzs = (si >> 16) * q + (ys >> 16);\n\t\t\tcarry = zs >> 16;\n\t\t\ty = (*bx & 0xffff) - (ys & 0xffff) - borrow;\n\t\t\tborrow = (y & 0x10000) >> 16;\n\t\t\tz = (*bx >> 16) - (zs & 0xffff) - borrow;\n\t\t\tborrow = (z & 0x10000) >> 16;\n\t\t\tStoreinc(bx, z, y);\n#else\n\t\t\tys = *sx++ * q + carry;\n\t\t\tcarry = ys >> 16;\n\t\t\ty = *bx - (ys & 0xffff) - borrow;\n\t\t\tborrow = (y & 0x10000) >> 16;\n\t\t\t*bx++ = y & 0xffff;\n#endif\n#endif\n\t\t\t}\n\t\t\twhile(sx <= sxe);\n\t\tif (!*bxe) {\n\t\t\tbx = b->x;\n\t\t\twhile(--bxe > bx && !*bxe)\n\t\t\t\t--n;\n\t\t\tb->wds = n;\n\t\t\t}\n\t\t}\n\tif (cmp(C, b, S) >= 0) {\n\t\tq++;\n\t\tborrow = 0;\n\t\tcarry = 0;\n\t\tbx = b->x;\n\t\tsx = S->x;\n\t\tdo {\n#ifdef ULLong\n\t\t\tys = *sx++ + carry;\n\t\t\tcarry = ys >> 32;\n\t\t\ty = *bx - (ys & FFFFFFFF) - borrow;\n\t\t\tborrow = y >> 32 & (ULong)1;\n\t\t\t*bx++ = y & FFFFFFFF;\n#else\n#ifdef Pack_32\n\t\t\tsi = *sx++;\n\t\t\tys = (si & 0xffff) + carry;\n\t\t\tzs = (si >> 16) + (ys >> 16);\n\t\t\tcarry = zs >> 16;\n\t\t\ty = (*bx & 0xffff) - (ys & 0xffff) - borrow;\n\t\t\tborrow = (y & 0x10000) >> 16;\n\t\t\tz = (*bx >> 16) - (zs & 0xffff) - borrow;\n\t\t\tborrow = (z & 0x10000) >> 16;\n\t\t\tStoreinc(bx, z, y);\n#else\n\t\t\tys = *sx++ + carry;\n\t\t\tcarry = ys >> 16;\n\t\t\ty = *bx - (ys & 0xffff) - borrow;\n\t\t\tborrow = (y & 0x10000) >> 16;\n\t\t\t*bx++ = y & 0xffff;\n#endif\n#endif\n\t\t\t}\n\t\t\twhile(sx <= sxe);\n\t\tbx = b->x;\n\t\tbxe = bx + n;\n\t\tif (!*bxe) {\n\t\t\twhile(--bxe > bx && !*bxe)\n\t\t\t\t--n;\n\t\t\tb->wds = n;\n\t\t\t}\n\t\t}\n\treturn q;\n\t}\n\n#if defined(Avoid_Underflow) || !defined(NO_STRTOD_BIGCOMP) /*{*/\n static double\nsulp\n (struct dtoa_context* C, U *x, BCinfo *bc)\n{\n\tU u;\n\tdouble rv;\n\tint i;\n\n\trv = ulp(C, x);\n\tif (!bc->scale || (i = 2*P + 1 - ((word0(x) & Exp_mask) >> Exp_shift)) <= 0)\n\t\treturn rv; /* Is there an example where i <= 0 ? */\n\tword0(&u) = Exp_1 + (i << Exp_shift);\n\tword1(&u) = 0;\n\treturn rv * u.d;\n\t}\n#endif /*}*/\n\n#ifndef NO_STRTOD_BIGCOMP\n static void\nbigcomp\n (struct dtoa_context* C, U *rv, const char *s0, BCinfo *bc)\n{\n\tBigint *b, *d;\n\tint b2, bbits, d2, dd=0, dig, dsign, i, j, nd, nd0, p2, p5, speccase;\n\n\tdsign = bc->dsign;\n\tnd = bc->nd;\n\tnd0 = bc->nd0;\n\tp5 = nd + bc->e0 - 1;\n\tspeccase = 0;\n#ifndef Sudden_Underflow\n\tif (rv->d == 0.) {\t/* special case: value near underflow-to-zero */\n\t\t\t\t/* threshold was rounded to zero */\n\t\tb = i2b(C, 1);\n\t\tp2 = Emin - P + 1;\n\t\tbbits = 1;\n#ifdef Avoid_Underflow\n\t\tword0(rv) = (P+2) << Exp_shift;\n#else\n\t\tword1(rv) = 1;\n#endif\n\t\ti = 0;\n#ifdef Honor_FLT_ROUNDS\n\t\tif (bc->rounding == 1)\n#endif\n\t\t\t{\n\t\t\tspeccase = 1;\n\t\t\t--p2;\n\t\t\tdsign = 0;\n\t\t\tgoto have_i;\n\t\t\t}\n\t\t}\n\telse\n#endif\n\t\tb = d2b(C, rv, &p2, &bbits);\n#ifdef Avoid_Underflow\n\tp2 -= bc->scale;\n#endif\n\t/* floor(log2(rv)) == bbits - 1 + p2 */\n\t/* Check for denormal case. */\n\ti = P - bbits;\n\tif (i > (j = P - Emin - 1 + p2)) {\n#ifdef Sudden_Underflow\n\t\tBfree(C, b);\n\t\tb = i2b(C, 1);\n\t\tp2 = Emin;\n\t\ti = P - 1;\n#ifdef Avoid_Underflow\n\t\tword0(rv) = (1 + bc->scale) << Exp_shift;\n#else\n\t\tword0(rv) = Exp_msk1;\n#endif\n\t\tword1(rv) = 0;\n#else\n\t\ti = j;\n#endif\n\t\t}\n#ifdef Honor_FLT_ROUNDS\n\tif (bc->rounding != 1) {\n\t\tif (i > 0)\n\t\t\tb = lshift(C, b, i);\n\t\tif (dsign)\n\t\t\tb = increment(b);\n\t\t}\n\telse\n#endif\n\t\t{\n\t\tb = lshift(C, b, ++i);\n\t\tb->x[0] |= 1;\n\t\t}\n#ifndef Sudden_Underflow\n have_i:\n#endif\n\tp2 -= p5 + i;\n\td = i2b(C, 1);\n\t/* Arrange for convenient computation of quotients:\n\t * shift left if necessary so divisor has 4 leading 0 bits.\n\t */\n\tif (p5 > 0)\n\t\td = pow5mult(C, d, p5);\n\telse if (p5 < 0)\n\t\tb = pow5mult(C, b, -p5);\n\tif (p2 > 0) {\n\t\tb2 = p2;\n\t\td2 = 0;\n\t\t}\n\telse {\n\t\tb2 = 0;\n\t\td2 = -p2;\n\t\t}\n\ti = dshift(C, d, d2);\n\tif ((b2 += i) > 0)\n\t\tb = lshift(C, b, b2);\n\tif ((d2 += i) > 0)\n\t\td = lshift(C, d, d2);\n\n\t/* Now b/d = exactly half-way between the two floating-point values */\n\t/* on either side of the input string.  Compute first digit of b/d. */\n\n\tif (!(dig = quorem(C, b,d))) {\n\t\tb = multadd(C, b, 10, 0);\t/* very unlikely */\n\t\tdig = quorem(C, b,d);\n\t\t}\n\n\t/* Compare b/d with s0 */\n\n\tfor(i = 0; i < nd0; ) {\n\t\tif ((dd = s0[i++] - '0' - dig))\n\t\t\tgoto ret;\n\t\tif (!b->x[0] && b->wds == 1) {\n\t\t\tif (i < nd)\n\t\t\t\tdd = 1;\n\t\t\tgoto ret;\n\t\t\t}\n\t\tb = multadd(C, b, 10, 0);\n\t\tdig = quorem(C, b,d);\n\t\t}\n\tfor(j = bc->dp1; i++ < nd;) {\n\t\tif ((dd = s0[j++] - '0' - dig))\n\t\t\tgoto ret;\n\t\tif (!b->x[0] && b->wds == 1) {\n\t\t\tif (i < nd)\n\t\t\t\tdd = 1;\n\t\t\tgoto ret;\n\t\t\t}\n\t\tb = multadd(C, b, 10, 0);\n\t\tdig = quorem(C, b,d);\n\t\t}\n\tif (dig > 0 || b->x[0] || b->wds > 1)\n\t\tdd = -1;\n ret:\n\tBfree(C, b);\n\tBfree(C, d);\n#ifdef Honor_FLT_ROUNDS\n\tif (bc->rounding != 1) {\n\t\tif (dd < 0) {\n\t\t\tif (bc->rounding == 0) {\n\t\t\t\tif (!dsign)\n\t\t\t\t\tgoto retlow1;\n\t\t\t\t}\n\t\t\telse if (dsign)\n\t\t\t\tgoto rethi1;\n\t\t\t}\n\t\telse if (dd > 0) {\n\t\t\tif (bc->rounding == 0) {\n\t\t\t\tif (dsign)\n\t\t\t\t\tgoto rethi1;\n\t\t\t\tgoto ret1;\n\t\t\t\t}\n\t\t\tif (!dsign)\n\t\t\t\tgoto rethi1;\n\t\t\tdval(rv) += 2.*sulp(C, rv,bc);\n\t\t\t}\n\t\telse {\n\t\t\tbc->inexact = 0;\n\t\t\tif (dsign)\n\t\t\t\tgoto rethi1;\n\t\t\t}\n\t\t}\n\telse\n#endif\n\tif (speccase) {\n\t\tif (dd <= 0)\n\t\t\trv->d = 0.;\n\t\t}\n\telse if (dd < 0) {\n\t\tif (!dsign)\t/* does not happen for round-near */\nretlow1:\n\t\t\tdval(rv) -= sulp(C, rv,bc);\n\t\t}\n\telse if (dd > 0) {\n\t\tif (dsign) {\n rethi1:\n\t\t\tdval(rv) += sulp(C, rv,bc);\n\t\t\t}\n\t\t}\n\telse {\n\t\t/* Exact half-way case:  apply round-even rule. */\n\t\tif ((j = ((word0(rv) & Exp_mask) >> Exp_shift) - bc->scale) <= 0) {\n\t\t\ti = 1 - j;\n\t\t\tif (i <= 31) {\n\t\t\t\tif (word1(rv) & (0x1 << i))\n\t\t\t\t\tgoto odd;\n\t\t\t\t}\n\t\t\telse if (word0(rv) & (0x1 << (i-32)))\n\t\t\t\tgoto odd;\n\t\t\t}\n\t\telse if (word1(rv) & 1) {\n odd:\n\t\t\tif (dsign)\n\t\t\t\tgoto rethi1;\n\t\t\tgoto retlow1;\n\t\t\t}\n\t\t}\n\n#ifdef Honor_FLT_ROUNDS\n ret1:\n#endif\n\treturn;\n\t}\n#endif /* NO_STRTOD_BIGCOMP */\n\n double\njvp_strtod\n (struct dtoa_context* C, const char *s00, char **se)\n{\n\tint bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1;\n#ifdef Honor_FLT_ROUNDS\n\tint test_scale;\n#endif\n\tint esign, i, j, k, nd, nd0, nf, nz, nz0, nz1, sign;\n\tCONST char *s, *s0, *s1;\n\tdouble aadj, aadj1;\n\tLong L;\n\tU aadj2, adj, rv, rv0;\n\tULong y, z;\n\tBCinfo bc;\n\tBigint *bb=0, *bb1, *bd=0, *bd0, *bs=0, *delta=0;\n#ifdef Avoid_Underflow\n\tULong Lsb, Lsb1;\n#endif\n#ifdef SET_INEXACT\n\tint oldinexact;\n#endif\n#ifndef NO_STRTOD_BIGCOMP\n\tint req_bigcomp = 0;\n#endif\n#ifdef Honor_FLT_ROUNDS /*{*/\n#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */\n\tbc.rounding = Flt_Rounds;\n#else /*}{*/\n\tbc.rounding = 1;\n\tswitch(fegetround()) {\n\t  case FE_TOWARDZERO:\tbc.rounding = 0; break;\n\t  case FE_UPWARD:\tbc.rounding = 2; break;\n\t  case FE_DOWNWARD:\tbc.rounding = 3;\n\t  }\n#endif /*}}*/\n#endif /*}*/\n#ifdef USE_LOCALE\n\tCONST char *s2;\n#endif\n\n\tsign = nz0 = nz1 = nz = bc.dplen = bc.uflchk = 0;\n\tdval(&rv) = 0.;\n\tswitch(*(s = s00)) {\n\t\tcase '-':\n\t\t\tsign = 1;\n\t\t\t/* no break */\n\t\t\tJQ_FALLTHROUGH;\n\t\tcase '+':\n\t\t\tif (*++s)\n\t\t\t\tbreak;\n\t\t\t/* no break */\n\t\t\tJQ_FALLTHROUGH;\n\t\tcase 0:\n\t\t\tgoto ret0;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\tif (*s == '0') {\n#ifndef NO_HEX_FP /*{*/\n\t\tswitch(s[1]) {\n\t\t  case 'x':\n\t\t  case 'X':\n#ifdef Honor_FLT_ROUNDS\n\t\t\tgethex(C, &s, &rv, bc.rounding, sign);\n#else\n\t\t\tgethex(C, &s, &rv, 1, sign);\n#endif\n\t\t\tgoto ret;\n\t\t  }\n#endif /*}*/\n\t\tnz0 = 1;\n\t\twhile(*++s == '0') ;\n\t\tif (!*s)\n\t\t\tgoto ret;\n\t\t}\n\ts0 = s;\n\ty = z = 0;\n\tfor(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)\n\t\tif (nd < 9)\n\t\t\ty = 10*y + c - '0';\n\t\telse if (nd < 16)\n\t\t\tz = 10*z + c - '0';\n\tnd0 = nd;\n\tbc.dp0 = bc.dp1 = s - s0;\n\tfor(s1 = s; s1 > s0 && *--s1 == '0'; )\n\t\t++nz1;\n#ifdef USE_LOCALE\n\ts1 = localeconv()->decimal_point;\n\tif (c == *s1) {\n\t\tc = '.';\n\t\tif (*++s1) {\n\t\t\ts2 = s;\n\t\t\tfor(;;) {\n\t\t\t\tif (*++s2 != *s1) {\n\t\t\t\t\tc = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\tif (!*++s1) {\n\t\t\t\t\ts = s2;\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n#endif\n\tif (c == '.') {\n\t\tc = *++s;\n\t\tbc.dp1 = s - s0;\n\t\tbc.dplen = bc.dp1 - bc.dp0;\n\t\tif (!nd) {\n\t\t\tfor(; c == '0'; c = *++s)\n\t\t\t\tnz++;\n\t\t\tif (c > '0' && c <= '9') {\n\t\t\t\tbc.dp0 = s0 - s;\n\t\t\t\tbc.dp1 = bc.dp0 + bc.dplen;\n\t\t\t\ts0 = s;\n\t\t\t\tnf += nz;\n\t\t\t\tnz = 0;\n\t\t\t\tgoto have_dig;\n\t\t\t\t}\n\t\t\tgoto dig_done;\n\t\t\t}\n\t\tfor(; c >= '0' && c <= '9'; c = *++s) {\n have_dig:\n\t\t\tnz++;\n\t\t\tif (c -= '0') {\n\t\t\t\tnf += nz;\n\t\t\t\tfor(i = 1; i < nz; i++)\n\t\t\t\t\tif (nd++ < 9)\n\t\t\t\t\t\ty *= 10;\n\t\t\t\t\telse if (nd <= DBL_DIG + 1)\n\t\t\t\t\t\tz *= 10;\n\t\t\t\tif (nd++ < 9)\n\t\t\t\t\ty = 10*y + c;\n\t\t\t\telse if (nd <= DBL_DIG + 1)\n\t\t\t\t\tz = 10*z + c;\n\t\t\t\tnz = nz1 = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n dig_done:\n\te = 0;\n\tif (c == 'e' || c == 'E') {\n\t\tif (!nd && !nz && !nz0) {\n\t\t\tgoto ret0;\n\t\t\t}\n\t\ts00 = s;\n\t\tesign = 0;\n\t\tswitch(c = *++s) {\n\t\t\tcase '-':\n\t\t\t\tesign = 1;\n\t\t\t\tJQ_FALLTHROUGH;\n\t\t\tcase '+':\n\t\t\t\tc = *++s;\n\t\t\t}\n\t\tif (c >= '0' && c <= '9') {\n\t\t\twhile(c == '0')\n\t\t\t\tc = *++s;\n\t\t\tif (c > '0' && c <= '9') {\n\t\t\t\tL = c - '0';\n\t\t\t\ts1 = s;\n\t\t\t\twhile((c = *++s) >= '0' && c <= '9')\n\t\t\t\t\tL = 10*L + c - '0';\n\t\t\t\tif (s - s1 > 8 || L > 19999)\n\t\t\t\t\t/* Avoid confusion from exponents\n\t\t\t\t\t * so large that e might overflow.\n\t\t\t\t\t */\n\t\t\t\t\te = 19999; /* safe for 16 bit ints */\n\t\t\t\telse\n\t\t\t\t\te = (int)L;\n\t\t\t\tif (esign)\n\t\t\t\t\te = -e;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\te = 0;\n\t\t\t}\n\t\telse\n\t\t\ts = s00;\n\t\t}\n\tif (!nd) {\n\t\tif (!nz && !nz0) {\n#ifdef INFNAN_CHECK\n\t\t\t/* Check for Nan and Infinity */\n\t\t\tif (!bc.dplen)\n\t\t\t switch(c) {\n\t\t\t  case 'i':\n\t\t\t  case 'I':\n\t\t\t\tif (match(C, &s,\"nf\")) {\n\t\t\t\t\t--s;\n\t\t\t\t\tif (!match(C, &s,\"inity\"))\n\t\t\t\t\t\t++s;\n\t\t\t\t\tword0(&rv) = 0x7ff00000;\n\t\t\t\t\tword1(&rv) = 0;\n\t\t\t\t\tgoto ret;\n\t\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t  case 'n':\n\t\t\t  case 'N':\n\t\t\t\tif (match(C, &s, \"an\")) {\n\t\t\t\t\tword0(&rv) = NAN_WORD0;\n\t\t\t\t\tword1(&rv) = NAN_WORD1;\n#ifndef No_Hex_NaN\n\t\t\t\t\tif (*s == '(') /*)*/\n\t\t\t\t\t\thexnan(C, &rv, &s);\n#endif\n\t\t\t\t\tgoto ret;\n\t\t\t\t\t}\n\t\t\t  }\n#endif /* INFNAN_CHECK */\n ret0:\n\t\t\ts = s00;\n\t\t\tsign = 0;\n\t\t\t}\n\t\tgoto ret;\n\t\t}\n\tbc.e0 = e1 = e -= nf;\n\n\t/* Now we have nd0 digits, starting at s0, followed by a\n\t * decimal point, followed by nd-nd0 digits.  The number we're\n\t * after is the integer represented by those digits times\n\t * 10**e */\n\n\tif (!nd0)\n\t\tnd0 = nd;\n\tk = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;\n\tdval(&rv) = y;\n\tif (k > 9) {\n#ifdef SET_INEXACT\n\t\tif (k > DBL_DIG)\n\t\t\toldinexact = get_inexact();\n#endif\n\t\tdval(&rv) = tens[k - 9] * dval(&rv) + z;\n\t\t}\n\tbd0 = 0;\n\tif (nd <= DBL_DIG\n#ifndef RND_PRODQUOT\n#ifndef Honor_FLT_ROUNDS\n\t\t&& Flt_Rounds == 1\n#endif\n#endif\n\t\t\t) {\n\t\tif (!e)\n\t\t\tgoto ret;\n#ifndef ROUND_BIASED_without_Round_Up\n\t\tif (e > 0) {\n\t\t\tif (e <= Ten_pmax) {\n#ifdef VAX\n\t\t\t\tgoto vax_ovfl_check;\n#else\n#ifdef Honor_FLT_ROUNDS\n\t\t\t\t/* round correctly FLT_ROUNDS = 2 or 3 */\n\t\t\t\tif (sign) {\n\t\t\t\t\trv.d = -rv.d;\n\t\t\t\t\tsign = 0;\n\t\t\t\t\t}\n#endif\n\t\t\t\t/* rv = */ rounded_product(dval(&rv), tens[e]);\n\t\t\t\tgoto ret;\n#endif\n\t\t\t\t}\n\t\t\ti = DBL_DIG - nd;\n\t\t\tif (e <= Ten_pmax + i) {\n\t\t\t\t/* A fancier test would sometimes let us do\n\t\t\t\t * this for larger i values.\n\t\t\t\t */\n#ifdef Honor_FLT_ROUNDS\n\t\t\t\t/* round correctly FLT_ROUNDS = 2 or 3 */\n\t\t\t\tif (sign) {\n\t\t\t\t\trv.d = -rv.d;\n\t\t\t\t\tsign = 0;\n\t\t\t\t\t}\n#endif\n\t\t\t\te -= i;\n\t\t\t\tdval(&rv) *= tens[i];\n#ifdef VAX\n\t\t\t\t/* VAX exponent range is so narrow we must\n\t\t\t\t * worry about overflow here...\n\t\t\t\t */\n vax_ovfl_check:\n\t\t\t\tword0(&rv) -= P*Exp_msk1;\n\t\t\t\t/* rv = */ rounded_product(dval(&rv), tens[e]);\n\t\t\t\tif ((word0(&rv) & Exp_mask)\n\t\t\t\t > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))\n\t\t\t\t\tgoto ovfl;\n\t\t\t\tword0(&rv) += P*Exp_msk1;\n#else\n\t\t\t\t/* rv = */ rounded_product(dval(&rv), tens[e]);\n#endif\n\t\t\t\tgoto ret;\n\t\t\t\t}\n\t\t\t}\n#ifndef Inaccurate_Divide\n\t\telse if (e >= -Ten_pmax) {\n#ifdef Honor_FLT_ROUNDS\n\t\t\t/* round correctly FLT_ROUNDS = 2 or 3 */\n\t\t\tif (sign) {\n\t\t\t\trv.d = -rv.d;\n\t\t\t\tsign = 0;\n\t\t\t\t}\n#endif\n\t\t\t/* rv = */ rounded_quotient(dval(&rv), tens[-e]);\n\t\t\tgoto ret;\n\t\t\t}\n#endif\n#endif /* ROUND_BIASED_without_Round_Up */\n\t\t}\n\te1 += nd - k;\n\n#ifdef IEEE_Arith\n#ifdef SET_INEXACT\n\tbc.inexact = 1;\n\tif (k <= DBL_DIG)\n\t\toldinexact = get_inexact();\n#endif\n#ifdef Avoid_Underflow\n\tbc.scale = 0;\n#endif\n#ifdef Honor_FLT_ROUNDS\n\tif (bc.rounding >= 2) {\n\t\tif (sign)\n\t\t\tbc.rounding = bc.rounding == 2 ? 0 : 2;\n\t\telse\n\t\t\tif (bc.rounding != 2)\n\t\t\t\tbc.rounding = 0;\n\t\t}\n#endif\n#endif /*IEEE_Arith*/\n\n\t/* Get starting approximation = rv * 10**e1 */\n\n\tif (e1 > 0) {\n\t\tif ((i = e1 & 15))\n\t\t\tdval(&rv) *= tens[i];\n\t\tif (e1 &= ~15) {\n\t\t\tif (e1 > DBL_MAX_10_EXP) {\n ovfl:\n\t\t\t\t/* Can't trust HUGE_VAL */\n#ifdef IEEE_Arith\n#ifdef Honor_FLT_ROUNDS\n\t\t\t\tswitch(bc.rounding) {\n\t\t\t\t  case 0: /* toward 0 */\n\t\t\t\t  case 3: /* toward -infinity */\n\t\t\t\t\tword0(&rv) = Big0;\n\t\t\t\t\tword1(&rv) = Big1;\n\t\t\t\t\tbreak;\n\t\t\t\t  default:\n\t\t\t\t\tword0(&rv) = Exp_mask;\n\t\t\t\t\tword1(&rv) = 0;\n\t\t\t\t  }\n#else /*Honor_FLT_ROUNDS*/\n\t\t\t\tword0(&rv) = Exp_mask;\n\t\t\t\tword1(&rv) = 0;\n#endif /*Honor_FLT_ROUNDS*/\n#ifdef SET_INEXACT\n\t\t\t\t/* set overflow bit */\n\t\t\t\tdval(&rv0) = 1e300;\n\t\t\t\tdval(&rv0) *= dval(&rv0);\n#endif\n#else /*IEEE_Arith*/\n\t\t\t\tword0(&rv) = Big0;\n\t\t\t\tword1(&rv) = Big1;\n#endif /*IEEE_Arith*/\n range_err:\n\t\t\t\tif (bd0) {\n\t\t\t\t\tBfree(C, bb);\n\t\t\t\t\tBfree(C, bd);\n\t\t\t\t\tBfree(C, bs);\n\t\t\t\t\tBfree(C, bd0);\n\t\t\t\t\tBfree(C, delta);\n\t\t\t\t\t}\n#ifndef NO_ERRNO\n\t\t\t\terrno = ERANGE;\n#endif\n\t\t\t\tgoto ret;\n\t\t\t\t}\n\t\t\te1 >>= 4;\n\t\t\tfor(j = 0; e1 > 1; j++, e1 >>= 1)\n\t\t\t\tif (e1 & 1)\n\t\t\t\t\tdval(&rv) *= bigtens[j];\n\t\t/* The last multiplication could overflow. */\n\t\t\tword0(&rv) -= P*Exp_msk1;\n\t\t\tdval(&rv) *= bigtens[j];\n\t\t\tif ((z = word0(&rv) & Exp_mask)\n\t\t\t > Exp_msk1*(DBL_MAX_EXP+Bias-P))\n\t\t\t\tgoto ovfl;\n\t\t\tif (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) {\n\t\t\t\t/* set to largest number */\n\t\t\t\t/* (Can't trust DBL_MAX) */\n\t\t\t\tword0(&rv) = Big0;\n\t\t\t\tword1(&rv) = Big1;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tword0(&rv) += P*Exp_msk1;\n\t\t\t}\n\t\t}\n\telse if (e1 < 0) {\n\t\te1 = -e1;\n\t\tif ((i = e1 & 15))\n\t\t\tdval(&rv) /= tens[i];\n\t\tif (e1 >>= 4) {\n\t\t\tif (e1 >= 1 << n_bigtens)\n\t\t\t\tgoto undfl;\n#ifdef Avoid_Underflow\n\t\t\tif (e1 & Scale_Bit)\n\t\t\t\tbc.scale = 2*P;\n\t\t\tfor(j = 0; e1 > 0; j++, e1 >>= 1)\n\t\t\t\tif (e1 & 1)\n\t\t\t\t\tdval(&rv) *= tinytens[j];\n\t\t\tif (bc.scale && (j = 2*P + 1 - ((word0(&rv) & Exp_mask)\n\t\t\t\t\t\t>> Exp_shift)) > 0) {\n\t\t\t\t/* scaled rv is denormal; clear j low bits */\n\t\t\t\tif (j >= 32) {\n\t\t\t\t\tif (j > 54)\n\t\t\t\t\t\tgoto undfl;\n\t\t\t\t\tword1(&rv) = 0;\n\t\t\t\t\tif (j >= 53)\n\t\t\t\t\t word0(&rv) = (P+2)*Exp_msk1;\n\t\t\t\t\telse\n\t\t\t\t\t word0(&rv) &= 0xffffffff << (j-32);\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tword1(&rv) &= 0xffffffff << j;\n\t\t\t\t}\n#else\n\t\t\tfor(j = 0; e1 > 1; j++, e1 >>= 1)\n\t\t\t\tif (e1 & 1)\n\t\t\t\t\tdval(&rv) *= tinytens[j];\n\t\t\t/* The last multiplication could underflow. */\n\t\t\tdval(&rv0) = dval(&rv);\n\t\t\tdval(&rv) *= tinytens[j];\n\t\t\tif (!dval(&rv)) {\n\t\t\t\tdval(&rv) = 2.*dval(&rv0);\n\t\t\t\tdval(&rv) *= tinytens[j];\n#endif\n\t\t\t\tif (!dval(&rv)) {\n undfl:\n\t\t\t\t\tdval(&rv) = 0.;\n\t\t\t\t\tgoto range_err;\n\t\t\t\t\t}\n#ifndef Avoid_Underflow\n\t\t\t\tword0(&rv) = Tiny0;\n\t\t\t\tword1(&rv) = Tiny1;\n\t\t\t\t/* The refinement below will clean\n\t\t\t\t * this approximation up.\n\t\t\t\t */\n\t\t\t\t}\n#endif\n\t\t\t}\n\t\t}\n\n\t/* Now the hard part -- adjusting rv to the correct value.*/\n\n\t/* Put digits into bd: true value = bd * 10^e */\n\n\tbc.nd = nd - nz1;\n#ifndef NO_STRTOD_BIGCOMP\n\tbc.nd0 = nd0;\t/* Only needed if nd > strtod_diglim, but done here */\n\t\t\t/* to silence an erroneous warning about bc.nd0 */\n\t\t\t/* possibly not being initialized. */\n\tif (nd > strtod_diglim) {\n\t\t/* ASSERT(strtod_diglim >= 18); 18 == one more than the */\n\t\t/* minimum number of decimal digits to distinguish double values */\n\t\t/* in IEEE arithmetic. */\n\t\ti = j = 18;\n\t\tif (i > nd0)\n\t\t\tj += bc.dplen;\n\t\tfor(;;) {\n\t\t\tif (--j < bc.dp1 && j >= bc.dp0)\n\t\t\t\tj = bc.dp0 - 1;\n\t\t\tif (s0[j] != '0')\n\t\t\t\tbreak;\n\t\t\t--i;\n\t\t\t}\n\t\te += nd - i;\n\t\tnd = i;\n\t\tif (nd0 > nd)\n\t\t\tnd0 = nd;\n\t\tif (nd < 9) { /* must recompute y */\n\t\t\ty = 0;\n\t\t\tfor(i = 0; i < nd0; ++i)\n\t\t\t\ty = 10*y + s0[i] - '0';\n\t\t\tfor(j = bc.dp1; i < nd; ++i)\n\t\t\t\ty = 10*y + s0[j++] - '0';\n\t\t\t}\n\t\t}\n#endif\n\tbd0 = s2b(C, s0, nd0, nd, y, bc.dplen);\n\n\tfor(;;) {\n\t\tbd = Balloc(C, bd0->k);\n\t\tBcopy(bd, bd0);\n\t\tbb = d2b(C, &rv, &bbe, &bbbits);\t/* rv = bb * 2^bbe */\n\t\tbs = i2b(C, 1);\n\n\t\tif (e >= 0) {\n\t\t\tbb2 = bb5 = 0;\n\t\t\tbd2 = bd5 = e;\n\t\t\t}\n\t\telse {\n\t\t\tbb2 = bb5 = -e;\n\t\t\tbd2 = bd5 = 0;\n\t\t\t}\n\t\tif (bbe >= 0)\n\t\t\tbb2 += bbe;\n\t\telse\n\t\t\tbd2 -= bbe;\n\t\tbs2 = bb2;\n#ifdef Honor_FLT_ROUNDS\n\t\tif (bc.rounding != 1)\n\t\t\tbs2++;\n#endif\n#ifdef Avoid_Underflow\n\t\tLsb = LSB;\n\t\tLsb1 = 0;\n\t\tj = bbe - bc.scale;\n\t\ti = j + bbbits - 1;\t/* logb(rv) */\n\t\tj = P + 1 - bbbits;\n\t\tif (i < Emin) {\t/* denormal */\n\t\t\ti = Emin - i;\n\t\t\tj -= i;\n\t\t\tif (i < 32)\n\t\t\t\tLsb <<= i;\n\t\t\telse if (i < 52)\n\t\t\t\tLsb1 = Lsb << (i-32);\n\t\t\telse\n\t\t\t\tLsb1 = Exp_mask;\n\t\t\t}\n#else /*Avoid_Underflow*/\n#ifdef Sudden_Underflow\n#ifdef IBM\n\t\tj = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3);\n#else\n\t\tj = P + 1 - bbbits;\n#endif\n#else /*Sudden_Underflow*/\n\t\tj = bbe;\n\t\ti = j + bbbits - 1;\t/* logb(rv) */\n\t\tif (i < Emin)\t/* denormal */\n\t\t\tj += P - Emin;\n\t\telse\n\t\t\tj = P + 1 - bbbits;\n#endif /*Sudden_Underflow*/\n#endif /*Avoid_Underflow*/\n\t\tbb2 += j;\n\t\tbd2 += j;\n#ifdef Avoid_Underflow\n\t\tbd2 += bc.scale;\n#endif\n\t\ti = bb2 < bd2 ? bb2 : bd2;\n\t\tif (i > bs2)\n\t\t\ti = bs2;\n\t\tif (i > 0) {\n\t\t\tbb2 -= i;\n\t\t\tbd2 -= i;\n\t\t\tbs2 -= i;\n\t\t\t}\n\t\tif (bb5 > 0) {\n\t\t\tbs = pow5mult(C, bs, bb5);\n\t\t\tbb1 = mult(C, bs, bb);\n\t\t\tBfree(C, bb);\n\t\t\tbb = bb1;\n\t\t\t}\n\t\tif (bb2 > 0)\n\t\t\tbb = lshift(C, bb, bb2);\n\t\tif (bd5 > 0)\n\t\t\tbd = pow5mult(C, bd, bd5);\n\t\tif (bd2 > 0)\n\t\t\tbd = lshift(C, bd, bd2);\n\t\tif (bs2 > 0)\n\t\t\tbs = lshift(C, bs, bs2);\n\t\tdelta = diff(C, bb, bd);\n\t\tbc.dsign = delta->sign;\n\t\tdelta->sign = 0;\n\t\ti = cmp(C, delta, bs);\n#ifndef NO_STRTOD_BIGCOMP /*{*/\n\t\tif (bc.nd > nd && i <= 0) {\n\t\t\tif (bc.dsign) {\n\t\t\t\t/* Must use bigcomp(C, ). */\n\t\t\t\treq_bigcomp = 1;\n\t\t\t\tbreak;\n\t\t\t\t}\n#ifdef Honor_FLT_ROUNDS\n\t\t\tif (bc.rounding != 1) {\n\t\t\t\tif (i < 0) {\n\t\t\t\t\treq_bigcomp = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse\n#endif\n\t\t\t\ti = -1;\t/* Discarded digits make delta smaller. */\n\t\t\t}\n#endif /*}*/\n#ifdef Honor_FLT_ROUNDS /*{*/\n\t\tif (bc.rounding != 1) {\n\t\t\tif (i < 0) {\n\t\t\t\t/* Error is less than an ulp */\n\t\t\t\tif (!delta->x[0] && delta->wds <= 1) {\n\t\t\t\t\t/* exact */\n#ifdef SET_INEXACT\n\t\t\t\t\tbc.inexact = 0;\n#endif\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\tif (bc.rounding) {\n\t\t\t\t\tif (bc.dsign) {\n\t\t\t\t\t\tadj.d = 1.;\n\t\t\t\t\t\tgoto apply_adj;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\telse if (!bc.dsign) {\n\t\t\t\t\tadj.d = -1.;\n\t\t\t\t\tif (!word1(&rv)\n\t\t\t\t\t && !(word0(&rv) & Frac_mask)) {\n\t\t\t\t\t\ty = word0(&rv) & Exp_mask;\n\t\t\t\t\t\ttest_scale = y;\n#ifdef Avoid_Underflow\n\t\t\t\t\t\ttest_scale = (!bc.scale || y > 2*P*Exp_msk1);\n#endif\n\t\t\t\t\t\tif (test_scale) {\n\t\t\t\t\t\t  delta = lshift(C, delta,Log2P);\n\t\t\t\t\t\t  if (cmp(C, delta, bs) <= 0)\n\t\t\t\t\t\t\tadj.d = -0.5;\n\t\t\t\t\t\t  }\n\t\t\t\t\t\t}\n apply_adj:\n#ifdef Avoid_Underflow /*{*/\n\t\t\t\t\tif (bc.scale && (y = word0(&rv) & Exp_mask)\n\t\t\t\t\t\t<= 2*P*Exp_msk1)\n\t\t\t\t\t  word0(&adj) += (2*P+1)*Exp_msk1 - y;\n#else\n#ifdef Sudden_Underflow\n\t\t\t\t\tif ((word0(&rv) & Exp_mask) <=\n\t\t\t\t\t\t\tP*Exp_msk1) {\n\t\t\t\t\t\tword0(&rv) += P*Exp_msk1;\n\t\t\t\t\t\tdval(&rv) += adj.d*ulp(C, dval(&rv));\n\t\t\t\t\t\tword0(&rv) -= P*Exp_msk1;\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n#endif /*Sudden_Underflow*/\n#endif /*Avoid_Underflow}*/\n\t\t\t\t\tdval(&rv) += adj.d*ulp(C, &rv);\n\t\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tadj.d = ratio(C, delta, bs);\n\t\t\tif (adj.d < 1.)\n\t\t\t\tadj.d = 1.;\n\t\t\tif (adj.d <= 0x7ffffffe) {\n\t\t\t\t/* adj = rounding ? ceil(adj) : floor(adj); */\n\t\t\t\ty = adj.d;\n\t\t\t\tif (y != adj.d) {\n\t\t\t\t\tif (!((bc.rounding>>1) ^ bc.dsign))\n\t\t\t\t\t\ty++;\n\t\t\t\t\tadj.d = y;\n\t\t\t\t\t}\n\t\t\t\t}\n#ifdef Avoid_Underflow /*{*/\n\t\t\tif (bc.scale && (y = word0(&rv) & Exp_mask) <= 2*P*Exp_msk1)\n\t\t\t\tword0(&adj) += (2*P+1)*Exp_msk1 - y;\n#else\n#ifdef Sudden_Underflow\n\t\t\tif ((word0(&rv) & Exp_mask) <= P*Exp_msk1) {\n\t\t\t\tword0(&rv) += P*Exp_msk1;\n\t\t\t\tadj.d *= ulp(C, dval(&rv));\n\t\t\t\tif (bc.dsign)\n\t\t\t\t\tdval(&rv) += adj.d;\n\t\t\t\telse\n\t\t\t\t\tdval(&rv) -= adj.d;\n\t\t\t\tword0(&rv) -= P*Exp_msk1;\n\t\t\t\tgoto cont;\n\t\t\t\t}\n#endif /*Sudden_Underflow*/\n#endif /*Avoid_Underflow}*/\n\t\t\tadj.d *= ulp(C, &rv);\n\t\t\tif (bc.dsign) {\n\t\t\t\tif (word0(&rv) == Big0 && word1(&rv) == Big1)\n\t\t\t\t\tgoto ovfl;\n\t\t\t\tdval(&rv) += adj.d;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tdval(&rv) -= adj.d;\n\t\t\tgoto cont;\n\t\t\t}\n#endif /*}Honor_FLT_ROUNDS*/\n\n\t\tif (i < 0) {\n\t\t\t/* Error is less than half an ulp -- check for\n\t\t\t * special case of mantissa a power of two.\n\t\t\t */\n\t\t\tif (bc.dsign || word1(&rv) || word0(&rv) & Bndry_mask\n#ifdef IEEE_Arith /*{*/\n#ifdef Avoid_Underflow\n\t\t\t || (word0(&rv) & Exp_mask) <= (2*P+1)*Exp_msk1\n#else\n\t\t\t || (word0(&rv) & Exp_mask) <= Exp_msk1\n#endif\n#endif /*}*/\n\t\t\t\t) {\n#ifdef SET_INEXACT\n\t\t\t\tif (!delta->x[0] && delta->wds <= 1)\n\t\t\t\t\tbc.inexact = 0;\n#endif\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tif (!delta->x[0] && delta->wds <= 1) {\n\t\t\t\t/* exact result */\n#ifdef SET_INEXACT\n\t\t\t\tbc.inexact = 0;\n#endif\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tdelta = lshift(C, delta,Log2P);\n\t\t\tif (cmp(C, delta, bs) > 0)\n\t\t\t\tgoto drop_down;\n\t\t\tbreak;\n\t\t\t}\n\t\tif (i == 0) {\n\t\t\t/* exactly half-way between */\n\t\t\tif (bc.dsign) {\n\t\t\t\tif ((word0(&rv) & Bndry_mask1) == Bndry_mask1\n\t\t\t\t &&  word1(&rv) == (\n#ifdef Avoid_Underflow\n\t\t\t(bc.scale && (y = word0(&rv) & Exp_mask) <= 2*P*Exp_msk1)\n\t\t? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) :\n#endif\n\t\t\t\t\t\t   0xffffffff)) {\n\t\t\t\t\t/*boundary case -- increment exponent*/\n\t\t\t\t\tif (word0(&rv) == Big0 && word1(&rv) == Big1)\n\t\t\t\t\t\tgoto ovfl;\n\t\t\t\t\tword0(&rv) = (word0(&rv) & Exp_mask)\n\t\t\t\t\t\t+ Exp_msk1\n#ifdef IBM\n\t\t\t\t\t\t| Exp_msk1 >> 4\n#endif\n\t\t\t\t\t\t;\n\t\t\t\t\tword1(&rv) = 0;\n#ifdef Avoid_Underflow\n\t\t\t\t\tbc.dsign = 0;\n#endif\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse if (!(word0(&rv) & Bndry_mask) && !word1(&rv)) {\n drop_down:\n\t\t\t\t/* boundary case -- decrement exponent */\n#ifdef Sudden_Underflow /*{{*/\n\t\t\t\tL = word0(&rv) & Exp_mask;\n#ifdef IBM\n\t\t\t\tif (L <  Exp_msk1)\n#else\n#ifdef Avoid_Underflow\n\t\t\t\tif (L <= (bc.scale ? (2*P+1)*Exp_msk1 : Exp_msk1))\n#else\n\t\t\t\tif (L <= Exp_msk1)\n#endif /*Avoid_Underflow*/\n#endif /*IBM*/\n\t\t\t\t\t{\n\t\t\t\t\tif (bc.nd >nd) {\n\t\t\t\t\t\tbc.uflchk = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\tgoto undfl;\n\t\t\t\t\t}\n\t\t\t\tL -= Exp_msk1;\n#else /*Sudden_Underflow}{*/\n#ifdef Avoid_Underflow\n\t\t\t\tif (bc.scale) {\n\t\t\t\t\tL = word0(&rv) & Exp_mask;\n\t\t\t\t\tif (L <= (2*P+1)*Exp_msk1) {\n\t\t\t\t\t\tif (L > (P+2)*Exp_msk1)\n\t\t\t\t\t\t\t/* round even ==> */\n\t\t\t\t\t\t\t/* accept rv */\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t/* rv = smallest denormal */\n\t\t\t\t\t\tif (bc.nd >nd) {\n\t\t\t\t\t\t\tbc.uflchk = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tgoto undfl;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n#endif /*Avoid_Underflow*/\n\t\t\t\tL = (word0(&rv) & Exp_mask) - Exp_msk1;\n#endif /*Sudden_Underflow}}*/\n\t\t\t\tword0(&rv) = L | Bndry_mask1;\n\t\t\t\tword1(&rv) = 0xffffffff;\n#ifdef IBM\n\t\t\t\tgoto cont;\n#else\n#ifndef NO_STRTOD_BIGCOMP\n\t\t\t\tif (bc.nd > nd)\n\t\t\t\t\tgoto cont;\n#endif\n\t\t\t\tbreak;\n#endif\n\t\t\t\t}\n#ifndef ROUND_BIASED\n#ifdef Avoid_Underflow\n\t\t\tif (Lsb1) {\n\t\t\t\tif (!(word0(&rv) & Lsb1))\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\telse if (!(word1(&rv) & Lsb))\n\t\t\t\tbreak;\n#else\n\t\t\tif (!(word1(&rv) & LSB))\n\t\t\t\tbreak;\n#endif\n#endif\n\t\t\tif (bc.dsign)\n#ifdef Avoid_Underflow\n\t\t\t\tdval(&rv) += sulp(C, &rv, &bc);\n#else\n\t\t\t\tdval(&rv) += ulp(C, &rv);\n#endif\n#ifndef ROUND_BIASED\n\t\t\telse {\n#ifdef Avoid_Underflow\n\t\t\t\tdval(&rv) -= sulp(C, &rv, &bc);\n#else\n\t\t\t\tdval(&rv) -= ulp(C, &rv);\n#endif\n#ifndef Sudden_Underflow\n\t\t\t\tif (!dval(&rv)) {\n\t\t\t\t\tif (bc.nd >nd) {\n\t\t\t\t\t\tbc.uflchk = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\tgoto undfl;\n\t\t\t\t\t}\n#endif\n\t\t\t\t}\n#ifdef Avoid_Underflow\n\t\t\tbc.dsign = 1 - bc.dsign;\n#endif\n#endif\n\t\t\tbreak;\n\t\t\t}\n\t\tif ((aadj = ratio(C, delta, bs)) <= 2.) {\n\t\t\tif (bc.dsign)\n\t\t\t\taadj = aadj1 = 1.;\n\t\t\telse if (word1(&rv) || word0(&rv) & Bndry_mask) {\n#ifndef Sudden_Underflow\n\t\t\t\tif (word1(&rv) == Tiny1 && !word0(&rv)) {\n\t\t\t\t\tif (bc.nd >nd) {\n\t\t\t\t\t\tbc.uflchk = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\tgoto undfl;\n\t\t\t\t\t}\n#endif\n\t\t\t\taadj = 1.;\n\t\t\t\taadj1 = -1.;\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\t/* special case -- power of FLT_RADIX to be */\n\t\t\t\t/* rounded down... */\n\n\t\t\t\tif (aadj < 2./FLT_RADIX)\n\t\t\t\t\taadj = 1./FLT_RADIX;\n\t\t\t\telse\n\t\t\t\t\taadj *= 0.5;\n\t\t\t\taadj1 = -aadj;\n\t\t\t\t}\n\t\t\t}\n\t\telse {\n\t\t\taadj *= 0.5;\n\t\t\taadj1 = bc.dsign ? aadj : -aadj;\n#ifdef Check_FLT_ROUNDS\n\t\t\tswitch(bc.rounding) {\n\t\t\t\tcase 2: /* towards +infinity */\n\t\t\t\t\taadj1 -= 0.5;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0: /* towards 0 */\n\t\t\t\tcase 3: /* towards -infinity */\n\t\t\t\t\taadj1 += 0.5;\n\t\t\t\t}\n#else\n\t\t\tif (Flt_Rounds == 0)\n\t\t\t\taadj1 += 0.5;\n#endif /*Check_FLT_ROUNDS*/\n\t\t\t}\n\t\ty = word0(&rv) & Exp_mask;\n\n\t\t/* Check for overflow */\n\n\t\tif (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {\n\t\t\tdval(&rv0) = dval(&rv);\n\t\t\tword0(&rv) -= P*Exp_msk1;\n\t\t\tadj.d = aadj1 * ulp(C, &rv);\n\t\t\tdval(&rv) += adj.d;\n\t\t\tif ((word0(&rv) & Exp_mask) >=\n\t\t\t\t\tExp_msk1*(DBL_MAX_EXP+Bias-P)) {\n\t\t\t\tif (word0(&rv0) == Big0 && word1(&rv0) == Big1)\n\t\t\t\t\tgoto ovfl;\n\t\t\t\tword0(&rv) = Big0;\n\t\t\t\tword1(&rv) = Big1;\n\t\t\t\tgoto cont;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tword0(&rv) += P*Exp_msk1;\n\t\t\t}\n\t\telse {\n#ifdef Avoid_Underflow\n\t\t\tif (bc.scale && y <= 2*P*Exp_msk1) {\n\t\t\t\tif (aadj <= 0x7fffffff) {\n\t\t\t\t\tif ((z = aadj) <= 0)\n\t\t\t\t\t\tz = 1;\n\t\t\t\t\taadj = z;\n\t\t\t\t\taadj1 = bc.dsign ? aadj : -aadj;\n\t\t\t\t\t}\n\t\t\t\tdval(&aadj2) = aadj1;\n\t\t\t\tword0(&aadj2) += (2*P+1)*Exp_msk1 - y;\n\t\t\t\taadj1 = dval(&aadj2);\n\t\t\t\tadj.d = aadj1 * ulp(C, &rv);\n\t\t\t\tdval(&rv) += adj.d;\n\t\t\t\tif (rv.d == 0.)\n#ifdef NO_STRTOD_BIGCOMP\n\t\t\t\t\tgoto undfl;\n#else\n\t\t\t\t\t{\n\t\t\t\t\tif (bc.nd > nd)\n\t\t\t\t\t\tbc.dsign = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n#endif\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\tadj.d = aadj1 * ulp(C, &rv);\n\t\t\t\tdval(&rv) += adj.d;\n\t\t\t\t}\n#else\n#ifdef Sudden_Underflow\n\t\t\tif ((word0(&rv) & Exp_mask) <= P*Exp_msk1) {\n\t\t\t\tdval(&rv0) = dval(&rv);\n\t\t\t\tword0(&rv) += P*Exp_msk1;\n\t\t\t\tadj.d = aadj1 * ulp(C, &rv);\n\t\t\t\tdval(&rv) += adj.d;\n#ifdef IBM\n\t\t\t\tif ((word0(&rv) & Exp_mask) <  P*Exp_msk1)\n#else\n\t\t\t\tif ((word0(&rv) & Exp_mask) <= P*Exp_msk1)\n#endif\n\t\t\t\t\t{\n\t\t\t\t\tif (word0(&rv0) == Tiny0\n\t\t\t\t\t && word1(&rv0) == Tiny1) {\n\t\t\t\t\t\tif (bc.nd >nd) {\n\t\t\t\t\t\t\tbc.uflchk = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tgoto undfl;\n\t\t\t\t\t\t}\n\t\t\t\t\tword0(&rv) = Tiny0;\n\t\t\t\t\tword1(&rv) = Tiny1;\n\t\t\t\t\tgoto cont;\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tword0(&rv) -= P*Exp_msk1;\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\tadj.d = aadj1 * ulp(C, &rv);\n\t\t\t\tdval(&rv) += adj.d;\n\t\t\t\t}\n#else /*Sudden_Underflow*/\n\t\t\t/* Compute adj so that the IEEE rounding rules will\n\t\t\t * correctly round rv + adj in some half-way cases.\n\t\t\t * If rv * ulp(C, rv) is denormalized (i.e.,\n\t\t\t * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid\n\t\t\t * trouble from bits lost to denormalization;\n\t\t\t * example: 1.2e-307 .\n\t\t\t */\n\t\t\tif (y <= (P-1)*Exp_msk1 && aadj > 1.) {\n\t\t\t\taadj1 = (double)(int)(aadj + 0.5);\n\t\t\t\tif (!bc.dsign)\n\t\t\t\t\taadj1 = -aadj1;\n\t\t\t\t}\n\t\t\tadj.d = aadj1 * ulp(C, &rv);\n\t\t\tdval(&rv) += adj.d;\n#endif /*Sudden_Underflow*/\n#endif /*Avoid_Underflow*/\n\t\t\t}\n\t\tz = word0(&rv) & Exp_mask;\n#ifndef SET_INEXACT\n\t\tif (bc.nd == nd) {\n#ifdef Avoid_Underflow\n\t\tif (!bc.scale)\n#endif\n\t\tif (y == z) {\n\t\t\t/* Can we stop now? */\n\t\t\tL = (Long)aadj;\n\t\t\taadj -= L;\n\t\t\t/* The tolerances below are conservative. */\n\t\t\tif (bc.dsign || word1(&rv) || word0(&rv) & Bndry_mask) {\n\t\t\t\tif (aadj < .4999999 || aadj > .5000001)\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\telse if (aadj < .4999999/FLT_RADIX)\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n#endif\n cont:\n\t\tBfree(C, bb);\n\t\tBfree(C, bd);\n\t\tBfree(C, bs);\n\t\tBfree(C, delta);\n\t\t}\n\tBfree(C, bb);\n\tBfree(C, bd);\n\tBfree(C, bs);\n\tBfree(C, bd0);\n\tBfree(C, delta);\n#ifndef NO_STRTOD_BIGCOMP\n\tif (req_bigcomp) {\n\t\tbd0 = 0;\n\t\tbc.e0 += nz1;\n\t\tbigcomp(C, &rv, s0, &bc);\n\t\ty = word0(&rv) & Exp_mask;\n\t\tif (y == Exp_mask)\n\t\t\tgoto ovfl;\n\t\tif (y == 0 && rv.d == 0.)\n\t\t\tgoto undfl;\n\t\t}\n#endif\n#ifdef SET_INEXACT\n\tif (bc.inexact) {\n\t\tif (!oldinexact) {\n\t\t\tword0(&rv0) = Exp_1 + (70 << Exp_shift);\n\t\t\tword1(&rv0) = 0;\n\t\t\tdval(&rv0) += 1.;\n\t\t\t}\n\t\t}\n\telse if (!oldinexact)\n\t\tclear_inexact();\n#endif\n#ifdef Avoid_Underflow\n\tif (bc.scale) {\n\t\tword0(&rv0) = Exp_1 - 2*P*Exp_msk1;\n\t\tword1(&rv0) = 0;\n\t\tdval(&rv) *= dval(&rv0);\n#ifndef NO_ERRNO\n\t\t/* try to avoid the bug of testing an 8087 register value */\n#ifdef IEEE_Arith\n\t\tif (!(word0(&rv) & Exp_mask))\n#else\n\t\tif (word0(&rv) == 0 && word1(&rv) == 0)\n#endif\n\t\t\terrno = ERANGE;\n#endif\n\t\t}\n#endif /* Avoid_Underflow */\n#ifdef SET_INEXACT\n\tif (bc.inexact && !(word0(&rv) & Exp_mask)) {\n\t\t/* set underflow bit */\n\t\tdval(&rv0) = 1e-300;\n\t\tdval(&rv0) *= dval(&rv0);\n\t\t}\n#endif\n ret:\n\tif (se)\n\t\t*se = (char *)s;\n\treturn sign ? -dval(&rv) : dval(&rv);\n\t}\n\n static char *\nrv_alloc(struct dtoa_context* C, int i)\n{\n\tint j, k, *r;\n\n\tj = sizeof(ULong);\n\tfor(k = 0;\n            (int)(sizeof(Bigint) - sizeof(ULong) - sizeof(int)) + j <= i;\n\t\tj <<= 1)\n\t\t\tk++;\n\tr = (int*)Balloc(C, k);\n\t*r = k;\n\treturn\n\t\t(char *)(r+1);\n\t}\n\n static char *\nnrv_alloc(struct dtoa_context* C, const char *s, char **rve, int n)\n{\n\tchar *rv, *t;\n\n\tt = rv = rv_alloc(C, n);\n\twhile((*t = *s++)) t++;\n\tif (rve)\n\t\t*rve = t;\n\treturn rv;\n\t}\n\n/* freedtoa(s) must be used to free values s returned by dtoa\n * when MULTIPLE_THREADS is #defined.  It should be used in all cases,\n * but for consistency with earlier versions of dtoa, it is optional\n * when MULTIPLE_THREADS is not defined.\n */\n\n void\njvp_freedtoa(struct dtoa_context* C, char *s)\n{\n\tBigint *b = (Bigint *)((int *)s - 1);\n\tb->maxwds = 1 << (b->k = *(int*)b);\n\tBfree(C, b);\n\t}\n\n/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.\n *\n * Inspired by \"How to Print Floating-Point Numbers Accurately\" by\n * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126].\n *\n * Modifications:\n *\t1. Rather than iterating, we use a simple numeric overestimate\n *\t   to determine k = floor(log10(d)).  We scale relevant\n *\t   quantities using O(log2(k)) rather than O(k) multiplications.\n *\t2. For some modes > 2 (corresponding to ecvt and fcvt), we don't\n *\t   try to generate digits strictly left to right.  Instead, we\n *\t   compute with fewer bits and propagate the carry if necessary\n *\t   when rounding the final digit up.  This is often faster.\n *\t3. Under the assumption that input will be rounded nearest,\n *\t   mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.\n *\t   That is, we allow equality in stopping tests when the\n *\t   round-nearest rule will give the same floating-point value\n *\t   as would satisfaction of the stopping test with strict\n *\t   inequality.\n *\t4. We remove common factors of powers of 2 from relevant\n *\t   quantities.\n *\t5. When converting floating-point integers less than 1e16,\n *\t   we use floating-point arithmetic rather than resorting\n *\t   to multiple-precision integers.\n *\t6. When asked to produce fewer than 15 digits, we first try\n *\t   to get by with floating-point arithmetic; we resort to\n *\t   multiple-precision integer arithmetic only if we cannot\n *\t   guarantee that the floating-point calculation has given\n *\t   the correctly rounded result.  For k requested digits and\n *\t   \"uniformly\" distributed input, the probability is\n *\t   something like 10^(k-15) that we must resort to the Long\n *\t   calculation.\n */\n\n char *\njvp_dtoa\n (struct dtoa_context* C, double dd, int mode, int ndigits, int *decpt, int *sign, char **rve)\n{\n /*\tArguments ndigits, decpt, sign are similar to those\n\tof ecvt and fcvt; trailing zeros are suppressed from\n\tthe returned string.  If not null, *rve is set to point\n\tto the end of the return value.  If d is +-Infinity or NaN,\n\tthen *decpt is set to 9999.\n\n\tmode:\n\t\t0 ==> shortest string that yields d when read in\n\t\t\tand rounded to nearest.\n\t\t1 ==> like 0, but with Steele & White stopping rule;\n\t\t\te.g. with IEEE P754 arithmetic , mode 0 gives\n\t\t\t1e23 whereas mode 1 gives 9.999999999999999e22.\n\t\t2 ==> max(1,ndigits) significant digits.  This gives a\n\t\t\treturn value similar to that of ecvt, except\n\t\t\tthat trailing zeros are suppressed.\n\t\t3 ==> through ndigits past the decimal point.  This\n\t\t\tgives a return value similar to that from fcvt,\n\t\t\texcept that trailing zeros are suppressed, and\n\t\t\tndigits can be negative.\n\t\t4,5 ==> similar to 2 and 3, respectively, but (in\n\t\t\tround-nearest mode) with the tests of mode 0 to\n\t\t\tpossibly return a shorter string that rounds to d.\n\t\t\tWith IEEE arithmetic and compilation with\n\t\t\t-DHonor_FLT_ROUNDS, modes 4 and 5 behave the same\n\t\t\tas modes 2 and 3 when FLT_ROUNDS != 1.\n\t\t6-9 ==> Debugging modes similar to mode - 4:  don't try\n\t\t\tfast floating-point estimate (if applicable).\n\n\t\tValues of mode other than 0-9 are treated as mode 0.\n\n\t\tSufficient space is allocated to the return value\n\t\tto hold the suppressed trailing zeros.\n\t*/\n\n\tint bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1,\n\t\tj, j1=0, k, k0, k_check, leftright, m2, m5, s2, s5,\n\t\tspec_case, try_quick;\n\tLong L;\n#ifndef Sudden_Underflow\n\tint denorm;\n\tULong x;\n#endif\n\tBigint *b, *b1, *delta, *mlo, *mhi, *S;\n\tU d2, eps, u;\n\tdouble ds;\n\tchar *s, *s0;\n#ifndef No_leftright\n#ifdef IEEE_Arith\n\tU eps1;\n#endif\n#endif\n#ifdef SET_INEXACT\n\tint inexact, oldinexact;\n#endif\n#ifdef Honor_FLT_ROUNDS /*{*/\n\tint Rounding;\n#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */\n\tRounding = Flt_Rounds;\n#else /*}{*/\n\tRounding = 1;\n\tswitch(fegetround()) {\n\t  case FE_TOWARDZERO:\tRounding = 0; break;\n\t  case FE_UPWARD:\tRounding = 2; break;\n\t  case FE_DOWNWARD:\tRounding = 3;\n\t  }\n#endif /*}}*/\n#endif /*}*/\n\n\n\tu.d = dd;\n\tif (word0(&u) & Sign_bit) {\n\t\t/* set sign for everything, including 0's and NaNs */\n\t\t*sign = 1;\n\t\tword0(&u) &= ~Sign_bit;\t/* clear sign bit */\n\t\t}\n\telse\n\t\t*sign = 0;\n\n#if defined(IEEE_Arith) + defined(VAX)\n#ifdef IEEE_Arith\n\tif ((word0(&u) & Exp_mask) == Exp_mask)\n#else\n\tif (word0(&u)  == 0x8000)\n#endif\n\t\t{\n\t\t/* Infinity or NaN */\n\t\t*decpt = 9999;\n#ifdef IEEE_Arith\n\t\tif (!word1(&u) && !(word0(&u) & 0xfffff))\n\t\t\treturn nrv_alloc(C, \"Infinity\", rve, 8);\n#endif\n\t\treturn nrv_alloc(C, \"NaN\", rve, 3);\n\t\t}\n#endif\n#ifdef IBM\n\tdval(&u) += 0; /* normalize */\n#endif\n\tif (!dval(&u)) {\n\t\t*decpt = 1;\n\t\treturn nrv_alloc(C, \"0\", rve, 1);\n\t\t}\n\n#ifdef SET_INEXACT\n\ttry_quick = oldinexact = get_inexact();\n\tinexact = 1;\n#endif\n#ifdef Honor_FLT_ROUNDS\n\tif (Rounding >= 2) {\n\t\tif (*sign)\n\t\t\tRounding = Rounding == 2 ? 0 : 2;\n\t\telse\n\t\t\tif (Rounding != 2)\n\t\t\t\tRounding = 0;\n\t\t}\n#endif\n\n\tb = d2b(C, &u, &be, &bbits);\n#ifdef Sudden_Underflow\n\ti = (int)(word0(&u) >> Exp_shift1 & (Exp_mask>>Exp_shift1));\n#else\n\tif ((i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask>>Exp_shift1)))) {\n#endif\n\t\tdval(&d2) = dval(&u);\n\t\tword0(&d2) &= Frac_mask1;\n\t\tword0(&d2) |= Exp_11;\n#ifdef IBM\n\t\tif (j = 11 - hi0bits(C, word0(&d2) & Frac_mask))\n\t\t\tdval(&d2) /= 1 << j;\n#endif\n\n\t\t/* log(x)\t~=~ log(1.5) + (x-1.5)/1.5\n\t\t * log10(x)\t =  log(x) / log(10)\n\t\t *\t\t~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))\n\t\t * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)\n\t\t *\n\t\t * This suggests computing an approximation k to log10(d) by\n\t\t *\n\t\t * k = (i - Bias)*0.301029995663981\n\t\t *\t+ ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );\n\t\t *\n\t\t * We want k to be too large rather than too small.\n\t\t * The error in the first-order Taylor series approximation\n\t\t * is in our favor, so we just round up the constant enough\n\t\t * to compensate for any error in the multiplication of\n\t\t * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,\n\t\t * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,\n\t\t * adding 1e-13 to the constant term more than suffices.\n\t\t * Hence we adjust the constant term to 0.1760912590558.\n\t\t * (We could get a more accurate k by invoking log10,\n\t\t *  but this is probably not worthwhile.)\n\t\t */\n\n\t\ti -= Bias;\n#ifdef IBM\n\t\ti <<= 2;\n\t\ti += j;\n#endif\n#ifndef Sudden_Underflow\n\t\tdenorm = 0;\n\t\t}\n\telse {\n\t\t/* d is denormalized */\n\n\t\ti = bbits + be + (Bias + (P-1) - 1);\n\t\tx = i > 32  ? word0(&u) << (64 - i) | word1(&u) >> (i - 32)\n\t\t\t    : word1(&u) << (32 - i);\n\t\tdval(&d2) = x;\n\t\tword0(&d2) -= 31*Exp_msk1; /* adjust exponent */\n\t\ti -= (Bias + (P-1) - 1) + 1;\n\t\tdenorm = 1;\n\t\t}\n#endif\n\tds = (dval(&d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;\n\tk = (int)ds;\n\tif (ds < 0. && ds != k)\n\t\tk--;\t/* want k = floor(ds) */\n\tk_check = 1;\n\tif (k >= 0 && k <= Ten_pmax) {\n\t\tif (dval(&u) < tens[k])\n\t\t\tk--;\n\t\tk_check = 0;\n\t\t}\n\tj = bbits - i - 1;\n\tif (j >= 0) {\n\t\tb2 = 0;\n\t\ts2 = j;\n\t\t}\n\telse {\n\t\tb2 = -j;\n\t\ts2 = 0;\n\t\t}\n\tif (k >= 0) {\n\t\tb5 = 0;\n\t\ts5 = k;\n\t\ts2 += k;\n\t\t}\n\telse {\n\t\tb2 -= k;\n\t\tb5 = -k;\n\t\ts5 = 0;\n\t\t}\n\tif (mode < 0 || mode > 9)\n\t\tmode = 0;\n\n#ifndef SET_INEXACT\n#ifdef Check_FLT_ROUNDS\n\ttry_quick = Rounding == 1;\n#else\n\ttry_quick = 1;\n#endif\n#endif /*SET_INEXACT*/\n\n\tif (mode > 5) {\n\t\tmode -= 4;\n\t\ttry_quick = 0;\n\t\t}\n\tleftright = 1;\n\tilim = ilim1 = -1;\t/* Values for cases 0 and 1; done here to */\n\t\t\t\t/* silence erroneous \"gcc -Wall\" warning. */\n\tswitch(mode) {\n\t\tcase 0:\n\t\tcase 1:\n\t\t\ti = 18;\n\t\t\tndigits = 0;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tleftright = 0;\n\t\t\t/* no break */\n\t\t\tJQ_FALLTHROUGH;\n\t\tcase 4:\n\t\t\tif (ndigits <= 0)\n\t\t\t\tndigits = 1;\n\t\t\tilim = ilim1 = i = ndigits;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tleftright = 0;\n\t\t\t/* no break */\n\t\t\tJQ_FALLTHROUGH;\n\t\tcase 5:\n\t\t\ti = ndigits + k + 1;\n\t\t\tilim = i;\n\t\t\tilim1 = i - 1;\n\t\t\tif (i <= 0)\n\t\t\t\ti = 1;\n\t\t}\n\ts = s0 = rv_alloc(C, i);\n\n#ifdef Honor_FLT_ROUNDS\n\tif (mode > 1 && Rounding != 1)\n\t\tleftright = 0;\n#endif\n\n\tif (ilim >= 0 && ilim <= Quick_max && try_quick) {\n\n\t\t/* Try to get by with floating-point arithmetic. */\n\n\t\ti = 0;\n\t\tdval(&d2) = dval(&u);\n\t\tk0 = k;\n\t\tilim0 = ilim;\n\t\tieps = 2; /* conservative */\n\t\tif (k > 0) {\n\t\t\tds = tens[k&0xf];\n\t\t\tj = k >> 4;\n\t\t\tif (j & Bletch) {\n\t\t\t\t/* prevent overflows */\n\t\t\t\tj &= Bletch - 1;\n\t\t\t\tdval(&u) /= bigtens[n_bigtens-1];\n\t\t\t\tieps++;\n\t\t\t\t}\n\t\t\tfor(; j; j >>= 1, i++)\n\t\t\t\tif (j & 1) {\n\t\t\t\t\tieps++;\n\t\t\t\t\tds *= bigtens[i];\n\t\t\t\t\t}\n\t\t\tdval(&u) /= ds;\n\t\t\t}\n\t\telse if ((j1 = -k)) {\n\t\t\tdval(&u) *= tens[j1 & 0xf];\n\t\t\tfor(j = j1 >> 4; j; j >>= 1, i++)\n\t\t\t\tif (j & 1) {\n\t\t\t\t\tieps++;\n\t\t\t\t\tdval(&u) *= bigtens[i];\n\t\t\t\t\t}\n\t\t\t}\n\t\tif (k_check && dval(&u) < 1. && ilim > 0) {\n\t\t\tif (ilim1 <= 0)\n\t\t\t\tgoto fast_failed;\n\t\t\tilim = ilim1;\n\t\t\tk--;\n\t\t\tdval(&u) *= 10.;\n\t\t\tieps++;\n\t\t\t}\n\t\tdval(&eps) = ieps*dval(&u) + 7.;\n\t\tword0(&eps) -= (P-1)*Exp_msk1;\n\t\tif (ilim == 0) {\n\t\t\tS = mhi = 0;\n\t\t\tdval(&u) -= 5.;\n\t\t\tif (dval(&u) > dval(&eps))\n\t\t\t\tgoto one_digit;\n\t\t\tif (dval(&u) < -dval(&eps))\n\t\t\t\tgoto no_digits;\n\t\t\tgoto fast_failed;\n\t\t\t}\n#ifndef No_leftright\n\t\tif (leftright) {\n\t\t\t/* Use Steele & White method of only\n\t\t\t * generating digits needed.\n\t\t\t */\n\t\t\tdval(&eps) = 0.5/tens[ilim-1] - dval(&eps);\n#ifdef IEEE_Arith\n\t\t\tif (k0 < 0 && j1 >= 307) {\n\t\t\t\teps1.d = 1.01e256; /* 1.01 allows roundoff in the next few lines */\n\t\t\t\tword0(&eps1) -= Exp_msk1 * (Bias+P-1);\n\t\t\t\tdval(&eps1) *= tens[j1 & 0xf];\n\t\t\t\tfor(i = 0, j = (j1-256) >> 4; j; j >>= 1, i++)\n\t\t\t\t\tif (j & 1)\n\t\t\t\t\t\tdval(&eps1) *= bigtens[i];\n\t\t\t\tif (eps.d < eps1.d)\n\t\t\t\t\teps.d = eps1.d;\n\t\t\t\t}\n#endif\n\t\t\tfor(i = 0;;) {\n\t\t\t\tL = dval(&u);\n\t\t\t\tdval(&u) -= L;\n\t\t\t\t*s++ = '0' + (int)L;\n\t\t\t\tif (1. - dval(&u) < dval(&eps))\n\t\t\t\t\tgoto bump_up;\n\t\t\t\tif (dval(&u) < dval(&eps))\n\t\t\t\t\tgoto ret1;\n\t\t\t\tif (++i >= ilim)\n\t\t\t\t\tbreak;\n\t\t\t\tdval(&eps) *= 10.;\n\t\t\t\tdval(&u) *= 10.;\n\t\t\t\t}\n\t\t\t}\n\t\telse {\n#endif\n\t\t\t/* Generate ilim digits, then fix them up. */\n\t\t\tdval(&eps) *= tens[ilim-1];\n\t\t\tfor(i = 1;; i++, dval(&u) *= 10.) {\n\t\t\t\tL = (Long)(dval(&u));\n\t\t\t\tif (!(dval(&u) -= L))\n\t\t\t\t\tilim = i;\n\t\t\t\t*s++ = '0' + (int)L;\n\t\t\t\tif (i == ilim) {\n\t\t\t\t\tif (dval(&u) > 0.5 + dval(&eps))\n\t\t\t\t\t\tgoto bump_up;\n\t\t\t\t\telse if (dval(&u) < 0.5 - dval(&eps)) {\n\t\t\t\t\t\twhile(*--s == '0');\n\t\t\t\t\t\ts++;\n\t\t\t\t\t\tgoto ret1;\n\t\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n#ifndef No_leftright\n\t\t\t}\n#endif\n fast_failed:\n\t\ts = s0;\n\t\tdval(&u) = dval(&d2);\n\t\tk = k0;\n\t\tilim = ilim0;\n\t\t}\n\n\t/* Do we have a \"small\" integer? */\n\n\tif (be >= 0 && k <= Int_max) {\n\t\t/* Yes. */\n\t\tds = tens[k];\n\t\tif (ndigits < 0 && ilim <= 0) {\n\t\t\tS = mhi = 0;\n\t\t\tif (ilim < 0 || dval(&u) <= 5*ds)\n\t\t\t\tgoto no_digits;\n\t\t\tgoto one_digit;\n\t\t\t}\n\t\tfor(i = 1;; i++, dval(&u) *= 10.) {\n\t\t\tL = (Long)(dval(&u) / ds);\n\t\t\tdval(&u) -= L*ds;\n#ifdef Check_FLT_ROUNDS\n\t\t\t/* If FLT_ROUNDS == 2, L will usually be high by 1 */\n\t\t\tif (dval(&u) < 0) {\n\t\t\t\tL--;\n\t\t\t\tdval(&u) += ds;\n\t\t\t\t}\n#endif\n\t\t\t*s++ = '0' + (int)L;\n\t\t\tif (!dval(&u)) {\n#ifdef SET_INEXACT\n\t\t\t\tinexact = 0;\n#endif\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tif (i == ilim) {\n#ifdef Honor_FLT_ROUNDS\n\t\t\t\tif (mode > 1)\n\t\t\t\tswitch(Rounding) {\n\t\t\t\t  case 0: goto ret1;\n\t\t\t\t  case 2: goto bump_up;\n\t\t\t\t  }\n#endif\n\t\t\t\tdval(&u) += dval(&u);\n#ifdef ROUND_BIASED\n\t\t\t\tif (dval(&u) >= ds)\n#else\n\t\t\t\tif (dval(&u) > ds || (dval(&u) == ds && L & 1))\n#endif\n\t\t\t\t\t{\n bump_up:\n\t\t\t\t\twhile(*--s == '9')\n\t\t\t\t\t\tif (s == s0) {\n\t\t\t\t\t\t\tk++;\n\t\t\t\t\t\t\t*s = '0';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t++*s++;\n\t\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tgoto ret1;\n\t\t}\n\n\tm2 = b2;\n\tm5 = b5;\n\tmhi = mlo = 0;\n\tif (leftright) {\n\t\ti =\n#ifndef Sudden_Underflow\n\t\t\tdenorm ? be + (Bias + (P-1) - 1 + 1) :\n#endif\n#ifdef IBM\n\t\t\t1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3);\n#else\n\t\t\t1 + P - bbits;\n#endif\n\t\tb2 += i;\n\t\ts2 += i;\n\t\tmhi = i2b(C, 1);\n\t\t}\n\tif (m2 > 0 && s2 > 0) {\n\t\ti = m2 < s2 ? m2 : s2;\n\t\tb2 -= i;\n\t\tm2 -= i;\n\t\ts2 -= i;\n\t\t}\n\tif (b5 > 0) {\n\t\tif (leftright) {\n\t\t\tif (m5 > 0) {\n\t\t\t\tmhi = pow5mult(C, mhi, m5);\n\t\t\t\tb1 = mult(C, mhi, b);\n\t\t\t\tBfree(C, b);\n\t\t\t\tb = b1;\n\t\t\t\t}\n\t\t\tif ((j = b5 - m5))\n\t\t\t\tb = pow5mult(C, b, j);\n\t\t\t}\n\t\telse\n\t\t\tb = pow5mult(C, b, b5);\n\t\t}\n\tS = i2b(C, 1);\n\tif (s5 > 0)\n\t\tS = pow5mult(C, S, s5);\n\n\t/* Check for special case that d is a normalized power of 2. */\n\n\tspec_case = 0;\n\tif ((mode < 2 || leftright)\n#ifdef Honor_FLT_ROUNDS\n\t\t\t&& Rounding == 1\n#endif\n\t\t\t\t) {\n\t\tif (!word1(&u) && !(word0(&u) & Bndry_mask)\n#ifndef Sudden_Underflow\n\t\t && word0(&u) & (Exp_mask & ~Exp_msk1)\n#endif\n\t\t\t\t) {\n\t\t\t/* The special case */\n\t\t\tb2 += Log2P;\n\t\t\ts2 += Log2P;\n\t\t\tspec_case = 1;\n\t\t\t}\n\t\t}\n\n\t/* Arrange for convenient computation of quotients:\n\t * shift left if necessary so divisor has 4 leading 0 bits.\n\t *\n\t * Perhaps we should just compute leading 28 bits of S once\n\t * and for all and pass them and a shift to quorem, so it\n\t * can do shifts and ors to compute the numerator for q.\n\t */\n\ti = dshift(C, S, s2);\n\tb2 += i;\n\tm2 += i;\n\ts2 += i;\n\tif (b2 > 0)\n\t\tb = lshift(C, b, b2);\n\tif (s2 > 0)\n\t\tS = lshift(C, S, s2);\n\tif (k_check) {\n\t\tif (cmp(C, b,S) < 0) {\n\t\t\tk--;\n\t\t\tb = multadd(C, b, 10, 0);\t/* we botched the k estimate */\n\t\t\tif (leftright)\n\t\t\t\tmhi = multadd(C, mhi, 10, 0);\n\t\t\tilim = ilim1;\n\t\t\t}\n\t\t}\n\tif (ilim <= 0 && (mode == 3 || mode == 5)) {\n\t\tif (ilim < 0 || cmp(C, b,S = multadd(C, S,5,0)) <= 0) {\n\t\t\t/* no digits, fcvt style */\n no_digits:\n\t\t\tk = -1 - ndigits;\n\t\t\tgoto ret;\n\t\t\t}\n one_digit:\n\t\t*s++ = '1';\n\t\tk++;\n\t\tgoto ret;\n\t\t}\n\tif (leftright) {\n\t\tif (m2 > 0)\n\t\t\tmhi = lshift(C, mhi, m2);\n\n\t\t/* Compute mlo -- check for special case\n\t\t * that d is a normalized power of 2.\n\t\t */\n\n\t\tmlo = mhi;\n\t\tif (spec_case) {\n\t\t\tmhi = Balloc(C, mhi->k);\n\t\t\tBcopy(mhi, mlo);\n\t\t\tmhi = lshift(C, mhi, Log2P);\n\t\t\t}\n\n\t\tfor(i = 1;;i++) {\n\t\t\tdig = quorem(C, b,S) + '0';\n\t\t\t/* Do we yet have the shortest decimal string\n\t\t\t * that will round to d?\n\t\t\t */\n\t\t\tj = cmp(C, b, mlo);\n\t\t\tdelta = diff(C, S, mhi);\n\t\t\tj1 = delta->sign ? 1 : cmp(C, b, delta);\n\t\t\tBfree(C, delta);\n#ifndef ROUND_BIASED\n\t\t\tif (j1 == 0 && mode != 1 && !(word1(&u) & 1)\n#ifdef Honor_FLT_ROUNDS\n\t\t\t\t&& Rounding >= 1\n#endif\n\t\t\t\t\t\t\t\t   ) {\n\t\t\t\tif (dig == '9')\n\t\t\t\t\tgoto round_9_up;\n\t\t\t\tif (j > 0)\n\t\t\t\t\tdig++;\n#ifdef SET_INEXACT\n\t\t\t\telse if (!b->x[0] && b->wds <= 1)\n\t\t\t\t\tinexact = 0;\n#endif\n\t\t\t\t*s++ = dig;\n\t\t\t\tgoto ret;\n\t\t\t\t}\n#endif\n\t\t\tif (j < 0 || (j == 0 && mode != 1\n#ifndef ROUND_BIASED\n\t\t\t\t\t\t\t&& !(word1(&u) & 1)\n#endif\n\t\t\t\t\t)) {\n\t\t\t\tif (!b->x[0] && b->wds <= 1) {\n#ifdef SET_INEXACT\n\t\t\t\t\tinexact = 0;\n#endif\n\t\t\t\t\tgoto accept_dig;\n\t\t\t\t\t}\n#ifdef Honor_FLT_ROUNDS\n\t\t\t\tif (mode > 1)\n\t\t\t\t switch(Rounding) {\n\t\t\t\t  case 0: goto accept_dig;\n\t\t\t\t  case 2: goto keep_dig;\n\t\t\t\t  }\n#endif /*Honor_FLT_ROUNDS*/\n\t\t\t\tif (j1 > 0) {\n\t\t\t\t\tb = lshift(C, b, 1);\n\t\t\t\t\tj1 = cmp(C, b, S);\n#ifdef ROUND_BIASED\n\t\t\t\t\tif (j1 >= 0 /*)*/\n#else\n\t\t\t\t\tif ((j1 > 0 || (j1 == 0 && dig & 1))\n#endif\n\t\t\t\t\t&& dig++ == '9')\n\t\t\t\t\t\tgoto round_9_up;\n\t\t\t\t\t}\n accept_dig:\n\t\t\t\t*s++ = dig;\n\t\t\t\tgoto ret;\n\t\t\t\t}\n\t\t\tif (j1 > 0) {\n#ifdef Honor_FLT_ROUNDS\n\t\t\t\tif (!Rounding)\n\t\t\t\t\tgoto accept_dig;\n#endif\n\t\t\t\tif (dig == '9') { /* possible if i == 1 */\n round_9_up:\n\t\t\t\t\t*s++ = '9';\n\t\t\t\t\tgoto roundoff;\n\t\t\t\t\t}\n\t\t\t\t*s++ = dig + 1;\n\t\t\t\tgoto ret;\n\t\t\t\t}\n#ifdef Honor_FLT_ROUNDS\n keep_dig:\n#endif\n\t\t\t*s++ = dig;\n\t\t\tif (i == ilim)\n\t\t\t\tbreak;\n\t\t\tb = multadd(C, b, 10, 0);\n\t\t\tif (mlo == mhi)\n\t\t\t\tmlo = mhi = multadd(C, mhi, 10, 0);\n\t\t\telse {\n\t\t\t\tmlo = multadd(C, mlo, 10, 0);\n\t\t\t\tmhi = multadd(C, mhi, 10, 0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\telse\n\t\tfor(i = 1;; i++) {\n\t\t\t*s++ = dig = quorem(C, b,S) + '0';\n\t\t\tif (!b->x[0] && b->wds <= 1) {\n#ifdef SET_INEXACT\n\t\t\t\tinexact = 0;\n#endif\n\t\t\t\tgoto ret;\n\t\t\t\t}\n\t\t\tif (i >= ilim)\n\t\t\t\tbreak;\n\t\t\tb = multadd(C, b, 10, 0);\n\t\t\t}\n\n\t/* Round off last digit */\n\n#ifdef Honor_FLT_ROUNDS\n\tswitch(Rounding) {\n\t  case 0: goto trimzeros;\n\t  case 2: goto roundoff;\n\t  }\n#endif\n\tb = lshift(C, b, 1);\n\tj = cmp(C, b, S);\n#ifdef ROUND_BIASED\n\tif (j >= 0)\n#else\n\tif (j > 0 || (j == 0 && dig & 1))\n#endif\n\t\t{\n roundoff:\n\t\twhile(*--s == '9')\n\t\t\tif (s == s0) {\n\t\t\t\tk++;\n\t\t\t\t*s++ = '1';\n\t\t\t\tgoto ret;\n\t\t\t\t}\n\t\t++*s++;\n\t\t}\n\telse {\n#ifdef Honor_FLT_ROUNDS\n trimzeros:\n#endif\n\t\twhile(*--s == '0');\n\t\ts++;\n\t\t}\n ret:\n\tBfree(C, S);\n\tif (mhi) {\n\t\tif (mlo && mlo != mhi)\n\t\t\tBfree(C, mlo);\n\t\tBfree(C, mhi);\n\t\t}\n ret1:\n#ifdef SET_INEXACT\n\tif (inexact) {\n\t\tif (!oldinexact) {\n\t\t\tword0(&u) = Exp_1 + (70 << Exp_shift);\n\t\t\tword1(&u) = 0;\n\t\t\tdval(&u) += 1.;\n\t\t\t}\n\t\t}\n\telse if (!oldinexact)\n\t\tclear_inexact();\n#endif\n\tBfree(C, b);\n\t*s = 0;\n\t*decpt = k + 1;\n\tif (rve)\n\t\t*rve = s;\n\treturn s0;\n\t}\n#ifdef __cplusplus\n}\n#endif\n\n\n\n\n\n\n\n\n/****************************************************************\n *\n * The author of this software is David M. Gay.\n *\n * Copyright (c) 1991, 1996 by Lucent Technologies.\n *\n * Permission to use, copy, modify, and distribute this software for any\n * purpose without fee is hereby granted, provided that this entire notice\n * is included in all copies of any software which is or includes a copy\n * or modification of this software and in all copies of the supporting\n * documentation for such software.\n *\n * THIS SOFTWARE IS BEING PROVIDED \"AS IS\", WITHOUT ANY EXPRESS OR IMPLIED\n * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY\n * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY\n * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.\n *\n ***************************************************************/\n\n/* g_fmt(buf,x) stores the closest decimal approximation to x in buf;\n * it suffices to declare buf\n *\tchar buf[32];\n */\n\n char *\n jvp_dtoa_fmt(struct dtoa_context* C, register char *b, double x)\n{\n\tregister int i, k;\n\tregister char *s;\n\tint decpt, j, sign;\n\tchar *b0, *s0, *se;\n\n\tb0 = b;\n#ifdef IGNORE_ZERO_SIGN\n\tif (!x) {\n\t\t*b++ = '0';\n\t\t*b = 0;\n\t\tgoto done;\n\t\t}\n#endif\n\ts = s0 = jvp_dtoa(C, x, 0, 0, &decpt, &sign, &se);\n\tif (sign)\n\t\t*b++ = '-';\n\tif (decpt == 9999) /* Infinity or Nan */ {\n\t\twhile((*b++ = *s++));\n\t\tgoto done0;\n\t\t}\n\tif (decpt <= -4 || decpt > se - s + 15) {\n\t\t*b++ = *s++;\n\t\tif (*s) {\n\t\t\t*b++ = '.';\n\t\t\twhile((*b = *s++))\n\t\t\t\tb++;\n\t\t\t}\n\t\t*b++ = 'e';\n\t\t/* sprintf(b, \"%+.2d\", decpt - 1); */\n\t\tif (--decpt < 0) {\n\t\t\t*b++ = '-';\n\t\t\tdecpt = -decpt;\n\t\t\t}\n\t\telse\n\t\t\t*b++ = '+';\n\t\tfor(j = 2, k = 10; 10*k <= decpt; j++, k *= 10);\n\t\tfor(;;) {\n\t\t\ti = decpt / k;\n\t\t\t*b++ = i + '0';\n\t\t\tif (--j <= 0)\n\t\t\t\tbreak;\n\t\t\tdecpt -= i*k;\n\t\t\tdecpt *= 10;\n\t\t\t}\n\t\t*b = 0;\n\t\t}\n\telse if (decpt <= 0) {\n\t\t*b++ = '0';\n\t\t*b++ = '.';\n\t\tfor(; decpt < 0; decpt++)\n\t\t\t*b++ = '0';\n\t\twhile((*b++ = *s++));\n\t\t}\n\telse {\n\t\twhile((*b = *s++)) {\n\t\t\tb++;\n\t\t\tif (--decpt == 0 && *s)\n\t\t\t\t*b++ = '.';\n\t\t\t}\n\t\tfor(; decpt > 0; decpt--)\n\t\t\t*b++ = '0';\n\t\t*b = 0;\n\t\t}\n done0:\n\tjvp_freedtoa(C, s0);\n        goto done;\n done:\n\treturn b0;\n\t}\n"
  },
  {
    "path": "src/jv_dtoa.h",
    "content": "#ifndef JV_DTOA_H\n#define JV_DTOA_H\n#define Kmax 7\n\nstruct Bigint;\nstruct dtoa_context {\n  struct Bigint *freelist[Kmax+1];\n  struct Bigint *p5s;\n};\n\nvoid jvp_dtoa_context_init(struct dtoa_context* ctx);\nvoid jvp_dtoa_context_free(struct dtoa_context* ctx);\n\ndouble jvp_strtod(struct dtoa_context* C, const char* s, char** se);\n\n\nchar* jvp_dtoa(struct dtoa_context* C, double dd, int mode, int ndigits, int *decpt, int *sign, char **rve);\nvoid jvp_freedtoa(struct dtoa_context* C, char *s);\n\n#define JVP_DTOA_FMT_MAX_LEN 64\nchar* jvp_dtoa_fmt(struct dtoa_context* C, register char *b, double x);\n#endif\n"
  },
  {
    "path": "src/jv_dtoa_tsd.c",
    "content": "#include <stdlib.h>\n#include <stdio.h>\n\n#include \"jv_thread.h\"\n#include \"jv_dtoa_tsd.h\"\n#include \"jv_dtoa.h\"\n#include \"jv_alloc.h\"\n\nstatic pthread_once_t dtoa_ctx_once = PTHREAD_ONCE_INIT;\n\nstatic pthread_key_t dtoa_ctx_key;\nstatic void tsd_dtoa_ctx_dtor(void *ctx) {\n  if (ctx) {\n    jvp_dtoa_context_free((struct dtoa_context *)ctx);\n    jv_mem_free(ctx);\n  }\n}\n\n#ifndef WIN32\nstatic\n#endif\nvoid jv_tsd_dtoa_ctx_fini(void) {\n  struct dtoa_context *ctx = pthread_getspecific(dtoa_ctx_key);\n  tsd_dtoa_ctx_dtor(ctx);\n  pthread_setspecific(dtoa_ctx_key, NULL);\n}\n\n#ifndef WIN32\nstatic\n#endif\nvoid jv_tsd_dtoa_ctx_init(void) {\n  if (pthread_key_create(&dtoa_ctx_key, tsd_dtoa_ctx_dtor) != 0) {\n    fprintf(stderr, \"error: cannot create thread specific key\");\n    abort();\n  }\n  atexit(jv_tsd_dtoa_ctx_fini);\n}\n\ninline struct dtoa_context *tsd_dtoa_context_get(void) {\n  pthread_once(&dtoa_ctx_once, jv_tsd_dtoa_ctx_init); // cannot fail\n  struct dtoa_context *ctx = (struct dtoa_context*)pthread_getspecific(dtoa_ctx_key);\n  if (!ctx) {\n    ctx = jv_mem_alloc(sizeof(struct dtoa_context));\n    jvp_dtoa_context_init(ctx);\n    if (pthread_setspecific(dtoa_ctx_key, ctx) != 0) {\n      jv_mem_free(ctx);\n      fprintf(stderr, \"error: cannot set thread specific data\");\n      abort();\n    }\n  }\n  return ctx;\n}\n"
  },
  {
    "path": "src/jv_dtoa_tsd.h",
    "content": "#ifndef JV_DTOA_TSD_H\n#define JV_DTOA_TSD_H\nstruct dtoa_context *tsd_dtoa_context_get(void);\n#endif\n"
  },
  {
    "path": "src/jv_file.c",
    "content": "#include <sys/stat.h>\n\n#include <errno.h>\n#include <fcntl.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include \"jv.h\"\n#include \"jv_unicode.h\"\n\njv jv_load_file(const char* filename, int raw) {\n  struct stat sb;\n  int fd = open(filename, O_RDONLY);\n  if (fd == -1) {\n    return jv_invalid_with_msg(jv_string_fmt(\"Could not open %s: %s\",\n                                             filename,\n                                             strerror(errno)));\n  }\n  if (fstat(fd, &sb) == -1 || S_ISDIR(sb.st_mode)) {\n    close(fd);\n    return jv_invalid_with_msg(jv_string_fmt(\"Could not open %s: %s\",\n                                             filename,\n                                             \"It's a directory\"));\n  }\n  FILE* file = fdopen(fd, \"r\");\n  struct jv_parser* parser = NULL;\n  jv data;\n  if (!file) {\n    close(fd);\n    return jv_invalid_with_msg(jv_string_fmt(\"Could not open %s: %s\",\n                                             filename,\n                                             strerror(errno)));\n  }\n  if (raw) {\n    data = jv_string(\"\");\n  } else {\n    data = jv_array();\n    parser = jv_parser_new(0);\n  }\n\n  // To avoid mangling UTF-8 multi-byte sequences that cross the end of our read\n  // buffer, we need to be able to read the remainder of a sequence and add that\n  // before appending.\n  char buf[4096 + 4];\n  while (!feof(file) && !ferror(file)) {\n    size_t n = fread(buf, 1, sizeof(buf) - 4, file);\n    if (n == 0)\n      continue;\n\n    char *end = buf + n;\n    int len = 0;\n    if (jvp_utf8_backtrack(end - 1, buf, &len) && len > 0 &&\n        !feof(file) && !ferror(file)) {\n      n += fread(end, 1, len, file);\n    }\n\n    if (raw) {\n      data = jv_string_append_buf(data, buf, n);\n    } else {\n      jv_parser_set_buf(parser, buf, n, !feof(file));\n      jv value;\n      while (jv_is_valid((value = jv_parser_next(parser))))\n        data = jv_array_append(data, value);\n      if (jv_invalid_has_msg(jv_copy(value))) {\n        jv_free(data);\n        data = value;\n        break;\n      }\n      jv_free(value);\n    }\n  }\n  if (!raw)\n      jv_parser_free(parser);\n  int badread = ferror(file);\n  if (fclose(file) != 0 || badread) {\n    jv_free(data);\n    return jv_invalid_with_msg(jv_string_fmt(\"Error reading from %s\",\n                                             filename));\n  }\n  return data;\n}\n"
  },
  {
    "path": "src/jv_parse.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#include \"jv.h\"\n#include \"jv_dtoa.h\"\n#include \"jv_unicode.h\"\n#include \"jv_alloc.h\"\n#include \"jv_dtoa.h\"\n\ntypedef const char* presult;\n\n#ifndef MAX_PARSING_DEPTH\n#define MAX_PARSING_DEPTH (10000)\n#endif\n\n#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)\n#ifdef __GNUC__\n#define pfunc __attribute__((warn_unused_result)) presult\n#else\n#define pfunc presult\n#endif\n\nenum last_seen {\n  JV_LAST_NONE = 0,\n  JV_LAST_OPEN_ARRAY = '[',\n  JV_LAST_OPEN_OBJECT = '{',\n  JV_LAST_COLON = ':',\n  JV_LAST_COMMA = ',',\n  JV_LAST_VALUE = 'V',\n};\n\nstruct jv_parser {\n  const char* curr_buf;\n  int curr_buf_length;\n  int curr_buf_pos;\n  int curr_buf_is_partial;\n  int eof;\n  unsigned bom_strip_position;\n\n  int flags;\n\n  jv* stack;                   // parser\n  int stackpos;                // parser\n  int stacklen;                // both (optimization; it's really pathlen for streaming)\n  jv path;                     // streamer\n  enum last_seen last_seen;    // streamer\n  jv output;                   // streamer\n  jv next;                     // both\n\n  char* tokenbuf;\n  int tokenpos;\n  int tokenlen;\n\n  int line, column;\n\n  struct dtoa_context dtoa;\n\n  enum {\n    JV_PARSER_NORMAL,\n    JV_PARSER_STRING,\n    JV_PARSER_STRING_ESCAPE,\n    JV_PARSER_WAITING_FOR_RS // parse error, waiting for RS\n  } st;\n  unsigned int last_ch_was_ws:1;\n};\n\n\nstatic void parser_init(struct jv_parser* p, int flags) {\n  p->flags = flags;\n  if ((p->flags & JV_PARSE_STREAMING)) {\n    p->path = jv_array();\n  } else {\n    p->path = jv_invalid();\n    p->flags &= ~(JV_PARSE_STREAM_ERRORS);\n  }\n  p->stack = 0;\n  p->stacklen = p->stackpos = 0;\n  p->last_seen = JV_LAST_NONE;\n  p->output = jv_invalid();\n  p->next = jv_invalid();\n  p->tokenlen = 256;\n  p->tokenbuf = jv_mem_alloc(p->tokenlen);\n  p->tokenpos = 0;\n  if ((p->flags & JV_PARSE_SEQ))\n    p->st = JV_PARSER_WAITING_FOR_RS;\n  else\n    p->st = JV_PARSER_NORMAL;\n  p->eof = 0;\n  p->curr_buf = 0;\n  p->curr_buf_length = p->curr_buf_pos = p->curr_buf_is_partial = 0;\n  p->bom_strip_position = 0;\n  p->last_ch_was_ws = 0;\n  p->line = 1;\n  p->column = 0;\n  jvp_dtoa_context_init(&p->dtoa);\n}\n\nstatic void parser_reset(struct jv_parser* p) {\n  if ((p->flags & JV_PARSE_STREAMING)) {\n    jv_free(p->path);\n    p->path = jv_array();\n    p->stacklen = 0;\n  }\n  p->last_seen = JV_LAST_NONE;\n  jv_free(p->output);\n  p->output = jv_invalid();\n  jv_free(p->next);\n  p->next = jv_invalid();\n  for (int i=0; i<p->stackpos; i++)\n    jv_free(p->stack[i]);\n  p->stackpos = 0;\n  p->tokenpos = 0;\n  p->st = JV_PARSER_NORMAL;\n}\n\nstatic void parser_free(struct jv_parser* p) {\n  parser_reset(p);\n  jv_free(p->path);\n  jv_free(p->output);\n  jv_mem_free(p->stack);\n  jv_mem_free(p->tokenbuf);\n  jvp_dtoa_context_free(&p->dtoa);\n}\n\nstatic pfunc value(struct jv_parser* p, jv val) {\n  if ((p->flags & JV_PARSE_STREAMING)) {\n    if (jv_is_valid(p->next) || p->last_seen == JV_LAST_VALUE) {\n      jv_free(val);\n      return \"Expected separator between values\";\n    }\n    if (p->stacklen > 0)\n      p->last_seen = JV_LAST_VALUE;\n    else\n      p->last_seen = JV_LAST_NONE;\n  } else {\n    if (jv_is_valid(p->next)) {\n      jv_free(val);\n      return \"Expected separator between values\";\n    }\n  }\n  jv_free(p->next);\n  p->next = val;\n  return 0;\n}\n\nstatic void push(struct jv_parser* p, jv v) {\n  assert(p->stackpos <= p->stacklen);\n  if (p->stackpos == p->stacklen) {\n    p->stacklen = p->stacklen * 2 + 10;\n    p->stack = jv_mem_realloc(p->stack, p->stacklen * sizeof(jv));\n  }\n  assert(p->stackpos < p->stacklen);\n  p->stack[p->stackpos++] = v;\n}\n\nstatic pfunc parse_token(struct jv_parser* p, char ch) {\n  switch (ch) {\n  case '[':\n    if (p->stackpos >= MAX_PARSING_DEPTH) return \"Exceeds depth limit for parsing\";\n    if (jv_is_valid(p->next)) return \"Expected separator between values\";\n    push(p, jv_array());\n    break;\n\n  case '{':\n    if (p->stackpos >= MAX_PARSING_DEPTH) return \"Exceeds depth limit for parsing\";\n    if (jv_is_valid(p->next)) return \"Expected separator between values\";\n    push(p, jv_object());\n    break;\n\n  case ':':\n    if (!jv_is_valid(p->next))\n      return \"Expected string key before ':'\";\n    if (p->stackpos == 0 || jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_OBJECT)\n      return \"':' not as part of an object\";\n    if (jv_get_kind(p->next) != JV_KIND_STRING)\n      return \"Object keys must be strings\";\n    push(p, p->next);\n    p->next = jv_invalid();\n    break;\n\n  case ',':\n    if (!jv_is_valid(p->next))\n      return \"Expected value before ','\";\n    if (p->stackpos == 0)\n      return \"',' not as part of an object or array\";\n    if (jv_get_kind(p->stack[p->stackpos-1]) == JV_KIND_ARRAY) {\n      p->stack[p->stackpos-1] = jv_array_append(p->stack[p->stackpos-1], p->next);\n      p->next = jv_invalid();\n    } else if (jv_get_kind(p->stack[p->stackpos-1]) == JV_KIND_STRING) {\n      assert(p->stackpos > 1 && jv_get_kind(p->stack[p->stackpos-2]) == JV_KIND_OBJECT);\n      p->stack[p->stackpos-2] = jv_object_set(p->stack[p->stackpos-2],\n                                              p->stack[p->stackpos-1], p->next);\n      p->stackpos--;\n      p->next = jv_invalid();\n    } else {\n      // this case hits on input like {\"a\", \"b\"}\n      return \"Objects must consist of key:value pairs\";\n    }\n    break;\n\n  case ']':\n    if (p->stackpos == 0 || jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_ARRAY)\n      return \"Unmatched ']'\";\n    if (jv_is_valid(p->next)) {\n      p->stack[p->stackpos-1] = jv_array_append(p->stack[p->stackpos-1], p->next);\n      p->next = jv_invalid();\n    } else {\n      if (jv_array_length(jv_copy(p->stack[p->stackpos-1])) != 0) {\n        // this case hits on input like [1,2,3,]\n        return \"Expected another array element\";\n      }\n    }\n    jv_free(p->next);\n    p->next = p->stack[--p->stackpos];\n    break;\n\n  case '}':\n    if (p->stackpos == 0)\n      return \"Unmatched '}'\";\n    if (jv_is_valid(p->next)) {\n      if (jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_STRING)\n        return \"Objects must consist of key:value pairs\";\n      assert(p->stackpos > 1 && jv_get_kind(p->stack[p->stackpos-2]) == JV_KIND_OBJECT);\n      p->stack[p->stackpos-2] = jv_object_set(p->stack[p->stackpos-2],\n                                              p->stack[p->stackpos-1], p->next);\n      p->stackpos--;\n      p->next = jv_invalid();\n    } else {\n      if (jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_OBJECT)\n        return \"Unmatched '}'\";\n      if (jv_object_length(jv_copy(p->stack[p->stackpos-1])) != 0)\n        return \"Expected another key-value pair\";\n    }\n    jv_free(p->next);\n    p->next = p->stack[--p->stackpos];\n    break;\n  }\n  return 0;\n}\n\nstatic pfunc stream_token(struct jv_parser* p, char ch) {\n  jv_kind k;\n  jv last;\n\n  switch (ch) {\n  case '[':\n    if (jv_is_valid(p->next))\n      return \"Expected a separator between values\";\n    if (p->last_seen == JV_LAST_OPEN_OBJECT)\n      // Looks like {[\"foo\"]}\n      return \"Expected string key after '{', not '['\";\n    if (p->last_seen == JV_LAST_COMMA) {\n      last = jv_array_get(jv_copy(p->path), p->stacklen - 1);\n      k = jv_get_kind(last);\n      jv_free(last);\n      if (k != JV_KIND_NUMBER)\n        // Looks like {\"x\":\"y\",[\"foo\"]}\n        return \"Expected string key after ',' in object, not '['\";\n    }\n    p->path = jv_array_append(p->path, jv_number(0)); // push\n    p->last_seen = JV_LAST_OPEN_ARRAY;\n    p->stacklen++;\n    break;\n\n  case '{':\n    if (p->last_seen == JV_LAST_VALUE)\n      return \"Expected a separator between values\";\n    if (p->last_seen == JV_LAST_OPEN_OBJECT)\n      // Looks like {{\"foo\":\"bar\"}}\n      return \"Expected string key after '{', not '{'\";\n    if (p->last_seen == JV_LAST_COMMA) {\n      last = jv_array_get(jv_copy(p->path), p->stacklen - 1);\n      k = jv_get_kind(last);\n      jv_free(last);\n      if (k != JV_KIND_NUMBER)\n        // Looks like {\"x\":\"y\",{\"foo\":\"bar\"}}\n        return \"Expected string key after ',' in object, not '{'\";\n    }\n    // Push object key: null, since we don't know it yet\n    p->path = jv_array_append(p->path, jv_null()); // push\n    p->last_seen = JV_LAST_OPEN_OBJECT;\n    p->stacklen++;\n    break;\n\n  case ':':\n    last = jv_invalid();\n    if (p->stacklen == 0 || jv_get_kind(last = jv_array_get(jv_copy(p->path), p->stacklen - 1)) == JV_KIND_NUMBER) {\n      jv_free(last);\n      return \"':' not as part of an object\";\n    }\n    jv_free(last);\n    if (!jv_is_valid(p->next) || p->last_seen == JV_LAST_NONE)\n      return \"Expected string key before ':'\";\n    if (jv_get_kind(p->next) != JV_KIND_STRING)\n      return \"Object keys must be strings\";\n    if (p->last_seen != JV_LAST_VALUE)\n      return \"':' should follow a key\";\n    p->last_seen = JV_LAST_COLON;\n    p->path = jv_array_set(p->path, p->stacklen - 1, p->next);\n    p->next = jv_invalid();\n    break;\n\n  case ',':\n    if (p->last_seen != JV_LAST_VALUE)\n      return \"Expected value before ','\";\n    if (p->stacklen == 0)\n      return \"',' not as part of an object or array\";\n    last = jv_array_get(jv_copy(p->path), p->stacklen - 1);\n    k = jv_get_kind(last);\n    if (k == JV_KIND_NUMBER) {\n      int idx = jv_number_value(last);\n\n      if (jv_is_valid(p->next)) {\n        p->output = JV_ARRAY(jv_copy(p->path), p->next);\n        p->next = jv_invalid();\n      }\n      p->path = jv_array_set(p->path, p->stacklen - 1, jv_number(idx + 1));\n      p->last_seen = JV_LAST_COMMA;\n    } else if (k == JV_KIND_STRING) {\n      if (jv_is_valid(p->next)) {\n        p->output = JV_ARRAY(jv_copy(p->path), p->next);\n        p->next = jv_invalid();\n      }\n      p->path = jv_array_set(p->path, p->stacklen - 1, jv_null()); // ready for another key:value pair\n      p->last_seen = JV_LAST_COMMA;\n    } else {\n      assert(k == JV_KIND_NULL);\n      // this case hits on input like {,}\n      // make sure to handle input like {\"a\", \"b\"} and {\"a\":, ...}\n      jv_free(last);\n      return \"Objects must consist of key:value pairs\";\n    }\n    jv_free(last);\n    break;\n\n  case ']':\n    if (p->stacklen == 0)\n      return \"Unmatched ']' at the top-level\";\n    if (p->last_seen == JV_LAST_COMMA)\n      return \"Expected another array element\";\n    if (p->last_seen == JV_LAST_OPEN_ARRAY)\n      assert(!jv_is_valid(p->next));\n\n    last = jv_array_get(jv_copy(p->path), p->stacklen - 1);\n    k = jv_get_kind(last);\n    jv_free(last);\n\n    if (k != JV_KIND_NUMBER)\n      return \"Unmatched ']' in the middle of an object\";\n    if (jv_is_valid(p->next)) {\n      p->output = JV_ARRAY(jv_copy(p->path), p->next, jv_true());\n      p->next = jv_invalid();\n    } else if (p->last_seen != JV_LAST_OPEN_ARRAY) {\n      p->output = JV_ARRAY(jv_copy(p->path));\n    }\n\n    p->path = jv_array_slice(p->path, 0, --(p->stacklen)); // pop\n    //assert(!jv_is_valid(p->next));\n    jv_free(p->next);\n    p->next = jv_invalid();\n\n    if (p->last_seen == JV_LAST_OPEN_ARRAY)\n      p->output = JV_ARRAY(jv_copy(p->path), jv_array()); // Empty arrays are leaves\n\n    if (p->stacklen == 0)\n      p->last_seen = JV_LAST_NONE;\n    else\n      p->last_seen = JV_LAST_VALUE;\n    break;\n\n  case '}':\n    if (p->stacklen == 0)\n      return \"Unmatched '}' at the top-level\";\n    if (p->last_seen == JV_LAST_COMMA)\n      return \"Expected another key:value pair\";\n    if (p->last_seen == JV_LAST_OPEN_OBJECT)\n      assert(!jv_is_valid(p->next));\n\n    last = jv_array_get(jv_copy(p->path), p->stacklen - 1);\n    k = jv_get_kind(last);\n    jv_free(last);\n    if (k == JV_KIND_NUMBER)\n      return \"Unmatched '}' in the middle of an array\";\n\n    if (jv_is_valid(p->next)) {\n      if (k != JV_KIND_STRING)\n        return \"Objects must consist of key:value pairs\";\n      p->output = JV_ARRAY(jv_copy(p->path), p->next, jv_true());\n      p->next = jv_invalid();\n    } else {\n      // Perhaps {\"a\":[]}\n      if (p->last_seen == JV_LAST_COLON)\n        // Looks like {\"a\":}\n        return \"Missing value in key:value pair\";\n      if (p->last_seen == JV_LAST_COMMA)\n        // Looks like {\"a\":0,}\n        return \"Expected another key-value pair\";\n      if (p->last_seen == JV_LAST_OPEN_ARRAY)\n        return \"Unmatched '}' in the middle of an array\";\n      if (p->last_seen != JV_LAST_VALUE && p->last_seen != JV_LAST_OPEN_OBJECT)\n        return \"Unmatched '}'\";\n      if (p->last_seen != JV_LAST_OPEN_OBJECT)\n        p->output = JV_ARRAY(jv_copy(p->path));\n    }\n    p->path = jv_array_slice(p->path, 0, --(p->stacklen)); // pop\n    jv_free(p->next);\n    p->next = jv_invalid();\n\n    if (p->last_seen == JV_LAST_OPEN_OBJECT)\n      p->output = JV_ARRAY(jv_copy(p->path), jv_object()); // Empty arrays are leaves\n\n    if (p->stacklen == 0)\n      p->last_seen = JV_LAST_NONE;\n    else\n      p->last_seen = JV_LAST_VALUE;\n    break;\n  }\n  return 0;\n}\n\nstatic void tokenadd(struct jv_parser* p, char c) {\n  assert(p->tokenpos <= p->tokenlen);\n  if (p->tokenpos >= (p->tokenlen - 1)) {\n    p->tokenlen = p->tokenlen*2 + 256;\n    p->tokenbuf = jv_mem_realloc(p->tokenbuf, p->tokenlen);\n  }\n  assert(p->tokenpos < p->tokenlen);\n  p->tokenbuf[p->tokenpos++] = c;\n}\n\nstatic int unhex4(char* hex) {\n  int r = 0;\n  for (int i=0; i<4; i++) {\n    char c = *hex++;\n    int n;\n    if ('0' <= c && c <= '9') n = c - '0';\n    else if ('a' <= c && c <= 'f') n = c - 'a' + 10;\n    else if ('A' <= c && c <= 'F') n = c - 'A' + 10;\n    else return -1;\n    r <<= 4;\n    r |= n;\n  }\n  return r;\n}\n\nstatic pfunc found_string(struct jv_parser* p) {\n  char* in = p->tokenbuf;\n  char* out = p->tokenbuf;\n  char* end = p->tokenbuf + p->tokenpos;\n\n  while (in < end) {\n    char c = *in++;\n    if (c == '\\\\') {\n      if (in >= end)\n        return \"Expected escape character at end of string\";\n      c = *in++;\n      switch (c) {\n      case '\\\\':\n      case '\"':\n      case '/': *out++ = c;    break;\n      case 'b': *out++ = '\\b'; break;\n      case 'f': *out++ = '\\f'; break;\n      case 't': *out++ = '\\t'; break;\n      case 'n': *out++ = '\\n'; break;\n      case 'r': *out++ = '\\r'; break;\n\n      case 'u':\n        /* ahh, the complicated case */\n        if (in + 4 > end)\n          return \"Invalid \\\\uXXXX escape\";\n        int hexvalue = unhex4(in);\n        if (hexvalue < 0)\n          return \"Invalid characters in \\\\uXXXX escape\";\n        unsigned long codepoint = (unsigned long)hexvalue;\n        in += 4;\n        if (0xD800 <= codepoint && codepoint <= 0xDBFF) {\n          /* who thought UTF-16 surrogate pairs were a good idea? */\n          if (in + 6 > end || in[0] != '\\\\' || in[1] != 'u')\n            return \"Invalid \\\\uXXXX\\\\uXXXX surrogate pair escape\";\n          unsigned long surrogate = unhex4(in+2);\n          if (!(0xDC00 <= surrogate && surrogate <= 0xDFFF))\n            return \"Invalid \\\\uXXXX\\\\uXXXX surrogate pair escape\";\n          in += 6;\n          codepoint = 0x10000 + (((codepoint - 0xD800) << 10)\n                                 |(surrogate - 0xDC00));\n        }\n        if (codepoint > 0x10FFFF)\n          codepoint = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER\n        out += jvp_utf8_encode(codepoint, out);\n        break;\n\n      default:\n        return \"Invalid escape\";\n      }\n    } else {\n      if (!(c & ~0x1F))\n        return \"Invalid string: control characters from U+0000 through U+001F must be escaped\";\n      *out++ = c;\n    }\n  }\n  TRY(value(p, jv_string_sized(p->tokenbuf, out - p->tokenbuf)));\n  p->tokenpos = 0;\n  return 0;\n}\n\nstatic pfunc check_literal(struct jv_parser* p) {\n  if (p->tokenpos == 0) return 0;\n\n  const char* pattern = 0;\n  int plen;\n  jv v;\n  switch (p->tokenbuf[0]) {\n  case 't': pattern = \"true\"; plen = 4; v = jv_true(); break;\n  case 'f': pattern = \"false\"; plen = 5; v = jv_false(); break;\n  case '\\'':\n    return \"Invalid string literal; expected \\\", but got '\";\n  case 'n':\n    // if it starts with 'n', it could be a literal \"nan\"\n    if (p->tokenpos > 1 && p->tokenbuf[1] == 'u') {\n      pattern = \"null\"; plen = 4; v = jv_null();\n    }\n  }\n  if (pattern) {\n    if (p->tokenpos != plen) return \"Invalid literal\";\n    for (int i=0; i<plen; i++)\n      if (p->tokenbuf[i] != pattern[i])\n        return \"Invalid literal\";\n    TRY(value(p, v));\n  } else {\n    // FIXME: better parser\n    p->tokenbuf[p->tokenpos] = 0;\n#ifdef USE_DECNUM\n    jv number = jv_number_with_literal(p->tokenbuf);\n    if (jv_get_kind(number) == JV_KIND_INVALID) {\n      return \"Invalid numeric literal\";\n    }\n    TRY(value(p, number));\n#else\n    char *end = 0;\n    double d = jvp_strtod(&p->dtoa, p->tokenbuf, &end);\n    if (end == 0 || *end != 0) {\n      return \"Invalid numeric literal\";\n    }\n    TRY(value(p, jv_number(d)));\n#endif\n  }\n  p->tokenpos = 0;\n  return 0;\n}\n\ntypedef enum {\n  LITERAL,\n  WHITESPACE,\n  STRUCTURE,\n  QUOTE,\n  INVALID\n} chclass;\n\nstatic chclass classify(char c) {\n  switch (c) {\n  case ' ':\n  case '\\t':\n  case '\\r':\n  case '\\n':\n    return WHITESPACE;\n  case '\"':\n    return QUOTE;\n  case '[':\n  case ',':\n  case ']':\n  case '{':\n  case ':':\n  case '}':\n    return STRUCTURE;\n  default:\n    return LITERAL;\n  }\n}\n\n\nstatic const presult OK = \"output produced\";\n\nstatic int parse_check_done(struct jv_parser* p, jv* out) {\n  if (p->stackpos == 0 && jv_is_valid(p->next)) {\n    *out = p->next;\n    p->next = jv_invalid();\n    return 1;\n  } else {\n    return 0;\n  }\n}\n\nstatic int stream_check_done(struct jv_parser* p, jv* out) {\n  if (p->stacklen == 0 && jv_is_valid(p->next)) {\n    *out = JV_ARRAY(jv_copy(p->path),p->next);\n    p->next = jv_invalid();\n    return 1;\n  } else if (jv_is_valid(p->output)) {\n    if (jv_array_length(jv_copy(p->output)) > 2) {\n      // At end of an array or object, necessitating one more output by\n      // which to indicate this\n      *out = jv_array_slice(jv_copy(p->output), 0, 2);\n      p->output = jv_array_slice(p->output, 0, 1);      // arrange one more output\n    } else {\n      // No further processing needed\n      *out = p->output;\n      p->output = jv_invalid();\n    }\n    return 1;\n  } else {\n    return 0;\n  }\n}\n\nstatic int seq_check_truncation(struct jv_parser* p) {\n  return (!p->last_ch_was_ws && (p->stackpos > 0 || p->tokenpos > 0 || jv_get_kind(p->next) == JV_KIND_NUMBER));\n}\n\nstatic int stream_seq_check_truncation(struct jv_parser* p) {\n  jv_kind k = jv_get_kind(p->next);\n  return (p->stacklen > 0 || k == JV_KIND_NUMBER || k == JV_KIND_TRUE || k == JV_KIND_FALSE || k == JV_KIND_NULL);\n}\n\nstatic int parse_is_top_num(struct jv_parser* p) {\n  return (p->stackpos == 0 && jv_get_kind(p->next) == JV_KIND_NUMBER);\n}\n\nstatic int stream_is_top_num(struct jv_parser* p) {\n  return (p->stacklen == 0 && jv_get_kind(p->next) == JV_KIND_NUMBER);\n}\n\n#define check_done(p, o) \\\n   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))\n\n#define token(p, ch) \\\n   (((p)->flags & JV_PARSE_STREAMING) ? stream_token((p), (ch)) : parse_token((p), (ch)))\n\n#define check_truncation(p) \\\n   (((p)->flags & JV_PARSE_STREAMING) ? stream_seq_check_truncation((p)) : seq_check_truncation((p)))\n\n#define is_top_num(p) \\\n   (((p)->flags & JV_PARSE_STREAMING) ? stream_is_top_num((p)) : parse_is_top_num((p)))\n\nstatic pfunc scan(struct jv_parser* p, char ch, jv* out) {\n  p->column++;\n  if (ch == '\\n') {\n    p->line++;\n    p->column = 0;\n  }\n  if ((p->flags & JV_PARSE_SEQ)\n      && ch == '\\036' /* ASCII RS; see draft-ietf-json-sequence-07 */) {\n    if (check_truncation(p)) {\n      if (check_literal(p) == 0 && is_top_num(p))\n        return \"Potentially truncated top-level numeric value\";\n      return \"Truncated value\";\n    }\n    TRY(check_literal(p));\n    if (p->st == JV_PARSER_NORMAL && check_done(p, out))\n      return OK;\n    // shouldn't happen?\n    assert(!jv_is_valid(*out));\n    parser_reset(p);\n    jv_free(*out);\n    *out = jv_invalid();\n    return OK;\n  }\n  presult answer = 0;\n  p->last_ch_was_ws = 0;\n  if (p->st == JV_PARSER_NORMAL) {\n    chclass cls = classify(ch);\n    if (cls == WHITESPACE)\n      p->last_ch_was_ws = 1;\n    if (cls != LITERAL) {\n      TRY(check_literal(p));\n      if (check_done(p, out)) answer = OK;\n    }\n    switch (cls) {\n    case LITERAL:\n      tokenadd(p, ch);\n      break;\n    case WHITESPACE:\n      break;\n    case QUOTE:\n      p->st = JV_PARSER_STRING;\n      break;\n    case STRUCTURE:\n      TRY(token(p, ch));\n      break;\n    case INVALID:\n      return \"Invalid character\";\n    }\n    if (check_done(p, out)) answer = OK;\n  } else {\n    if (ch == '\"' && p->st == JV_PARSER_STRING) {\n      TRY(found_string(p));\n      p->st = JV_PARSER_NORMAL;\n      if (check_done(p, out)) answer = OK;\n    } else {\n      tokenadd(p, ch);\n      if (ch == '\\\\' && p->st == JV_PARSER_STRING) {\n        p->st = JV_PARSER_STRING_ESCAPE;\n      } else {\n        p->st = JV_PARSER_STRING;\n      }\n    }\n  }\n  return answer;\n}\n\nstruct jv_parser* jv_parser_new(int flags) {\n  struct jv_parser* p = jv_mem_alloc(sizeof(struct jv_parser));\n  parser_init(p, flags);\n  p->flags = flags;\n  return p;\n}\n\nvoid jv_parser_free(struct jv_parser* p) {\n  parser_free(p);\n  jv_mem_free(p);\n}\n\nstatic const unsigned char UTF8_BOM[] = {0xEF,0xBB,0xBF};\n\nint jv_parser_remaining(struct jv_parser* p) {\n  if (p->curr_buf == 0)\n    return 0;\n  return (p->curr_buf_length - p->curr_buf_pos);\n}\n\nvoid jv_parser_set_buf(struct jv_parser* p, const char* buf, int length, int is_partial) {\n  assert((p->curr_buf == 0 || p->curr_buf_pos == p->curr_buf_length)\n         && \"previous buffer not exhausted\");\n  while (length > 0 && p->bom_strip_position < sizeof(UTF8_BOM)) {\n    if ((unsigned char)*buf == UTF8_BOM[p->bom_strip_position]) {\n      // matched a BOM character\n      buf++;\n      length--;\n      p->bom_strip_position++;\n    } else {\n      if (p->bom_strip_position == 0) {\n        // no BOM in this document\n        p->bom_strip_position = sizeof(UTF8_BOM);\n      } else {\n        // malformed BOM (prefix present, rest missing)\n        p->bom_strip_position = 0xff;\n      }\n    }\n  }\n  p->curr_buf = buf;\n  p->curr_buf_length = length;\n  p->curr_buf_pos = 0;\n  p->curr_buf_is_partial = is_partial;\n}\n\nstatic jv make_error(struct jv_parser*, const char *, ...) JV_PRINTF_LIKE(2, 3);\n\nstatic jv make_error(struct jv_parser* p, const char *fmt, ...) {\n  va_list ap;\n  va_start(ap, fmt);\n  jv e = jv_string_vfmt(fmt, ap);\n  va_end(ap);\n  if ((p->flags & JV_PARSE_STREAM_ERRORS))\n    return JV_ARRAY(e, jv_copy(p->path));\n  return jv_invalid_with_msg(e);\n}\n\njv jv_parser_next(struct jv_parser* p) {\n  if (p->eof)\n    return jv_invalid();\n  if (!p->curr_buf)\n    return jv_invalid(); // Need a buffer\n  if (p->bom_strip_position == 0xff) {\n    if (!(p->flags & JV_PARSE_SEQ))\n      return jv_invalid_with_msg(jv_string(\"Malformed BOM\"));\n    p->st =JV_PARSER_WAITING_FOR_RS;\n    parser_reset(p);\n  }\n  jv value = jv_invalid();\n  if ((p->flags & JV_PARSE_STREAMING) && stream_check_done(p, &value))\n    return value;\n  char ch;\n  presult msg = 0;\n  while (!msg && p->curr_buf_pos < p->curr_buf_length) {\n    ch = p->curr_buf[p->curr_buf_pos++];\n    if (p->st == JV_PARSER_WAITING_FOR_RS) {\n      if (ch == '\\n') {\n        p->line++;\n        p->column = 0;\n      } else {\n        p->column++;\n      }\n      if (ch == '\\036')\n        p->st = JV_PARSER_NORMAL;\n      continue; // need to resync, wait for RS\n    }\n    msg = scan(p, ch, &value);\n  }\n  if (msg == OK) {\n    return value;\n  } else if (msg) {\n    jv_free(value);\n    if (ch != '\\036' && (p->flags & JV_PARSE_SEQ)) {\n      // Skip to the next RS\n      p->st = JV_PARSER_WAITING_FOR_RS;\n      value = make_error(p, \"%s at line %d, column %d (need RS to resync)\", msg, p->line, p->column);\n      parser_reset(p);\n      return value;\n    }\n    value = make_error(p, \"%s at line %d, column %d\", msg, p->line, p->column);\n    parser_reset(p);\n    if (!(p->flags & JV_PARSE_SEQ)) {\n      // We're not parsing a JSON text sequence; throw this buffer away.\n      // XXX We should fail permanently here.\n      p->curr_buf = 0;\n      p->curr_buf_pos = 0;\n    } // Else ch must be RS; don't clear buf so we can start parsing again after this ch\n    return value;\n  } else if (p->curr_buf_is_partial) {\n    assert(p->curr_buf_pos == p->curr_buf_length);\n    // need another buffer\n    return jv_invalid();\n  } else {\n    // at EOF\n    p->eof = 1;\n    assert(p->curr_buf_pos == p->curr_buf_length);\n    jv_free(value);\n    if (p->st == JV_PARSER_WAITING_FOR_RS)\n      return make_error(p, \"Unfinished abandoned text at EOF at line %d, column %d\", p->line, p->column);\n    if (p->st != JV_PARSER_NORMAL) {\n      value = make_error(p, \"Unfinished string at EOF at line %d, column %d\", p->line, p->column);\n      parser_reset(p);\n      p->st = JV_PARSER_WAITING_FOR_RS;\n      return value;\n    }\n    if ((msg = check_literal(p))) {\n      value = make_error(p, \"%s at EOF at line %d, column %d\", msg, p->line, p->column);\n      parser_reset(p);\n      p->st = JV_PARSER_WAITING_FOR_RS;\n      return value;\n    }\n    if (((p->flags & JV_PARSE_STREAMING) && p->stacklen != 0) ||\n        (!(p->flags & JV_PARSE_STREAMING) && p->stackpos != 0)) {\n      value = make_error(p, \"Unfinished JSON term at EOF at line %d, column %d\", p->line, p->column);\n      parser_reset(p);\n      p->st = JV_PARSER_WAITING_FOR_RS;\n      return value;\n    }\n    // p->next is either invalid (nothing here, but no syntax error)\n    // or valid (this is the value). either way it's the thing to return\n    if ((p->flags & JV_PARSE_STREAMING) && jv_is_valid(p->next)) {\n      value = JV_ARRAY(jv_copy(p->path), p->next); // except in streaming mode we've got to make it [path,value]\n    } else {\n      value = p->next;\n    }\n    p->next = jv_invalid();\n    if ((p->flags & JV_PARSE_SEQ) && !p->last_ch_was_ws && jv_get_kind(value) == JV_KIND_NUMBER) {\n      jv_free(value);\n      return make_error(p, \"Potentially truncated top-level numeric value at EOF at line %d, column %d\", p->line, p->column);\n    }\n    return value;\n  }\n}\n\njv jv_parse_sized_custom_flags(const char* string, int length, int flags) {\n  struct jv_parser parser;\n  parser_init(&parser, flags);\n  jv_parser_set_buf(&parser, string, length, 0);\n  jv value = jv_parser_next(&parser);\n  if (jv_is_valid(value)) {\n    jv next = jv_parser_next(&parser);\n    if (jv_is_valid(next)) {\n      // multiple JSON values, we only wanted one\n      jv_free(value);\n      jv_free(next);\n      value = jv_invalid_with_msg(jv_string(\"Unexpected extra JSON values\"));\n    } else if (jv_invalid_has_msg(jv_copy(next))) {\n      // parser error after the first JSON value\n      jv_free(value);\n      value = next;\n    } else {\n      // a single valid JSON value\n      jv_free(next);\n    }\n  } else if (jv_invalid_has_msg(jv_copy(value))) {\n    // parse error, we'll return it\n  } else {\n    // no value at all\n    jv_free(value);\n    value = jv_invalid_with_msg(jv_string(\"Expected JSON value\"));\n  }\n  parser_free(&parser);\n\n  if (!jv_is_valid(value) && jv_invalid_has_msg(jv_copy(value))) {\n    jv msg = jv_invalid_get_msg(value);\n    value = jv_invalid_with_msg(jv_string_fmt(\"%s (while parsing '%s')\",\n                                              jv_string_value(msg),\n                                              string));\n    jv_free(msg);\n  }\n  return value;\n}\n\njv jv_parse_sized(const char* string, int length) {\n  return jv_parse_sized_custom_flags(string, length, 0);\n}\n\njv jv_parse(const char* string) {\n  return jv_parse_sized(string, strlen(string));\n}\n\njv jv_parse_custom_flags(const char* string, int flags) {\n  return jv_parse_sized_custom_flags(string, strlen(string), flags);\n}\n"
  },
  {
    "path": "src/jv_print.c",
    "content": "#include <assert.h>\n#include <stdio.h>\n#include <float.h>\n#include <string.h>\n\n#ifdef WIN32\n#include <windows.h>\n#include <io.h>\n#include <fileapi.h>\n#endif\n\n#include \"jv.h\"\n#include \"jv_dtoa.h\"\n#include \"jv_dtoa_tsd.h\"\n#include \"jv_unicode.h\"\n#include \"jv_alloc.h\"\n#include \"jv_private.h\"\n#include \"util.h\"\n\n#ifndef MAX_PRINT_DEPTH\n#define MAX_PRINT_DEPTH (10000)\n#endif\n\n#define ESC \"\\033\"\n#define COL(c) (ESC \"[\" c \"m\")\n#define COLRESET (ESC \"[0m\")\n\n// Color table. See https://en.wikipedia.org/wiki/ANSI_escape_code#Colors\n// for how to choose these. The order is same as jv_kind definition, and\n// the last color is used for object keys.\n#define DEFAULT_COLORS \\\n  {COL(\"0;90\"),    COL(\"0;39\"),      COL(\"0;39\"),     COL(\"0;39\"),\\\n   COL(\"0;32\"),    COL(\"1;39\"),      COL(\"1;39\"),     COL(\"1;34\")};\nstatic const char *const default_colors[] = DEFAULT_COLORS;\nstatic const char *colors[] = DEFAULT_COLORS;\n#define COLORS_LEN (sizeof(colors) / sizeof(colors[0]))\n#define FIELD_COLOR (colors[7])\n\nstatic char *colors_buf = NULL;\nint jq_set_colors(const char *code_str) {\n  if (code_str == NULL)\n    return 1;\n\n  // the start of each color code in the env var, and the byte after the end of the last one\n  const char *codes[COLORS_LEN + 1];\n  size_t num_colors;\n  // must be initialized before `goto default_colors`, used later to loop over every color\n  size_t ci = 0;\n\n  for (num_colors = 0;; num_colors++) {\n    codes[num_colors] = code_str;\n    code_str += strspn(code_str, \"0123456789;\");\n    if (code_str[0] == '\\0' || num_colors + 1 >= COLORS_LEN) {\n      break;\n    } else if (code_str[0] != ':') {\n      return 0; // invalid character\n    }\n    code_str++;\n  }\n  if (codes[num_colors] != code_str) {\n    // count the last color and store its end (plus one byte for consistency with starts)\n    // an empty last color would be ignored (for cases like \"\" and \"0:\")\n    num_colors++;\n    codes[num_colors] = code_str + 1;\n  } else if (num_colors == 0) {\n    if (colors_buf != NULL) {\n      jv_mem_free(colors_buf);\n      colors_buf = NULL;\n    }\n    goto default_colors;\n  }\n\n  colors_buf = jv_mem_realloc(\n    colors_buf,\n    // add ESC '[' 'm' to each string\n    // '\\0' is already included in difference of codes\n    codes[num_colors] - codes[0] + 3 * num_colors\n  );\n  char *cb = colors_buf;\n  for (; ci < num_colors; ci++) {\n    colors[ci] = cb;\n    size_t len = codes[ci + 1] - 1 - codes[ci];\n\n    cb[0] = ESC[0];\n    cb[1] = '[';\n    memcpy(cb + 2, codes[ci], len);\n    cb[2 + len] = 'm';\n    cb[3 + len] = '\\0';\n\n    cb += len + 4;\n  }\n  default_colors:\n  for (; ci < COLORS_LEN; ci++)\n    colors[ci] = default_colors[ci];\n  return 1;\n}\n\nstatic void put_buf(const char *s, int len, FILE *fout, jv *strout, int is_tty) {\n  if (strout) {\n    *strout = jv_string_append_buf(*strout, s, len);\n  } else {\n#ifdef WIN32\n  /* See util.h */\n  if (is_tty) {\n    wchar_t *ws;\n    size_t wl;\n    if (len == -1)\n      len = strlen(s);\n    wl = MultiByteToWideChar(CP_UTF8, 0, s, len, NULL, 0);\n    ws = jv_mem_calloc(wl + 1, sizeof(*ws));\n    if (!ws)\n      return;\n    wl = MultiByteToWideChar(CP_UTF8, 0, s, len, ws, wl + 1);\n    ws[wl] = 0;\n    WriteConsoleW((HANDLE)_get_osfhandle(fileno(fout)), ws, wl, NULL, NULL);\n    free(ws);\n  } else\n    fwrite(s, 1, len, fout);\n#else\n  fwrite(s, 1, len, fout);\n#endif\n  }\n}\n\nstatic void put_char(char c, FILE* fout, jv* strout, int T) {\n  put_buf(&c, 1, fout, strout, T);\n}\n\nstatic void put_str(const char* s, FILE* fout, jv* strout, int T) {\n  put_buf(s, strlen(s), fout, strout, T);\n}\n\nstatic void put_indent(int n, int flags, FILE* fout, jv* strout, int T) {\n  if (flags & JV_PRINT_TAB) {\n    while (n--)\n      put_char('\\t', fout, strout, T);\n  } else {\n    n *= ((flags & (JV_PRINT_SPACE0 | JV_PRINT_SPACE1 | JV_PRINT_SPACE2)) >> 8);\n    while (n--)\n      put_char(' ', fout, strout, T);\n  }\n}\n\nstatic void jvp_dump_string(jv str, int ascii_only, FILE* F, jv* S, int T) {\n  assert(jv_get_kind(str) == JV_KIND_STRING);\n  const char* i = jv_string_value(str);\n  const char* end = i + jv_string_length_bytes(jv_copy(str));\n  const char* cstart;\n  int c = 0;\n  char buf[32];\n  put_char('\"', F, S, T);\n  while ((i = jvp_utf8_next((cstart = i), end, &c))) {\n    assert(c != -1);\n    int unicode_escape = 0;\n    if (0x20 <= c && c <= 0x7E) {\n      // printable ASCII\n      if (c == '\"' || c == '\\\\') {\n        put_char('\\\\', F, S, T);\n      }\n      put_char(c, F, S, T);\n    } else if (c < 0x20 || c == 0x7F) {\n      // ASCII control character\n      switch (c) {\n      case '\\b':\n        put_char('\\\\', F, S, T);\n        put_char('b', F, S, T);\n        break;\n      case '\\t':\n        put_char('\\\\', F, S, T);\n        put_char('t', F, S, T);\n        break;\n      case '\\r':\n        put_char('\\\\', F, S, T);\n        put_char('r', F, S, T);\n        break;\n      case '\\n':\n        put_char('\\\\', F, S, T);\n        put_char('n', F, S, T);\n        break;\n      case '\\f':\n        put_char('\\\\', F, S, T);\n        put_char('f', F, S, T);\n        break;\n      default:\n        unicode_escape = 1;\n        break;\n      }\n    } else {\n      if (ascii_only) {\n        unicode_escape = 1;\n      } else {\n        put_buf(cstart, i - cstart, F, S, T);\n      }\n    }\n    if (unicode_escape) {\n      if (c <= 0xffff) {\n        snprintf(buf, sizeof(buf), \"\\\\u%04x\", c);\n      } else {\n        c -= 0x10000;\n        snprintf(buf, sizeof(buf), \"\\\\u%04x\\\\u%04x\",\n                0xD800 | ((c & 0xffc00) >> 10),\n                0xDC00 | (c & 0x003ff));\n      }\n      put_str(buf, F, S, T);\n    }\n  }\n  assert(c != -1);\n  put_char('\"', F, S, T);\n}\n\nstatic void put_refcnt(struct dtoa_context* C, int refcnt, FILE *F, jv* S, int T){\n  char buf[JVP_DTOA_FMT_MAX_LEN];\n  put_char(' ', F, S, T);\n  put_char('(', F, S, T);\n  put_str(jvp_dtoa_fmt(C, buf, refcnt), F, S, T);\n  put_char(')', F, S, T);\n}\n\nstatic void jv_dump_term(struct dtoa_context* C, jv x, int flags, int indent, FILE* F, jv* S) {\n  char buf[JVP_DTOA_FMT_MAX_LEN];\n  const char* color = 0;\n  double refcnt = (flags & JV_PRINT_REFCOUNT) ? jv_get_refcnt(x) - 1 : -1;\n  if ((flags & JV_PRINT_COLOR) && jv_get_kind(x) != JV_KIND_INVALID) {\n    color = colors[(int)jv_get_kind(x) - 1];\n    put_str(color, F, S, flags & JV_PRINT_ISATTY);\n  }\n  if (indent > MAX_PRINT_DEPTH) {\n    put_str(\"<skipped: too deep>\", F, S, flags & JV_PRINT_ISATTY);\n  } else switch (jv_get_kind(x)) {\n  default:\n  case JV_KIND_INVALID:\n    if (flags & JV_PRINT_INVALID) {\n      jv msg = jv_invalid_get_msg(jv_copy(x));\n      if (jv_get_kind(msg) == JV_KIND_STRING) {\n        put_str(\"<invalid:\", F, S, flags & JV_PRINT_ISATTY);\n        jvp_dump_string(msg, flags | JV_PRINT_ASCII, F, S, flags & JV_PRINT_ISATTY);\n        put_char('>', F, S, flags & JV_PRINT_ISATTY);\n      } else {\n        put_str(\"<invalid>\", F, S, flags & JV_PRINT_ISATTY);\n      }\n    } else {\n      assert(0 && \"Invalid value\");\n    }\n    break;\n  case JV_KIND_NULL:\n    put_str(\"null\", F, S, flags & JV_PRINT_ISATTY);\n    break;\n  case JV_KIND_FALSE:\n    put_str(\"false\", F, S, flags & JV_PRINT_ISATTY);\n    break;\n  case JV_KIND_TRUE:\n    put_str(\"true\", F, S, flags & JV_PRINT_ISATTY);\n    break;\n  case JV_KIND_NUMBER: {\n    if (jvp_number_is_nan(x)) {\n      jv_dump_term(C, jv_null(), flags, indent, F, S);\n    } else {\n#ifdef USE_DECNUM\n      const char * literal_data = jv_number_get_literal(x);\n      if (literal_data) {\n        put_str(literal_data, F, S, flags & JV_PRINT_ISATTY);\n      } else {\n#endif\n        double d = jv_number_value(x);\n        if (d != d) {\n          // JSON doesn't have NaN, so we'll render it as \"null\"\n          put_str(\"null\", F, S, flags & JV_PRINT_ISATTY);\n        } else {\n          // Normalise infinities to something we can print in valid JSON\n          if (d > DBL_MAX) d = DBL_MAX;\n          if (d < -DBL_MAX) d = -DBL_MAX;\n          put_str(jvp_dtoa_fmt(C, buf, d), F, S, flags & JV_PRINT_ISATTY);\n        }\n      }\n#ifdef USE_DECNUM\n    }\n#endif\n    break;\n  }\n  case JV_KIND_STRING:\n    jvp_dump_string(x, flags & JV_PRINT_ASCII, F, S, flags & JV_PRINT_ISATTY);\n    if (flags & JV_PRINT_REFCOUNT)\n      put_refcnt(C, refcnt, F, S, flags & JV_PRINT_ISATTY);\n    break;\n  case JV_KIND_ARRAY: {\n    if (jv_array_length(jv_copy(x)) == 0) {\n      put_str(\"[]\", F, S, flags & JV_PRINT_ISATTY);\n      break;\n    }\n    put_char('[', F, S, flags & JV_PRINT_ISATTY);\n    jv_array_foreach(x, i, elem) {\n      if (i!=0) {\n        if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);\n        put_char(',', F, S, flags & JV_PRINT_ISATTY);\n      }\n      if (color) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);\n      if (flags & JV_PRINT_PRETTY) {\n        put_char('\\n', F, S, flags & JV_PRINT_ISATTY);\n        put_indent(indent + 1, flags, F, S, flags & JV_PRINT_ISATTY);\n      }\n      jv_dump_term(C, elem, flags, indent + 1, F, S);\n    }\n    if (flags & JV_PRINT_PRETTY) {\n      put_char('\\n', F, S, flags & JV_PRINT_ISATTY);\n      put_indent(indent, flags, F, S, flags & JV_PRINT_ISATTY);\n    }\n    if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);\n    put_char(']', F, S, flags & JV_PRINT_ISATTY);\n    if (flags & JV_PRINT_REFCOUNT)\n      put_refcnt(C, refcnt, F, S, flags & JV_PRINT_ISATTY);\n    break;\n  }\n  case JV_KIND_OBJECT: {\n    if (jv_object_length(jv_copy(x)) == 0) {\n      put_str(\"{}\", F, S, flags & JV_PRINT_ISATTY);\n      break;\n    }\n    put_char('{', F, S, flags & JV_PRINT_ISATTY);\n    int first = 1;\n    int i = 0;\n    jv keyset = jv_null();\n    while (1) {\n      jv key, value;\n      if (flags & JV_PRINT_SORTED) {\n        if (first) {\n          keyset = jv_keys(jv_copy(x));\n          i = 0;\n        } else {\n          i++;\n        }\n        if (i >= jv_array_length(jv_copy(keyset))) {\n          jv_free(keyset);\n          break;\n        }\n        key = jv_array_get(jv_copy(keyset), i);\n        value = jv_object_get(jv_copy(x), jv_copy(key));\n      } else {\n        if (first) {\n          i = jv_object_iter(x);\n        } else {\n          i = jv_object_iter_next(x, i);\n        }\n        if (!jv_object_iter_valid(x, i)) break;\n        key = jv_object_iter_key(x, i);\n        value = jv_object_iter_value(x, i);\n      }\n\n      if (!first) {\n        if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);\n        put_char(',', F, S, flags & JV_PRINT_ISATTY);\n      }\n      if (color) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);\n      if (flags & JV_PRINT_PRETTY) {\n        put_char('\\n', F, S, flags & JV_PRINT_ISATTY);\n        put_indent(indent + 1, flags, F, S, flags & JV_PRINT_ISATTY);\n      }\n\n      first = 0;\n      if (color) put_str(FIELD_COLOR, F, S, flags & JV_PRINT_ISATTY);\n      jvp_dump_string(key, flags & JV_PRINT_ASCII, F, S, flags & JV_PRINT_ISATTY);\n      jv_free(key);\n      if (color) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);\n\n      if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);\n      put_char(':', F, S, flags & JV_PRINT_ISATTY);\n      if (color) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);\n      if (flags & JV_PRINT_PRETTY) {\n        put_char(' ', F, S, flags & JV_PRINT_ISATTY);\n      }\n\n      jv_dump_term(C, value, flags, indent + 1, F, S);\n    }\n    if (flags & JV_PRINT_PRETTY) {\n      put_char('\\n', F, S, flags & JV_PRINT_ISATTY);\n      put_indent(indent, flags, F, S, flags & JV_PRINT_ISATTY);\n    }\n    if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);\n    put_char('}', F, S, flags & JV_PRINT_ISATTY);\n    if (flags & JV_PRINT_REFCOUNT)\n      put_refcnt(C, refcnt, F, S, flags & JV_PRINT_ISATTY);\n  }\n  }\n  jv_free(x);\n  if (color) {\n    put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);\n  }\n}\n\nvoid jv_dumpf(jv x, FILE *f, int flags) {\n  jv_dump_term(tsd_dtoa_context_get(), x, flags, 0, f, 0);\n}\n\nvoid jv_dump(jv x, int flags) {\n  jv_dumpf(x, stdout, flags);\n}\n\n/* This one is nice for use in debuggers */\nvoid jv_show(jv x, int flags) {\n  if (flags == -1)\n    flags = JV_PRINT_PRETTY | JV_PRINT_COLOR | JV_PRINT_INDENT_FLAGS(2);\n  jv_dumpf(jv_copy(x), stderr, flags | JV_PRINT_INVALID);\n  fflush(stderr);\n}\n\njv jv_dump_string(jv x, int flags) {\n  jv s = jv_string(\"\");\n  jv_dump_term(tsd_dtoa_context_get(), x, flags, 0, 0, &s);\n  return s;\n}\n\nchar *jv_dump_string_trunc(jv x, char *outbuf, size_t bufsize) {\n  assert(bufsize > 0);\n  x = jv_dump_string(x, 0);\n  const char *str = jv_string_value(x);\n  const size_t len = strlen(str);\n  if (len > bufsize - 1 && bufsize >= 8) {\n    char delim = 0;\n    switch (str[0]) {\n    case '\"': delim = '\"'; break;\n    case '[': delim = ']'; break;\n    case '{': delim = '}'; break;\n    }\n    size_t l = bufsize - (delim ? 5 : 4);  // \"...\", delim (if any), '\\0'\n    const char *s = jvp_utf8_backtrack(str + l, str, NULL);\n    if (s) l = s - str;\n    memcpy(outbuf, str, l);\n    outbuf[l++] = '.';\n    outbuf[l++] = '.';\n    outbuf[l++] = '.';\n    if (delim) outbuf[l++] = delim;\n    outbuf[l] = '\\0';\n  } else {\n    size_t l = MIN(len, bufsize - 1);\n    memcpy(outbuf, str, l);\n    outbuf[l] = '\\0';\n  }\n  jv_free(x);\n  return outbuf;\n}\n"
  },
  {
    "path": "src/jv_private.h",
    "content": "#ifndef JV_PRIVATE\n#define JV_PRIVATE\n\nint jvp_number_cmp(jv, jv);\nint jvp_number_is_nan(jv);\n\n#endif //JV_PRIVATE\n"
  },
  {
    "path": "src/jv_thread.h",
    "content": "#ifndef JV_THREAD_H\n#define JV_THREAD_H\n\n#ifdef WIN32\n#ifndef __MINGW32__\n#include <windows.h>\n#include <winnt.h>\n#include <errno.h>\n\n/* Copied from Heimdal: pthread-like mutexes for WIN32 -- see lib/base/heimbase.h in Heimdal */\ntypedef struct pthread_mutex {\n    HANDLE      h;\n} pthread_mutex_t;\n\n#define PTHREAD_MUTEX_INITIALIZER { INVALID_HANDLE_VALUE }\n\nstatic inline int\npthread_mutex_init(pthread_mutex_t *m)\n{\n    m->h = CreateSemaphore(NULL, 1, 1, NULL);\n    if (m->h == INVALID_HANDLE_VALUE)\n        return EAGAIN;\n    return 0;\n}\n\nstatic inline int\npthread_mutex_lock(pthread_mutex_t *m)\n{\n    HANDLE h, new_h;\n    int created = 0;\n\n    h = InterlockedCompareExchangePointer(&m->h, m->h, m->h);\n    if (h == INVALID_HANDLE_VALUE || h == NULL) {\n        created = 1;\n        new_h = CreateSemaphore(NULL, 0, 1, NULL);\n        if (new_h == INVALID_HANDLE_VALUE)\n            return EAGAIN;\n        if (InterlockedCompareExchangePointer(&m->h, new_h, h) != h) {\n            created = 0;\n            CloseHandle(new_h);\n        }\n    }\n    if (!created)\n        WaitForSingleObject(m->h, INFINITE);\n    return 0;\n}\n\nstatic inline int\npthread_mutex_unlock(pthread_mutex_t *m)\n{\n    if (ReleaseSemaphore(m->h, 1, NULL) == FALSE)\n        return EPERM;\n    return 0;\n}\nstatic inline int\npthread_mutex_destroy(pthread_mutex_t *m)\n{\n    HANDLE h;\n\n    h = InterlockedCompareExchangePointer(&m->h, INVALID_HANDLE_VALUE, m->h);\n    if (h != INVALID_HANDLE_VALUE)\n        CloseHandle(h);\n    return 0;\n}\n\ntypedef unsigned long pthread_key_t;\nint pthread_key_create(pthread_key_t *, void (*)(void *));\nint pthread_setspecific(pthread_key_t, void *);\nvoid *pthread_getspecific(pthread_key_t);\n#else\n#include <pthread.h>\n#endif\n#else\n#include <pthread.h>\n#endif\n#endif /* JV_THREAD_H */\n"
  },
  {
    "path": "src/jv_unicode.c",
    "content": "#include <stdio.h>\n#include <assert.h>\n#include \"jv_unicode.h\"\n#include \"jv_utf8_tables.h\"\n\n// jvp_utf8_backtrack returns the beginning of the last codepoint in the\n// string, assuming that start is the last byte in the string.\n// If the last codepoint is incomplete, returns the number of missing bytes via\n// *missing_bytes.  If there are no leading bytes or an invalid byte is\n// encountered, NULL is returned and *missing_bytes is not altered.\nconst char* jvp_utf8_backtrack(const char* start, const char* min, int *missing_bytes) {\n  assert(min <= start);\n  if (min == start) {\n    return min;\n  }\n  int length = 0;\n  int seen = 1;\n  while (start >= min && (length = utf8_coding_length[(unsigned char)*start]) == UTF8_CONTINUATION_BYTE) {\n    start--;\n    seen++;\n  }\n  if (length == 0 || length == UTF8_CONTINUATION_BYTE || length - seen < 0) {\n    return NULL;\n  }\n  if (missing_bytes) *missing_bytes = length - seen;\n  return start;\n}\n\nconst char* jvp_utf8_next(const char* in, const char* end, int* codepoint_ret) {\n  assert(in <= end);\n  if (in == end) {\n    return 0;\n  }\n  int codepoint = -1;\n  unsigned char first = (unsigned char)in[0];\n  int length = utf8_coding_length[first];\n  if ((first & 0x80) == 0) {\n    /* Fast-path for ASCII */\n    codepoint = first;\n    length = 1;\n  } else if (length == 0 || length == UTF8_CONTINUATION_BYTE) {\n    /* Bad single byte - either an invalid byte or an out-of-place continuation byte */\n    length = 1;\n  } else if (in + length > end) {\n    /* String ends before UTF8 sequence ends */\n    length = end - in;\n  } else {\n    codepoint = ((unsigned)in[0]) & utf8_coding_bits[first];\n    for (int i=1; i<length; i++) {\n      unsigned ch = (unsigned char)in[i];\n      if (utf8_coding_length[ch] != UTF8_CONTINUATION_BYTE){\n        /* Invalid UTF8 sequence - not followed by the right number of continuation bytes */\n        codepoint = -1;\n        length = i;\n        break;\n      }\n      codepoint = (codepoint << 6) | (ch & 0x3f);\n    }\n    if (codepoint < utf8_first_codepoint[length]) {\n      /* Overlong UTF8 sequence */\n      codepoint = -1;\n    }\n    if (0xD800 <= codepoint && codepoint <= 0xDFFF) {\n      /* Surrogate codepoints can't be encoded in UTF8 */\n      codepoint = -1;\n    }\n    if (codepoint > 0x10FFFF) {\n      /* Outside Unicode range */\n      codepoint = -1;\n    }\n  }\n  assert(length > 0);\n  *codepoint_ret = codepoint;\n  return in + length;\n}\n\nint jvp_utf8_is_valid(const char* in, const char* end) {\n  int codepoint;\n  while ((in = jvp_utf8_next(in, end, &codepoint))) {\n    if (codepoint == -1) return 0;\n  }\n  return 1;\n}\n\n/* Assumes startchar is the first byte of a valid character sequence */\nint jvp_utf8_decode_length(char startchar) {\n\tif ((startchar & 0x80) == 0) return 1;         // 0___ ____\n\telse if ((startchar & 0xE0) == 0xC0) return 2; // 110_ ____\n\telse if ((startchar & 0xF0) == 0xE0) return 3; // 1110 ____\n\telse return 4;                                 // 1111 ____\n}\n\nint jvp_utf8_encode_length(int codepoint) {\n  if (codepoint <= 0x7F) return 1;\n  else if (codepoint <= 0x7FF) return 2;\n  else if (codepoint <= 0xFFFF) return 3;\n  else return 4;\n}\n\nint jvp_utf8_encode(int codepoint, char* out) {\n  assert(codepoint >= 0 && codepoint <= 0x10FFFF);\n  char* start = out;\n  if (codepoint <= 0x7F) {\n    *out++ = codepoint;\n  } else if (codepoint <= 0x7FF) {\n    *out++ = 0xC0 + ((codepoint & 0x7C0) >> 6);\n    *out++ = 0x80 + ((codepoint & 0x03F));\n  } else if(codepoint <= 0xFFFF) {\n    *out++ = 0xE0 + ((codepoint & 0xF000) >> 12);\n    *out++ = 0x80 + ((codepoint & 0x0FC0) >> 6);\n    *out++ = 0x80 + ((codepoint & 0x003F));\n  } else {\n    *out++ = 0xF0 + ((codepoint & 0x1C0000) >> 18);\n    *out++ = 0x80 + ((codepoint & 0x03F000) >> 12);\n    *out++ = 0x80 + ((codepoint & 0x000FC0) >> 6);\n    *out++ = 0x80 + ((codepoint & 0x00003F));\n  }\n  assert(out - start == jvp_utf8_encode_length(codepoint));\n  return out - start;\n}\n\n// characters with White_Space property in:\n// https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt\nint jvp_codepoint_is_whitespace(int c) {\n  return\n    (c >= 0x0009 && c <= 0x000D) || // <control-0009>..<control-000D>\n    c == 0x0020                  || // SPACE\n    c == 0x0085                  || // <control-0085>\n    c == 0x00A0                  || // NO-BREAK SPACE\n    c == 0x1680                  || // OGHAM SPACE MARK\n    (c >= 0x2000 && c <= 0x200A) || // EN QUAD..HAIR SPACE\n    c == 0x2028                  || // LINE SEPARATOR\n    c == 0x2029                  || // PARAGRAPH SEPARATOR\n    c == 0x202F                  || // NARROW NO-BREAK SPACE\n    c == 0x205F                  || // MEDIUM MATHEMATICAL SPACE\n    c == 0x3000                     // IDEOGRAPHIC SPACE\n    ;\n}\n"
  },
  {
    "path": "src/jv_unicode.h",
    "content": "#ifndef JV_UNICODE_H\n#define JV_UNICODE_H\n\nconst char* jvp_utf8_backtrack(const char* start, const char* min, int *missing_bytes);\nconst char* jvp_utf8_next(const char* in, const char* end, int* codepoint);\nint jvp_utf8_is_valid(const char* in, const char* end);\n\nint jvp_utf8_decode_length(char startchar);\n\nint jvp_utf8_encode_length(int codepoint);\nint jvp_utf8_encode(int codepoint, char* out);\n\nint jvp_codepoint_is_whitespace(int c);\n#endif\n"
  },
  {
    "path": "src/jv_utf8_tables.h",
    "content": "#define UTF8_CONTINUATION_BYTE ((unsigned char)255)\nstatic const unsigned char utf8_coding_length[] =\n {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\n  0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\n  0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\n  0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\n  0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\n  0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\n  0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\n  0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\n  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\n  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\n  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\n  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\n  0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,\n  0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,\n  0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,\n  0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\nstatic const unsigned char utf8_coding_bits[] =\n {0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,\n  0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,\n  0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,\n  0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,\n  0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,\n  0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,\n  0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,\n  0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,\n  0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,\n  0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,\n  0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,\n  0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,\n  0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,\n  0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,\n  0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,\n  0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\nstatic const int utf8_first_codepoint[] =\n {0x00, 0x00, 0x80, 0x800, 0x10000};\n"
  },
  {
    "path": "src/lexer.c",
    "content": "#line 2 \"src/lexer.c\"\n\n#line 4 \"src/lexer.c\"\n\n#define  YY_INT_ALIGNED short int\n\n/* A lexical scanner generated by flex */\n\n#define FLEX_SCANNER\n#define YY_FLEX_MAJOR_VERSION 2\n#define YY_FLEX_MINOR_VERSION 6\n#define YY_FLEX_SUBMINOR_VERSION 4\n#if YY_FLEX_SUBMINOR_VERSION > 0\n#define FLEX_BETA\n#endif\n\n#ifdef yy_create_buffer\n#define jq_yy_create_buffer_ALREADY_DEFINED\n#else\n#define yy_create_buffer jq_yy_create_buffer\n#endif\n\n#ifdef yy_delete_buffer\n#define jq_yy_delete_buffer_ALREADY_DEFINED\n#else\n#define yy_delete_buffer jq_yy_delete_buffer\n#endif\n\n#ifdef yy_scan_buffer\n#define jq_yy_scan_buffer_ALREADY_DEFINED\n#else\n#define yy_scan_buffer jq_yy_scan_buffer\n#endif\n\n#ifdef yy_scan_string\n#define jq_yy_scan_string_ALREADY_DEFINED\n#else\n#define yy_scan_string jq_yy_scan_string\n#endif\n\n#ifdef yy_scan_bytes\n#define jq_yy_scan_bytes_ALREADY_DEFINED\n#else\n#define yy_scan_bytes jq_yy_scan_bytes\n#endif\n\n#ifdef yy_init_buffer\n#define jq_yy_init_buffer_ALREADY_DEFINED\n#else\n#define yy_init_buffer jq_yy_init_buffer\n#endif\n\n#ifdef yy_flush_buffer\n#define jq_yy_flush_buffer_ALREADY_DEFINED\n#else\n#define yy_flush_buffer jq_yy_flush_buffer\n#endif\n\n#ifdef yy_load_buffer_state\n#define jq_yy_load_buffer_state_ALREADY_DEFINED\n#else\n#define yy_load_buffer_state jq_yy_load_buffer_state\n#endif\n\n#ifdef yy_switch_to_buffer\n#define jq_yy_switch_to_buffer_ALREADY_DEFINED\n#else\n#define yy_switch_to_buffer jq_yy_switch_to_buffer\n#endif\n\n#ifdef yypush_buffer_state\n#define jq_yypush_buffer_state_ALREADY_DEFINED\n#else\n#define yypush_buffer_state jq_yypush_buffer_state\n#endif\n\n#ifdef yypop_buffer_state\n#define jq_yypop_buffer_state_ALREADY_DEFINED\n#else\n#define yypop_buffer_state jq_yypop_buffer_state\n#endif\n\n#ifdef yyensure_buffer_stack\n#define jq_yyensure_buffer_stack_ALREADY_DEFINED\n#else\n#define yyensure_buffer_stack jq_yyensure_buffer_stack\n#endif\n\n#ifdef yylex\n#define jq_yylex_ALREADY_DEFINED\n#else\n#define yylex jq_yylex\n#endif\n\n#ifdef yyrestart\n#define jq_yyrestart_ALREADY_DEFINED\n#else\n#define yyrestart jq_yyrestart\n#endif\n\n#ifdef yylex_init\n#define jq_yylex_init_ALREADY_DEFINED\n#else\n#define yylex_init jq_yylex_init\n#endif\n\n#ifdef yylex_init_extra\n#define jq_yylex_init_extra_ALREADY_DEFINED\n#else\n#define yylex_init_extra jq_yylex_init_extra\n#endif\n\n#ifdef yylex_destroy\n#define jq_yylex_destroy_ALREADY_DEFINED\n#else\n#define yylex_destroy jq_yylex_destroy\n#endif\n\n#ifdef yyget_debug\n#define jq_yyget_debug_ALREADY_DEFINED\n#else\n#define yyget_debug jq_yyget_debug\n#endif\n\n#ifdef yyset_debug\n#define jq_yyset_debug_ALREADY_DEFINED\n#else\n#define yyset_debug jq_yyset_debug\n#endif\n\n#ifdef yyget_extra\n#define jq_yyget_extra_ALREADY_DEFINED\n#else\n#define yyget_extra jq_yyget_extra\n#endif\n\n#ifdef yyset_extra\n#define jq_yyset_extra_ALREADY_DEFINED\n#else\n#define yyset_extra jq_yyset_extra\n#endif\n\n#ifdef yyget_in\n#define jq_yyget_in_ALREADY_DEFINED\n#else\n#define yyget_in jq_yyget_in\n#endif\n\n#ifdef yyset_in\n#define jq_yyset_in_ALREADY_DEFINED\n#else\n#define yyset_in jq_yyset_in\n#endif\n\n#ifdef yyget_out\n#define jq_yyget_out_ALREADY_DEFINED\n#else\n#define yyget_out jq_yyget_out\n#endif\n\n#ifdef yyset_out\n#define jq_yyset_out_ALREADY_DEFINED\n#else\n#define yyset_out jq_yyset_out\n#endif\n\n#ifdef yyget_leng\n#define jq_yyget_leng_ALREADY_DEFINED\n#else\n#define yyget_leng jq_yyget_leng\n#endif\n\n#ifdef yyget_text\n#define jq_yyget_text_ALREADY_DEFINED\n#else\n#define yyget_text jq_yyget_text\n#endif\n\n#ifdef yyget_lineno\n#define jq_yyget_lineno_ALREADY_DEFINED\n#else\n#define yyget_lineno jq_yyget_lineno\n#endif\n\n#ifdef yyset_lineno\n#define jq_yyset_lineno_ALREADY_DEFINED\n#else\n#define yyset_lineno jq_yyset_lineno\n#endif\n\n#ifdef yyget_column\n#define jq_yyget_column_ALREADY_DEFINED\n#else\n#define yyget_column jq_yyget_column\n#endif\n\n#ifdef yyset_column\n#define jq_yyset_column_ALREADY_DEFINED\n#else\n#define yyset_column jq_yyset_column\n#endif\n\n#ifdef yywrap\n#define jq_yywrap_ALREADY_DEFINED\n#else\n#define yywrap jq_yywrap\n#endif\n\n#ifdef yyget_lval\n#define jq_yyget_lval_ALREADY_DEFINED\n#else\n#define yyget_lval jq_yyget_lval\n#endif\n\n#ifdef yyset_lval\n#define jq_yyset_lval_ALREADY_DEFINED\n#else\n#define yyset_lval jq_yyset_lval\n#endif\n\n#ifdef yyget_lloc\n#define jq_yyget_lloc_ALREADY_DEFINED\n#else\n#define yyget_lloc jq_yyget_lloc\n#endif\n\n#ifdef yyset_lloc\n#define jq_yyset_lloc_ALREADY_DEFINED\n#else\n#define yyset_lloc jq_yyset_lloc\n#endif\n\n#ifdef yyalloc\n#define jq_yyalloc_ALREADY_DEFINED\n#else\n#define yyalloc jq_yyalloc\n#endif\n\n#ifdef yyrealloc\n#define jq_yyrealloc_ALREADY_DEFINED\n#else\n#define yyrealloc jq_yyrealloc\n#endif\n\n#ifdef yyfree\n#define jq_yyfree_ALREADY_DEFINED\n#else\n#define yyfree jq_yyfree\n#endif\n\n/* First, we deal with  platform-specific or compiler-specific issues. */\n\n/* begin standard C headers. */\n#include <stdio.h>\n#include <string.h>\n#include <errno.h>\n#include <stdlib.h>\n\n/* end standard C headers. */\n\n/* flex integer type definitions */\n\n#ifndef FLEXINT_H\n#define FLEXINT_H\n\n/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */\n\n#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n\n/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,\n * if you want the limit (max/min) macros for int types. \n */\n#ifndef __STDC_LIMIT_MACROS\n#define __STDC_LIMIT_MACROS 1\n#endif\n\n#include <inttypes.h>\ntypedef int8_t flex_int8_t;\ntypedef uint8_t flex_uint8_t;\ntypedef int16_t flex_int16_t;\ntypedef uint16_t flex_uint16_t;\ntypedef int32_t flex_int32_t;\ntypedef uint32_t flex_uint32_t;\n#else\ntypedef signed char flex_int8_t;\ntypedef short int flex_int16_t;\ntypedef int flex_int32_t;\ntypedef unsigned char flex_uint8_t; \ntypedef unsigned short int flex_uint16_t;\ntypedef unsigned int flex_uint32_t;\n\n/* Limits of integral types. */\n#ifndef INT8_MIN\n#define INT8_MIN               (-128)\n#endif\n#ifndef INT16_MIN\n#define INT16_MIN              (-32767-1)\n#endif\n#ifndef INT32_MIN\n#define INT32_MIN              (-2147483647-1)\n#endif\n#ifndef INT8_MAX\n#define INT8_MAX               (127)\n#endif\n#ifndef INT16_MAX\n#define INT16_MAX              (32767)\n#endif\n#ifndef INT32_MAX\n#define INT32_MAX              (2147483647)\n#endif\n#ifndef UINT8_MAX\n#define UINT8_MAX              (255U)\n#endif\n#ifndef UINT16_MAX\n#define UINT16_MAX             (65535U)\n#endif\n#ifndef UINT32_MAX\n#define UINT32_MAX             (4294967295U)\n#endif\n\n#ifndef SIZE_MAX\n#define SIZE_MAX               (~(size_t)0)\n#endif\n\n#endif /* ! C99 */\n\n#endif /* ! FLEXINT_H */\n\n/* begin standard C++ headers. */\n\n/* TODO: this is always defined, so inline it */\n#define yyconst const\n\n#if defined(__GNUC__) && __GNUC__ >= 3\n#define yynoreturn __attribute__((__noreturn__))\n#else\n#define yynoreturn\n#endif\n\n/* Returned upon end-of-file. */\n#define YY_NULL 0\n\n/* Promotes a possibly negative, possibly signed char to an\n *   integer in range [0..255] for use as an array index.\n */\n#define YY_SC_TO_UI(c) ((YY_CHAR) (c))\n\n/* An opaque pointer. */\n#ifndef YY_TYPEDEF_YY_SCANNER_T\n#define YY_TYPEDEF_YY_SCANNER_T\ntypedef void* yyscan_t;\n#endif\n\n/* For convenience, these vars (plus the bison vars far below)\n   are macros in the reentrant scanner. */\n#define yyin yyg->yyin_r\n#define yyout yyg->yyout_r\n#define yyextra yyg->yyextra_r\n#define yyleng yyg->yyleng_r\n#define yytext yyg->yytext_r\n#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)\n#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)\n#define yy_flex_debug yyg->yy_flex_debug_r\n\n/* Enter a start condition.  This macro really ought to take a parameter,\n * but we do it the disgusting crufty way forced on us by the ()-less\n * definition of BEGIN.\n */\n#define BEGIN yyg->yy_start = 1 + 2 *\n/* Translate the current start state into a value that can be later handed\n * to BEGIN to return to the state.  The YYSTATE alias is for lex\n * compatibility.\n */\n#define YY_START ((yyg->yy_start - 1) / 2)\n#define YYSTATE YY_START\n/* Action number for EOF rule of a given start state. */\n#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)\n/* Special action meaning \"start processing a new file\". */\n#define YY_NEW_FILE yyrestart( yyin , yyscanner )\n#define YY_END_OF_BUFFER_CHAR 0\n\n/* Size of default input buffer. */\n#ifndef YY_BUF_SIZE\n#ifdef __ia64__\n/* On IA-64, the buffer size is 16k, not 8k.\n * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.\n * Ditto for the __ia64__ case accordingly.\n */\n#define YY_BUF_SIZE 32768\n#else\n#define YY_BUF_SIZE 16384\n#endif /* __ia64__ */\n#endif\n\n/* The state buf must be large enough to hold one state per character in the main buffer.\n */\n#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))\n\n#ifndef YY_TYPEDEF_YY_BUFFER_STATE\n#define YY_TYPEDEF_YY_BUFFER_STATE\ntypedef struct yy_buffer_state *YY_BUFFER_STATE;\n#endif\n\n#ifndef YY_TYPEDEF_YY_SIZE_T\n#define YY_TYPEDEF_YY_SIZE_T\ntypedef size_t yy_size_t;\n#endif\n\n#define EOB_ACT_CONTINUE_SCAN 0\n#define EOB_ACT_END_OF_FILE 1\n#define EOB_ACT_LAST_MATCH 2\n    \n    #define YY_LESS_LINENO(n)\n    #define YY_LINENO_REWIND_TO(ptr)\n    \n/* Return all but the first \"n\" matched characters back to the input stream. */\n#define yyless(n) \\\n\tdo \\\n\t\t{ \\\n\t\t/* Undo effects of setting up yytext. */ \\\n        int yyless_macro_arg = (n); \\\n        YY_LESS_LINENO(yyless_macro_arg);\\\n\t\t*yy_cp = yyg->yy_hold_char; \\\n\t\tYY_RESTORE_YY_MORE_OFFSET \\\n\t\tyyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \\\n\t\tYY_DO_BEFORE_ACTION; /* set up yytext again */ \\\n\t\t} \\\n\twhile ( 0 )\n#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )\n\n#ifndef YY_STRUCT_YY_BUFFER_STATE\n#define YY_STRUCT_YY_BUFFER_STATE\nstruct yy_buffer_state\n\t{\n\tFILE *yy_input_file;\n\n\tchar *yy_ch_buf;\t\t/* input buffer */\n\tchar *yy_buf_pos;\t\t/* current position in input buffer */\n\n\t/* Size of input buffer in bytes, not including room for EOB\n\t * characters.\n\t */\n\tint yy_buf_size;\n\n\t/* Number of characters read into yy_ch_buf, not including EOB\n\t * characters.\n\t */\n\tint yy_n_chars;\n\n\t/* Whether we \"own\" the buffer - i.e., we know we created it,\n\t * and can realloc() it to grow it, and should free() it to\n\t * delete it.\n\t */\n\tint yy_is_our_buffer;\n\n\t/* Whether this is an \"interactive\" input source; if so, and\n\t * if we're using stdio for input, then we want to use getc()\n\t * instead of fread(), to make sure we stop fetching input after\n\t * each newline.\n\t */\n\tint yy_is_interactive;\n\n\t/* Whether we're considered to be at the beginning of a line.\n\t * If so, '^' rules will be active on the next match, otherwise\n\t * not.\n\t */\n\tint yy_at_bol;\n\n    int yy_bs_lineno; /**< The line count. */\n    int yy_bs_column; /**< The column count. */\n\n\t/* Whether to try to fill the input buffer when we reach the\n\t * end of it.\n\t */\n\tint yy_fill_buffer;\n\n\tint yy_buffer_status;\n\n#define YY_BUFFER_NEW 0\n#define YY_BUFFER_NORMAL 1\n\t/* When an EOF's been seen but there's still some text to process\n\t * then we mark the buffer as YY_EOF_PENDING, to indicate that we\n\t * shouldn't try reading from the input source any more.  We might\n\t * still have a bunch of tokens to match, though, because of\n\t * possible backing-up.\n\t *\n\t * When we actually see the EOF, we change the status to \"new\"\n\t * (via yyrestart()), so that the user can continue scanning by\n\t * just pointing yyin at a new input file.\n\t */\n#define YY_BUFFER_EOF_PENDING 2\n\n\t};\n#endif /* !YY_STRUCT_YY_BUFFER_STATE */\n\n/* We provide macros for accessing buffer states in case in the\n * future we want to put the buffer states in a more general\n * \"scanner state\".\n *\n * Returns the top of the stack, or NULL.\n */\n#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \\\n                          ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \\\n                          : NULL)\n/* Same as previous macro, but useful when we know that the buffer stack is not\n * NULL or when we need an lvalue. For internal use only.\n */\n#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]\n\nvoid yyrestart ( FILE *input_file , yyscan_t yyscanner );\nvoid yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );\nYY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );\nvoid yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );\nvoid yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );\nvoid yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );\nvoid yypop_buffer_state ( yyscan_t yyscanner );\n\nstatic void yyensure_buffer_stack ( yyscan_t yyscanner );\nstatic void yy_load_buffer_state ( yyscan_t yyscanner );\nstatic void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );\n#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)\n\nYY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );\nYY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );\nYY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );\n\nvoid *yyalloc ( yy_size_t , yyscan_t yyscanner );\nvoid *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );\nvoid yyfree ( void * , yyscan_t yyscanner );\n\n#define yy_new_buffer yy_create_buffer\n#define yy_set_interactive(is_interactive) \\\n\t{ \\\n\tif ( ! YY_CURRENT_BUFFER ){ \\\n        yyensure_buffer_stack (yyscanner); \\\n\t\tYY_CURRENT_BUFFER_LVALUE =    \\\n            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \\\n\t} \\\n\tYY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \\\n\t}\n#define yy_set_bol(at_bol) \\\n\t{ \\\n\tif ( ! YY_CURRENT_BUFFER ){\\\n        yyensure_buffer_stack (yyscanner); \\\n\t\tYY_CURRENT_BUFFER_LVALUE =    \\\n            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \\\n\t} \\\n\tYY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \\\n\t}\n#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)\n\n/* Begin user sect3 */\n\n#define jq_yywrap(yyscanner) (/*CONSTCOND*/1)\n#define YY_SKIP_YYWRAP\ntypedef flex_uint8_t YY_CHAR;\n\ntypedef int yy_state_type;\n\n#define yytext_ptr yytext_r\n\nstatic yy_state_type yy_get_previous_state ( yyscan_t yyscanner );\nstatic yy_state_type yy_try_NUL_trans ( yy_state_type current_state  , yyscan_t yyscanner);\nstatic int yy_get_next_buffer ( yyscan_t yyscanner );\nstatic void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );\n\n/* Done after the current pattern has been matched and before the\n * corresponding action - sets up yytext.\n */\n#define YY_DO_BEFORE_ACTION \\\n\tyyg->yytext_ptr = yy_bp; \\\n\tyyleng = (int) (yy_cp - yy_bp); \\\n\tyyg->yy_hold_char = *yy_cp; \\\n\t*yy_cp = '\\0'; \\\n\tyyg->yy_c_buf_p = yy_cp;\n#define YY_NUM_RULES 53\n#define YY_END_OF_BUFFER 54\n/* This struct is not used in this scanner,\n   but its presence is necessary. */\nstruct yy_trans_info\n\t{\n\tflex_int32_t yy_verify;\n\tflex_int32_t yy_nxt;\n\t};\nstatic const flex_int16_t yy_accept[171] =\n    {   0,\n        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n        0,    0,    0,    0,   54,   52,   51,   51,   52,   42,\n        1,   37,   37,   38,   39,   37,   37,   37,   37,   37,\n       37,   41,   37,   37,   37,   37,   52,   48,   48,   48,\n       48,   48,   48,   48,   48,   48,   48,   48,   48,   48,\n       37,   46,   46,   44,   47,    2,    3,    2,    2,   51,\n        4,   50,   50,   31,   29,   27,   28,   35,   41,   49,\n       20,   30,   41,   41,    0,   33,    5,   34,    0,   40,\n       48,    0,   48,    6,   48,   48,   48,   48,   48,   48,\n       11,   48,   48,   48,   48,   16,   48,   48,   48,   26,\n\n       46,   45,   43,   45,    3,    2,    0,   50,    0,   50,\n       49,   32,   41,    0,   41,   36,    0,   15,   48,   48,\n       10,   48,   48,   17,   48,   48,   48,   48,   48,   48,\n       48,   21,    0,   45,    0,   50,   48,   48,   48,   14,\n       13,   48,   48,   48,   48,   48,   48,   12,   45,   50,\n       24,   22,   48,   48,   48,   23,   48,   48,   45,   50,\n       48,    7,   48,    9,   18,   50,   19,    8,   25,    0\n    } ;\n\nstatic const YY_CHAR yy_ec[256] =\n    {   0,\n        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,\n        1,    1,    4,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    2,    5,    6,    7,    8,    9,    1,    1,   10,\n       11,   12,   13,   14,   15,   16,   17,   18,   18,   18,\n       18,   18,   18,   18,   18,   18,   18,   19,   20,   21,\n       22,   23,   24,   25,   26,   26,   26,   26,   27,   26,\n       26,   26,   26,   26,   26,   26,   26,   26,   26,   26,\n       26,   26,   26,   26,   26,   26,   26,   26,   26,   26,\n       28,   29,   30,    1,   31,    1,   32,   33,   34,   35,\n\n       36,   37,   26,   38,   39,   26,   40,   41,   42,   43,\n       44,   45,   26,   46,   47,   48,   49,   26,   26,   26,\n       50,   26,   51,   52,   53,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1\n    } ;\n\nstatic const YY_CHAR yy_meta[54] =\n    {   0,\n        1,    1,    1,    1,    1,    2,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    3,    1,    4,    5,    1,\n        1,    1,    1,    1,    1,    6,    6,    1,    7,    1,\n        8,    6,    6,    6,    6,    6,    6,    6,    6,    6,\n        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,\n        1,    1,    1\n    } ;\n\nstatic const flex_int16_t yy_base[186] =\n    {   0,\n        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,\n       51,   52,   56,   58,  340,  341,   61,   64,  317,  341,\n      341,  307,  315,  341,  341,  314,  313,  341,  312,   53,\n       53,   56,  311,  310,  309,  313,    0,  310,   54,   57,\n       58,   59,   63,   65,   70,   67,   72,   69,   60,   79,\n      306,    0,    0,  341,   83,  341,  341,  324,  107,  116,\n      341,  307,   83,  341,  341,  341,  341,  341,  103,    0,\n      303,  341,  104,  108,  128,  341,  341,  341,  307,    0,\n      304,  301,  110,  297,  114,   75,  115,  108,  118,  119,\n      293,  109,  123,  129,  132,  290,  137,  130,  139,  341,\n\n        0,  276,  341,  273,  341,  341,  297,  278,  265,  140,\n        0,  341,  142,  261,  258,  341,    0,  252,  142,  145,\n      250,  149,  144,  247,  151,  152,  154,  156,  157,  158,\n      165,  245,  172,  231,    0,  166,  222,  164,  171,  221,\n      220,  169,  172,  174,  175,  178,  179,  218,  206,  180,\n      215,  214,  181,  183,  192,  213,  184,  186,  201,  193,\n      198,  210,  206,  209,   89,  207,   86,   81,   37,  341,\n      242,  250,  253,  259,  264,  269,  277,  285,  290,  295,\n      300,  302,  307,  311,  315\n    } ;\n\nstatic const flex_int16_t yy_def[186] =\n    {   0,\n      170,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n      171,  171,  172,  172,  170,  170,  170,  170,  170,  170,\n      170,  173,  170,  170,  170,  170,  170,  170,  170,  174,\n      170,  170,  170,  170,  170,  170,  175,  176,  176,  176,\n      176,  176,  176,  176,  176,  176,  176,  176,  176,  176,\n      170,  177,  177,  170,  178,  170,  170,  170,  170,  170,\n      170,  179,  179,  170,  170,  170,  170,  170,  170,  180,\n      170,  170,  170,  170,  170,  170,  170,  170,  170,  175,\n      176,  170,  176,  176,  176,  176,  176,  176,  176,  176,\n      176,  176,  176,  176,  176,  176,  176,  176,  176,  170,\n\n      177,  170,  170,  181,  170,  170,  170,  179,  170,  179,\n      180,  170,  170,  170,  170,  170,  182,  176,  176,  176,\n      176,  176,  176,  176,  176,  176,  176,  176,  176,  176,\n      176,  176,  178,  183,  173,  179,  176,  176,  176,  176,\n      176,  176,  176,  176,  176,  176,  176,  176,  184,  179,\n      176,  176,  176,  176,  176,  176,  176,  176,  185,  179,\n      176,  176,  176,  176,  176,  179,  176,  176,  179,    0,\n      170,  170,  170,  170,  170,  170,  170,  170,  170,  170,\n      170,  170,  170,  170,  170\n    } ;\n\nstatic const flex_int16_t yy_nxt[395] =\n    {   0,\n       16,   17,   18,   17,   19,   20,   21,   22,   23,   24,\n       25,   26,   27,   28,   29,   30,   31,   32,   28,   28,\n       33,   34,   35,   36,   37,   38,   38,   24,   16,   25,\n       38,   39,   40,   41,   42,   43,   44,   38,   45,   38,\n       46,   47,   38,   48,   38,   49,   38,   50,   38,   38,\n       24,   51,   25,   53,   53,  109,   54,   54,   57,   58,\n       57,   58,   60,   60,   60,   60,   60,   60,   68,   71,\n       69,   73,   82,   74,   72,   82,   82,   82,   82,   55,\n       55,   82,   75,   82,   59,   82,   59,   82,   82,   86,\n       82,   75,  103,   82,   87,   97,   83,   82,   94,   82,\n\n       84,  109,   85,   88,   82,   89,   91,   82,   90,  106,\n      107,   92,   93,  110,   96,   95,   98,   60,   60,   60,\n       69,  113,  120,   73,   99,   74,   82,   82,   82,   75,\n       75,  104,   82,   82,   75,  106,   82,   82,   75,   75,\n      114,   82,  114,   75,  118,  115,  122,   82,   82,  119,\n       82,  121,  124,  126,  123,   82,  127,   82,  109,  113,\n       82,  128,   82,   82,  125,  131,  129,   82,   75,   82,\n       82,  130,   82,  138,   82,   82,   82,   75,  139,  141,\n      136,  170,   82,   82,  109,  140,  142,   82,  132,   82,\n       82,  145,   82,   82,  144,  143,   82,   82,  109,   82,\n\n      153,   82,   82,  151,   82,  146,  147,  148,  152,  150,\n       82,  109,  158,  160,  161,  156,   82,  154,  157,  164,\n      104,  165,  155,  166,   82,  109,  163,   82,   82,  133,\n      162,   82,   82,   82,  133,  167,   82,  169,   82,   82,\n       82,  168,   52,   52,   52,   52,   52,   52,   52,   52,\n       56,   56,   56,   56,   56,   56,   56,   56,   62,  133,\n       62,   70,   70,   82,   70,   82,   70,   80,   82,   80,\n       82,   80,   81,   81,   81,  115,   81,  101,  115,  101,\n      101,  101,  101,  135,  101,  102,  102,  102,  102,  102,\n      102,  102,  102,  108,  108,  108,  109,  108,  111,  106,\n\n      111,  133,  111,  134,  133,  134,  134,  137,   82,  137,\n      149,   82,  149,  149,  159,   82,  159,  159,  102,  117,\n      102,  102,   82,  116,  112,  109,  105,  100,   82,   79,\n       78,   77,   76,   67,   66,   65,   64,   63,   61,  170,\n       15,  170,  170,  170,  170,  170,  170,  170,  170,  170,\n      170,  170,  170,  170,  170,  170,  170,  170,  170,  170,\n      170,  170,  170,  170,  170,  170,  170,  170,  170,  170,\n      170,  170,  170,  170,  170,  170,  170,  170,  170,  170,\n      170,  170,  170,  170,  170,  170,  170,  170,  170,  170,\n      170,  170,  170,  170\n\n    } ;\n\nstatic const flex_int16_t yy_chk[395] =\n    {   0,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,\n        1,    1,    1,   11,   12,  169,   11,   12,   13,   13,\n       14,   14,   17,   17,   17,   18,   18,   18,   30,   31,\n       30,   32,   39,   32,   31,   40,   41,   42,   49,   11,\n       12,   43,   32,   44,   13,   46,   14,   48,   45,   41,\n       47,   32,   55,   86,   42,   49,   39,   50,   46,  168,\n\n       39,   63,   40,   43,  167,   43,   45,  165,   44,   59,\n       59,   45,   45,   63,   48,   47,   50,   60,   60,   60,\n       69,   73,   86,   74,   50,   74,   88,   92,   83,   69,\n       73,   55,   85,   87,   74,   59,   89,   90,   69,   73,\n       75,   93,   75,   74,   83,   75,   88,   94,   98,   85,\n       95,   87,   89,   92,   88,   97,   93,   99,  110,  113,\n      119,   94,  123,  120,   90,   98,   95,  122,  113,  125,\n      126,   97,  127,  119,  128,  129,  130,  113,  120,  123,\n      110,  133,  138,  131,  136,  122,  125,  142,   99,  139,\n      143,  128,  144,  145,  127,  126,  146,  147,  150,  153,\n\n      142,  154,  157,  138,  158,  129,  130,  131,  139,  136,\n      155,  160,  147,  150,  153,  145,  161,  143,  146,  157,\n      133,  158,  144,  160,  163,  166,  155,  164,  162,  159,\n      154,  156,  152,  151,  149,  161,  148,  166,  141,  140,\n      137,  163,  171,  171,  171,  171,  171,  171,  171,  171,\n      172,  172,  172,  172,  172,  172,  172,  172,  173,  134,\n      173,  174,  174,  132,  174,  124,  174,  175,  121,  175,\n      118,  175,  176,  176,  176,  115,  176,  177,  114,  177,\n      177,  177,  177,  109,  177,  178,  178,  178,  178,  178,\n      178,  178,  178,  179,  179,  179,  108,  179,  180,  107,\n\n      180,  104,  180,  181,  102,  181,  181,  182,   96,  182,\n      183,   91,  183,  183,  184,   84,  184,  184,  185,   82,\n      185,  185,   81,   79,   71,   62,   58,   51,   38,   36,\n       35,   34,   33,   29,   27,   26,   23,   22,   19,   15,\n      170,  170,  170,  170,  170,  170,  170,  170,  170,  170,\n      170,  170,  170,  170,  170,  170,  170,  170,  170,  170,\n      170,  170,  170,  170,  170,  170,  170,  170,  170,  170,\n      170,  170,  170,  170,  170,  170,  170,  170,  170,  170,\n      170,  170,  170,  170,  170,  170,  170,  170,  170,  170,\n      170,  170,  170,  170\n\n    } ;\n\n/* The intent behind this definition is that it'll catch\n * any uses of REJECT which flex missed.\n */\n#define REJECT reject_used_but_not_detected\n#define yymore() yymore_used_but_not_detected\n#define YY_MORE_ADJ 0\n#define YY_RESTORE_YY_MORE_OFFSET\n#line 1 \"src/lexer.l\"\n#line 2 \"src/lexer.l\"\n#include <assert.h>\n#include \"jv_alloc.h\"\n#include \"compile.h\"\n\nstruct lexer_param;\n\n#include \"parser.h\"  /* Generated by bison. */\n\n#define YY_USER_ACTION                           \\\n  do {                                           \\\n    yylloc->start = yyget_extra(yyscanner);      \\\n    yylloc->end = yylloc->start + yyleng;        \\\n    yyset_extra(yylloc->end, yyscanner);         \\\n  } while (0);\n\n#line 818 \"src/lexer.c\"\n\n#line 26 \"src/lexer.l\"\n  static int enter(int opening, int state, yyscan_t yyscanner);\n  static int try_exit(int closing, int state, yyscan_t yyscanner);\n#line 823 \"src/lexer.c\"\n#define YY_NO_INPUT 1\n#line 825 \"src/lexer.c\"\n\n#define INITIAL 0\n#define IN_PAREN 1\n#define IN_BRACKET 2\n#define IN_BRACE 3\n#define IN_QQINTERP 4\n#define IN_QQSTRING 5\n#define IN_COMMENT 6\n\n#ifndef YY_NO_UNISTD_H\n/* Special case for \"unistd.h\", since it is non-ANSI. We include it way\n * down here because we want the user's section 1 to have been scanned first.\n * The user has a chance to override it with an option.\n */\n#include <unistd.h>\n#endif\n\n#define YY_EXTRA_TYPE int\n\n/* Holds the entire state of the reentrant scanner. */\nstruct yyguts_t\n    {\n\n    /* User-defined. Not touched by flex. */\n    YY_EXTRA_TYPE yyextra_r;\n\n    /* The rest are the same as the globals declared in the non-reentrant scanner. */\n    FILE *yyin_r, *yyout_r;\n    size_t yy_buffer_stack_top; /**< index of top of stack. */\n    size_t yy_buffer_stack_max; /**< capacity of stack. */\n    YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */\n    char yy_hold_char;\n    int yy_n_chars;\n    int yyleng_r;\n    char *yy_c_buf_p;\n    int yy_init;\n    int yy_start;\n    int yy_did_buffer_switch_on_eof;\n    int yy_start_stack_ptr;\n    int yy_start_stack_depth;\n    int *yy_start_stack;\n    yy_state_type yy_last_accepting_state;\n    char* yy_last_accepting_cpos;\n\n    int yylineno_r;\n    int yy_flex_debug_r;\n\n    char *yytext_r;\n    int yy_more_flag;\n    int yy_more_len;\n\n    YYSTYPE * yylval_r;\n\n    YYLTYPE * yylloc_r;\n\n    }; /* end struct yyguts_t */\n\nstatic int yy_init_globals ( yyscan_t yyscanner );\n\n    /* This must go here because YYSTYPE and YYLTYPE are included\n     * from bison output in section 1.*/\n    #    define yylval yyg->yylval_r\n    \n    #    define yylloc yyg->yylloc_r\n    \nint yylex_init (yyscan_t* scanner);\n\nint yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);\n\n/* Accessor methods to globals.\n   These are made visible to non-reentrant scanners for convenience. */\n\nint yylex_destroy ( yyscan_t yyscanner );\n\nint yyget_debug ( yyscan_t yyscanner );\n\nvoid yyset_debug ( int debug_flag , yyscan_t yyscanner );\n\nYY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );\n\nvoid yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );\n\nFILE *yyget_in ( yyscan_t yyscanner );\n\nvoid yyset_in  ( FILE * _in_str , yyscan_t yyscanner );\n\nFILE *yyget_out ( yyscan_t yyscanner );\n\nvoid yyset_out  ( FILE * _out_str , yyscan_t yyscanner );\n\n\t\t\tint yyget_leng ( yyscan_t yyscanner );\n\nchar *yyget_text ( yyscan_t yyscanner );\n\nint yyget_lineno ( yyscan_t yyscanner );\n\nvoid yyset_lineno ( int _line_number , yyscan_t yyscanner );\n\nint yyget_column  ( yyscan_t yyscanner );\n\nvoid yyset_column ( int _column_no , yyscan_t yyscanner );\n\nYYSTYPE * yyget_lval ( yyscan_t yyscanner );\n\nvoid yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );\n\n       YYLTYPE *yyget_lloc ( yyscan_t yyscanner );\n    \n        void yyset_lloc ( YYLTYPE * yylloc_param , yyscan_t yyscanner );\n    \n/* Macros after this point can all be overridden by user definitions in\n * section 1.\n */\n\n#ifndef YY_SKIP_YYWRAP\n#ifdef __cplusplus\nextern \"C\" int yywrap ( yyscan_t yyscanner );\n#else\nextern int yywrap ( yyscan_t yyscanner );\n#endif\n#endif\n\n#ifndef YY_NO_UNPUT\n    \n#endif\n\n#ifndef yytext_ptr\nstatic void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);\n#endif\n\n#ifdef YY_NEED_STRLEN\nstatic int yy_flex_strlen ( const char * , yyscan_t yyscanner);\n#endif\n\n#ifndef YY_NO_INPUT\n#ifdef __cplusplus\nstatic int yyinput ( yyscan_t yyscanner );\n#else\nstatic int input ( yyscan_t yyscanner );\n#endif\n\n#endif\n\n    static void yy_push_state ( int _new_state , yyscan_t yyscanner);\n    \n    static void yy_pop_state ( yyscan_t yyscanner );\n    \n    static int yy_top_state ( yyscan_t yyscanner );\n    \n/* Amount of stuff to slurp up with each read. */\n#ifndef YY_READ_BUF_SIZE\n#ifdef __ia64__\n/* On IA-64, the buffer size is 16k, not 8k */\n#define YY_READ_BUF_SIZE 16384\n#else\n#define YY_READ_BUF_SIZE 8192\n#endif /* __ia64__ */\n#endif\n\n/* Copy whatever the last rule matched to the standard output. */\n#ifndef ECHO\n/* This used to be an fputs(), but since the string might contain NUL's,\n * we now use fwrite().\n */\n#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)\n#endif\n\n/* Gets input and stuffs it into \"buf\".  number of characters read, or YY_NULL,\n * is returned in \"result\".\n */\n#ifndef YY_INPUT\n#define YY_INPUT(buf,result,max_size) \\\n\tif ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \\\n\t\t{ \\\n\t\tint c = '*'; \\\n\t\tint n; \\\n\t\tfor ( n = 0; n < max_size && \\\n\t\t\t     (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\\n\t\t\tbuf[n] = (char) c; \\\n\t\tif ( c == '\\n' ) \\\n\t\t\tbuf[n++] = (char) c; \\\n\t\tif ( c == EOF && ferror( yyin ) ) \\\n\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\\n\t\tresult = n; \\\n\t\t} \\\n\telse \\\n\t\t{ \\\n\t\terrno=0; \\\n\t\twhile ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \\\n\t\t\t{ \\\n\t\t\tif( errno != EINTR) \\\n\t\t\t\t{ \\\n\t\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\\n\t\t\t\tbreak; \\\n\t\t\t\t} \\\n\t\t\terrno=0; \\\n\t\t\tclearerr(yyin); \\\n\t\t\t} \\\n\t\t}\\\n\\\n\n#endif\n\n/* No semi-colon after return; correct usage is to write \"yyterminate();\" -\n * we don't want an extra ';' after the \"return\" because that will cause\n * some compilers to complain about unreachable statements.\n */\n#ifndef yyterminate\n#define yyterminate() return YY_NULL\n#endif\n\n/* Number of entries by which start-condition stack grows. */\n#ifndef YY_START_STACK_INCR\n#define YY_START_STACK_INCR 25\n#endif\n\n/* Report a fatal error. */\n#ifndef YY_FATAL_ERROR\n#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)\n#endif\n\n/* end tables serialization structures and prototypes */\n\n/* Default declaration of generated scanner - a define so the user can\n * easily add parameters.\n */\n#ifndef YY_DECL\n#define YY_DECL_IS_OURS 1\n\nextern int yylex \\\n               (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner);\n\n#define YY_DECL int yylex \\\n               (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)\n#endif /* !YY_DECL */\n\n/* Code executed at the beginning of each rule, after yytext and yyleng\n * have been set up.\n */\n#ifndef YY_USER_ACTION\n#define YY_USER_ACTION\n#endif\n\n/* Code executed at the end of each rule. */\n#ifndef YY_BREAK\n#define YY_BREAK /*LINTED*/break;\n#endif\n\n#define YY_RULE_SETUP \\\n\tYY_USER_ACTION\n\n/** The main scanner function which does all the work.\n */\nYY_DECL\n{\n\tyy_state_type yy_current_state;\n\tchar *yy_cp, *yy_bp;\n\tint yy_act;\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n    yylval = yylval_param;\n\n    yylloc = yylloc_param;\n\n\tif ( !yyg->yy_init )\n\t\t{\n\t\tyyg->yy_init = 1;\n\n#ifdef YY_USER_INIT\n\t\tYY_USER_INIT;\n#endif\n\n\t\tif ( ! yyg->yy_start )\n\t\t\tyyg->yy_start = 1;\t/* first start state */\n\n\t\tif ( ! yyin )\n\t\t\tyyin = stdin;\n\n\t\tif ( ! yyout )\n\t\t\tyyout = stdout;\n\n\t\tif ( ! YY_CURRENT_BUFFER ) {\n\t\t\tyyensure_buffer_stack (yyscanner);\n\t\t\tYY_CURRENT_BUFFER_LVALUE =\n\t\t\t\tyy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);\n\t\t}\n\n\t\tyy_load_buffer_state( yyscanner );\n\t\t}\n\n\t{\n#line 39 \"src/lexer.l\"\n\n\n#line 1120 \"src/lexer.c\"\n\n\twhile ( /*CONSTCOND*/1 )\t\t/* loops until end-of-file is reached */\n\t\t{\n\t\tyy_cp = yyg->yy_c_buf_p;\n\n\t\t/* Support of yytext. */\n\t\t*yy_cp = yyg->yy_hold_char;\n\n\t\t/* yy_bp points to the position in yy_ch_buf of the start of\n\t\t * the current run.\n\t\t */\n\t\tyy_bp = yy_cp;\n\n\t\tyy_current_state = yyg->yy_start;\nyy_match:\n\t\tdo\n\t\t\t{\n\t\t\tYY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;\n\t\t\tif ( yy_accept[yy_current_state] )\n\t\t\t\t{\n\t\t\t\tyyg->yy_last_accepting_state = yy_current_state;\n\t\t\t\tyyg->yy_last_accepting_cpos = yy_cp;\n\t\t\t\t}\n\t\t\twhile ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )\n\t\t\t\t{\n\t\t\t\tyy_current_state = (int) yy_def[yy_current_state];\n\t\t\t\tif ( yy_current_state >= 171 )\n\t\t\t\t\tyy_c = yy_meta[yy_c];\n\t\t\t\t}\n\t\t\tyy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];\n\t\t\t++yy_cp;\n\t\t\t}\n\t\twhile ( yy_base[yy_current_state] != 341 );\n\nyy_find_action:\n\t\tyy_act = yy_accept[yy_current_state];\n\t\tif ( yy_act == 0 )\n\t\t\t{ /* have to back up */\n\t\t\tyy_cp = yyg->yy_last_accepting_cpos;\n\t\t\tyy_current_state = yyg->yy_last_accepting_state;\n\t\t\tyy_act = yy_accept[yy_current_state];\n\t\t\t}\n\n\t\tYY_DO_BEFORE_ACTION;\n\ndo_action:\t/* This label is used only to access EOF actions. */\n\n\t\tswitch ( yy_act )\n\t{ /* beginning of action switch */\n\t\t\tcase 0: /* must back up */\n\t\t\t/* undo the effects of YY_DO_BEFORE_ACTION */\n\t\t\t*yy_cp = yyg->yy_hold_char;\n\t\t\tyy_cp = yyg->yy_last_accepting_cpos;\n\t\t\tyy_current_state = yyg->yy_last_accepting_state;\n\t\t\tgoto yy_find_action;\n\ncase 1:\nYY_RULE_SETUP\n#line 41 \"src/lexer.l\"\n{ yy_push_state(IN_COMMENT, yyscanner); }\n\tYY_BREAK\n\ncase 2:\n/* rule 2 can match eol */\nYY_RULE_SETUP\n#line 43 \"src/lexer.l\"\n{ }\n\tYY_BREAK\ncase 3:\n/* rule 3 can match eol */\nYY_RULE_SETUP\n#line 44 \"src/lexer.l\"\n{ yy_pop_state(yyscanner); }\n\tYY_BREAK\n\ncase YY_STATE_EOF(IN_COMMENT):\n#line 46 \"src/lexer.l\"\n{ yy_pop_state(yyscanner); }\n\tYY_BREAK\ncase 4:\nYY_RULE_SETUP\n#line 48 \"src/lexer.l\"\n{ return NEQ; }\n\tYY_BREAK\ncase 5:\nYY_RULE_SETUP\n#line 49 \"src/lexer.l\"\n{ return EQ; }\n\tYY_BREAK\ncase 6:\nYY_RULE_SETUP\n#line 50 \"src/lexer.l\"\n{ return AS; }\n\tYY_BREAK\ncase 7:\nYY_RULE_SETUP\n#line 51 \"src/lexer.l\"\n{ return IMPORT; }\n\tYY_BREAK\ncase 8:\nYY_RULE_SETUP\n#line 52 \"src/lexer.l\"\n{ return INCLUDE; }\n\tYY_BREAK\ncase 9:\nYY_RULE_SETUP\n#line 53 \"src/lexer.l\"\n{ return MODULE; }\n\tYY_BREAK\ncase 10:\nYY_RULE_SETUP\n#line 54 \"src/lexer.l\"\n{ return DEF; }\n\tYY_BREAK\ncase 11:\nYY_RULE_SETUP\n#line 55 \"src/lexer.l\"\n{ return IF; }\n\tYY_BREAK\ncase 12:\nYY_RULE_SETUP\n#line 56 \"src/lexer.l\"\n{ return THEN; }\n\tYY_BREAK\ncase 13:\nYY_RULE_SETUP\n#line 57 \"src/lexer.l\"\n{ return ELSE; }\n\tYY_BREAK\ncase 14:\nYY_RULE_SETUP\n#line 58 \"src/lexer.l\"\n{ return ELSE_IF; }\n\tYY_BREAK\ncase 15:\nYY_RULE_SETUP\n#line 59 \"src/lexer.l\"\n{ return AND; }\n\tYY_BREAK\ncase 16:\nYY_RULE_SETUP\n#line 60 \"src/lexer.l\"\n{ return OR; }\n\tYY_BREAK\ncase 17:\nYY_RULE_SETUP\n#line 61 \"src/lexer.l\"\n{ return END; }\n\tYY_BREAK\ncase 18:\nYY_RULE_SETUP\n#line 62 \"src/lexer.l\"\n{ return REDUCE; }\n\tYY_BREAK\ncase 19:\nYY_RULE_SETUP\n#line 63 \"src/lexer.l\"\n{ return FOREACH; }\n\tYY_BREAK\ncase 20:\nYY_RULE_SETUP\n#line 64 \"src/lexer.l\"\n{ return DEFINEDOR; }\n\tYY_BREAK\ncase 21:\nYY_RULE_SETUP\n#line 65 \"src/lexer.l\"\n{ return TRY; }\n\tYY_BREAK\ncase 22:\nYY_RULE_SETUP\n#line 66 \"src/lexer.l\"\n{ return CATCH; }\n\tYY_BREAK\ncase 23:\nYY_RULE_SETUP\n#line 67 \"src/lexer.l\"\n{ return LABEL; }\n\tYY_BREAK\ncase 24:\nYY_RULE_SETUP\n#line 68 \"src/lexer.l\"\n{ return BREAK; }\n\tYY_BREAK\ncase 25:\nYY_RULE_SETUP\n#line 69 \"src/lexer.l\"\n{ return LOC; }\n\tYY_BREAK\ncase 26:\nYY_RULE_SETUP\n#line 70 \"src/lexer.l\"\n{ return SETPIPE; }\n\tYY_BREAK\ncase 27:\nYY_RULE_SETUP\n#line 71 \"src/lexer.l\"\n{ return SETPLUS; }\n\tYY_BREAK\ncase 28:\nYY_RULE_SETUP\n#line 72 \"src/lexer.l\"\n{ return SETMINUS; }\n\tYY_BREAK\ncase 29:\nYY_RULE_SETUP\n#line 73 \"src/lexer.l\"\n{ return SETMULT; }\n\tYY_BREAK\ncase 30:\nYY_RULE_SETUP\n#line 74 \"src/lexer.l\"\n{ return SETDIV; }\n\tYY_BREAK\ncase 31:\nYY_RULE_SETUP\n#line 75 \"src/lexer.l\"\n{ return SETMOD; }\n\tYY_BREAK\ncase 32:\nYY_RULE_SETUP\n#line 76 \"src/lexer.l\"\n{ return SETDEFINEDOR; }\n\tYY_BREAK\ncase 33:\nYY_RULE_SETUP\n#line 77 \"src/lexer.l\"\n{ return LESSEQ; }\n\tYY_BREAK\ncase 34:\nYY_RULE_SETUP\n#line 78 \"src/lexer.l\"\n{ return GREATEREQ; }\n\tYY_BREAK\ncase 35:\nYY_RULE_SETUP\n#line 79 \"src/lexer.l\"\n{ return REC; }\n\tYY_BREAK\ncase 36:\nYY_RULE_SETUP\n#line 80 \"src/lexer.l\"\n{ return ALTERNATION; }\n\tYY_BREAK\ncase 37:\nYY_RULE_SETUP\n#line 81 \"src/lexer.l\"\n{ return yytext[0];}\n\tYY_BREAK\ncase 38:\nYY_RULE_SETUP\n#line 83 \"src/lexer.l\"\n{\n  return enter(yytext[0], YY_START, yyscanner);\n}\n\tYY_BREAK\ncase 39:\nYY_RULE_SETUP\n#line 87 \"src/lexer.l\"\n{\n  return try_exit(yytext[0], YY_START, yyscanner);\n}\n\tYY_BREAK\ncase 40:\nYY_RULE_SETUP\n#line 91 \"src/lexer.l\"\n{\n  yylval->literal = jv_string_sized(yytext + 1, yyleng - 1); return FORMAT;\n}\n\tYY_BREAK\ncase 41:\nYY_RULE_SETUP\n#line 95 \"src/lexer.l\"\n{\n   yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL;\n}\n\tYY_BREAK\ncase 42:\nYY_RULE_SETUP\n#line 99 \"src/lexer.l\"\n{\n  yy_push_state(IN_QQSTRING, yyscanner);\n  return QQSTRING_START;\n}\n\tYY_BREAK\n\ncase 43:\nYY_RULE_SETUP\n#line 105 \"src/lexer.l\"\n{\n    return enter(QQSTRING_INTERP_START, YY_START, yyscanner);\n  }\n\tYY_BREAK\ncase 44:\nYY_RULE_SETUP\n#line 108 \"src/lexer.l\"\n{\n    yy_pop_state(yyscanner);\n    return QQSTRING_END;\n  }\n\tYY_BREAK\ncase 45:\n/* rule 45 can match eol */\nYY_RULE_SETUP\n#line 112 \"src/lexer.l\"\n{\n    /* pass escapes to the json parser */\n    jv escapes = jv_string_fmt(\"\\\"%.*s\\\"\", (int)yyleng, yytext);\n    yylval->literal = jv_parse_sized(jv_string_value(escapes), jv_string_length_bytes(jv_copy(escapes)));\n    jv_free(escapes);\n    return QQSTRING_TEXT;\n  }\n\tYY_BREAK\ncase 46:\n/* rule 46 can match eol */\nYY_RULE_SETUP\n#line 119 \"src/lexer.l\"\n{\n    yylval->literal = jv_string_sized(yytext, yyleng);\n    return QQSTRING_TEXT;\n  }\n\tYY_BREAK\ncase 47:\nYY_RULE_SETUP\n#line 123 \"src/lexer.l\"\n{\n    return INVALID_CHARACTER;\n  }\n\tYY_BREAK\n\ncase 48:\nYY_RULE_SETUP\n#line 129 \"src/lexer.l\"\n{ yylval->literal = jv_string(yytext); return IDENT;}\n\tYY_BREAK\ncase 49:\nYY_RULE_SETUP\n#line 130 \"src/lexer.l\"\n{ yylval->literal = jv_string(yytext+1); return FIELD;}\n\tYY_BREAK\ncase 50:\nYY_RULE_SETUP\n#line 131 \"src/lexer.l\"\n{ yylval->literal = jv_string(yytext+1); return BINDING;}\n\tYY_BREAK\ncase 51:\n/* rule 51 can match eol */\nYY_RULE_SETUP\n#line 133 \"src/lexer.l\"\n{}\n\tYY_BREAK\ncase 52:\nYY_RULE_SETUP\n#line 135 \"src/lexer.l\"\n{ return INVALID_CHARACTER; }\n\tYY_BREAK\ncase 53:\nYY_RULE_SETUP\n#line 137 \"src/lexer.l\"\nYY_FATAL_ERROR( \"flex scanner jammed\" );\n\tYY_BREAK\n#line 1482 \"src/lexer.c\"\ncase YY_STATE_EOF(INITIAL):\ncase YY_STATE_EOF(IN_PAREN):\ncase YY_STATE_EOF(IN_BRACKET):\ncase YY_STATE_EOF(IN_BRACE):\ncase YY_STATE_EOF(IN_QQINTERP):\ncase YY_STATE_EOF(IN_QQSTRING):\n\tyyterminate();\n\n\tcase YY_END_OF_BUFFER:\n\t\t{\n\t\t/* Amount of text matched not including the EOB char. */\n\t\tint yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;\n\n\t\t/* Undo the effects of YY_DO_BEFORE_ACTION. */\n\t\t*yy_cp = yyg->yy_hold_char;\n\t\tYY_RESTORE_YY_MORE_OFFSET\n\n\t\tif ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )\n\t\t\t{\n\t\t\t/* We're scanning a new file or input source.  It's\n\t\t\t * possible that this happened because the user\n\t\t\t * just pointed yyin at a new source and called\n\t\t\t * yylex().  If so, then we have to assure\n\t\t\t * consistency between YY_CURRENT_BUFFER and our\n\t\t\t * globals.  Here is the right place to do so, because\n\t\t\t * this is the first action (other than possibly a\n\t\t\t * back-up) that will match for the new input source.\n\t\t\t */\n\t\t\tyyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;\n\t\t\tYY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;\n\t\t\tYY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;\n\t\t\t}\n\n\t\t/* Note that here we test for yy_c_buf_p \"<=\" to the position\n\t\t * of the first EOB in the buffer, since yy_c_buf_p will\n\t\t * already have been incremented past the NUL character\n\t\t * (since all states make transitions on EOB to the\n\t\t * end-of-buffer state).  Contrast this with the test\n\t\t * in input().\n\t\t */\n\t\tif ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )\n\t\t\t{ /* This was really a NUL. */\n\t\t\tyy_state_type yy_next_state;\n\n\t\t\tyyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;\n\n\t\t\tyy_current_state = yy_get_previous_state( yyscanner );\n\n\t\t\t/* Okay, we're now positioned to make the NUL\n\t\t\t * transition.  We couldn't have\n\t\t\t * yy_get_previous_state() go ahead and do it\n\t\t\t * for us because it doesn't know how to deal\n\t\t\t * with the possibility of jamming (and we don't\n\t\t\t * want to build jamming into it because then it\n\t\t\t * will run more slowly).\n\t\t\t */\n\n\t\t\tyy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);\n\n\t\t\tyy_bp = yyg->yytext_ptr + YY_MORE_ADJ;\n\n\t\t\tif ( yy_next_state )\n\t\t\t\t{\n\t\t\t\t/* Consume the NUL. */\n\t\t\t\tyy_cp = ++yyg->yy_c_buf_p;\n\t\t\t\tyy_current_state = yy_next_state;\n\t\t\t\tgoto yy_match;\n\t\t\t\t}\n\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tyy_cp = yyg->yy_c_buf_p;\n\t\t\t\tgoto yy_find_action;\n\t\t\t\t}\n\t\t\t}\n\n\t\telse switch ( yy_get_next_buffer( yyscanner ) )\n\t\t\t{\n\t\t\tcase EOB_ACT_END_OF_FILE:\n\t\t\t\t{\n\t\t\t\tyyg->yy_did_buffer_switch_on_eof = 0;\n\n\t\t\t\tif ( yywrap( yyscanner ) )\n\t\t\t\t\t{\n\t\t\t\t\t/* Note: because we've taken care in\n\t\t\t\t\t * yy_get_next_buffer() to have set up\n\t\t\t\t\t * yytext, we can now set up\n\t\t\t\t\t * yy_c_buf_p so that if some total\n\t\t\t\t\t * hoser (like flex itself) wants to\n\t\t\t\t\t * call the scanner after we return the\n\t\t\t\t\t * YY_NULL, it'll still work - another\n\t\t\t\t\t * YY_NULL will get returned.\n\t\t\t\t\t */\n\t\t\t\t\tyyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;\n\n\t\t\t\t\tyy_act = YY_STATE_EOF(YY_START);\n\t\t\t\t\tgoto do_action;\n\t\t\t\t\t}\n\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\tif ( ! yyg->yy_did_buffer_switch_on_eof )\n\t\t\t\t\t\tYY_NEW_FILE;\n\t\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\tcase EOB_ACT_CONTINUE_SCAN:\n\t\t\t\tyyg->yy_c_buf_p =\n\t\t\t\t\tyyg->yytext_ptr + yy_amount_of_matched_text;\n\n\t\t\t\tyy_current_state = yy_get_previous_state( yyscanner );\n\n\t\t\t\tyy_cp = yyg->yy_c_buf_p;\n\t\t\t\tyy_bp = yyg->yytext_ptr + YY_MORE_ADJ;\n\t\t\t\tgoto yy_match;\n\n\t\t\tcase EOB_ACT_LAST_MATCH:\n\t\t\t\tyyg->yy_c_buf_p =\n\t\t\t\t&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];\n\n\t\t\t\tyy_current_state = yy_get_previous_state( yyscanner );\n\n\t\t\t\tyy_cp = yyg->yy_c_buf_p;\n\t\t\t\tyy_bp = yyg->yytext_ptr + YY_MORE_ADJ;\n\t\t\t\tgoto yy_find_action;\n\t\t\t}\n\t\tbreak;\n\t\t}\n\n\tdefault:\n\t\tYY_FATAL_ERROR(\n\t\t\t\"fatal flex scanner internal error--no action found\" );\n\t} /* end of action switch */\n\t\t} /* end of scanning one token */\n\t} /* end of user's declarations */\n} /* end of yylex */\n\n/* yy_get_next_buffer - try to read in a new buffer\n *\n * Returns a code representing an action:\n *\tEOB_ACT_LAST_MATCH -\n *\tEOB_ACT_CONTINUE_SCAN - continue scanning from current position\n *\tEOB_ACT_END_OF_FILE - end of file\n */\nstatic int yy_get_next_buffer (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\tchar *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;\n\tchar *source = yyg->yytext_ptr;\n\tint number_to_move, i;\n\tint ret_val;\n\n\tif ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )\n\t\tYY_FATAL_ERROR(\n\t\t\"fatal flex scanner internal error--end of buffer missed\" );\n\n\tif ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )\n\t\t{ /* Don't try to fill the buffer, so this is an EOF. */\n\t\tif ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )\n\t\t\t{\n\t\t\t/* We matched a single character, the EOB, so\n\t\t\t * treat this as a final EOF.\n\t\t\t */\n\t\t\treturn EOB_ACT_END_OF_FILE;\n\t\t\t}\n\n\t\telse\n\t\t\t{\n\t\t\t/* We matched some text prior to the EOB, first\n\t\t\t * process it.\n\t\t\t */\n\t\t\treturn EOB_ACT_LAST_MATCH;\n\t\t\t}\n\t\t}\n\n\t/* Try to read more data. */\n\n\t/* First move last chars to start of buffer. */\n\tnumber_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);\n\n\tfor ( i = 0; i < number_to_move; ++i )\n\t\t*(dest++) = *(source++);\n\n\tif ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )\n\t\t/* don't do the read, it's not guaranteed to return an EOF,\n\t\t * just force an EOF\n\t\t */\n\t\tYY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;\n\n\telse\n\t\t{\n\t\t\tint num_to_read =\n\t\t\tYY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;\n\n\t\twhile ( num_to_read <= 0 )\n\t\t\t{ /* Not enough room in the buffer - grow it. */\n\n\t\t\t/* just a shorter name for the current buffer */\n\t\t\tYY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;\n\n\t\t\tint yy_c_buf_p_offset =\n\t\t\t\t(int) (yyg->yy_c_buf_p - b->yy_ch_buf);\n\n\t\t\tif ( b->yy_is_our_buffer )\n\t\t\t\t{\n\t\t\t\tint new_size = b->yy_buf_size * 2;\n\n\t\t\t\tif ( new_size <= 0 )\n\t\t\t\t\tb->yy_buf_size += b->yy_buf_size / 8;\n\t\t\t\telse\n\t\t\t\t\tb->yy_buf_size *= 2;\n\n\t\t\t\tb->yy_ch_buf = (char *)\n\t\t\t\t\t/* Include room in for 2 EOB chars. */\n\t\t\t\t\tyyrealloc( (void *) b->yy_ch_buf,\n\t\t\t\t\t\t\t (yy_size_t) (b->yy_buf_size + 2) , yyscanner );\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t/* Can't grow it, we don't own it. */\n\t\t\t\tb->yy_ch_buf = NULL;\n\n\t\t\tif ( ! b->yy_ch_buf )\n\t\t\t\tYY_FATAL_ERROR(\n\t\t\t\t\"fatal error - scanner input buffer overflow\" );\n\n\t\t\tyyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];\n\n\t\t\tnum_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -\n\t\t\t\t\t\tnumber_to_move - 1;\n\n\t\t\t}\n\n\t\tif ( num_to_read > YY_READ_BUF_SIZE )\n\t\t\tnum_to_read = YY_READ_BUF_SIZE;\n\n\t\t/* Read in more data. */\n\t\tYY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),\n\t\t\tyyg->yy_n_chars, num_to_read );\n\n\t\tYY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;\n\t\t}\n\n\tif ( yyg->yy_n_chars == 0 )\n\t\t{\n\t\tif ( number_to_move == YY_MORE_ADJ )\n\t\t\t{\n\t\t\tret_val = EOB_ACT_END_OF_FILE;\n\t\t\tyyrestart( yyin  , yyscanner);\n\t\t\t}\n\n\t\telse\n\t\t\t{\n\t\t\tret_val = EOB_ACT_LAST_MATCH;\n\t\t\tYY_CURRENT_BUFFER_LVALUE->yy_buffer_status =\n\t\t\t\tYY_BUFFER_EOF_PENDING;\n\t\t\t}\n\t\t}\n\n\telse\n\t\tret_val = EOB_ACT_CONTINUE_SCAN;\n\n\tif ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {\n\t\t/* Extend the array by 50%, plus the number we really need. */\n\t\tint new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);\n\t\tYY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(\n\t\t\t(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );\n\t\tif ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )\n\t\t\tYY_FATAL_ERROR( \"out of dynamic memory in yy_get_next_buffer()\" );\n\t\t/* \"- 2\" to take care of EOB's */\n\t\tYY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);\n\t}\n\n\tyyg->yy_n_chars += number_to_move;\n\tYY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;\n\tYY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;\n\n\tyyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];\n\n\treturn ret_val;\n}\n\n/* yy_get_previous_state - get the state just before the EOB char was reached */\n\n    static yy_state_type yy_get_previous_state (yyscan_t yyscanner)\n{\n\tyy_state_type yy_current_state;\n\tchar *yy_cp;\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\tyy_current_state = yyg->yy_start;\n\n\tfor ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )\n\t\t{\n\t\tYY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);\n\t\tif ( yy_accept[yy_current_state] )\n\t\t\t{\n\t\t\tyyg->yy_last_accepting_state = yy_current_state;\n\t\t\tyyg->yy_last_accepting_cpos = yy_cp;\n\t\t\t}\n\t\twhile ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )\n\t\t\t{\n\t\t\tyy_current_state = (int) yy_def[yy_current_state];\n\t\t\tif ( yy_current_state >= 171 )\n\t\t\t\tyy_c = yy_meta[yy_c];\n\t\t\t}\n\t\tyy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];\n\t\t}\n\n\treturn yy_current_state;\n}\n\n/* yy_try_NUL_trans - try to make a transition on the NUL character\n *\n * synopsis\n *\tnext_state = yy_try_NUL_trans( current_state );\n */\n    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)\n{\n\tint yy_is_jam;\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */\n\tchar *yy_cp = yyg->yy_c_buf_p;\n\n\tYY_CHAR yy_c = 1;\n\tif ( yy_accept[yy_current_state] )\n\t\t{\n\t\tyyg->yy_last_accepting_state = yy_current_state;\n\t\tyyg->yy_last_accepting_cpos = yy_cp;\n\t\t}\n\twhile ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )\n\t\t{\n\t\tyy_current_state = (int) yy_def[yy_current_state];\n\t\tif ( yy_current_state >= 171 )\n\t\t\tyy_c = yy_meta[yy_c];\n\t\t}\n\tyy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];\n\tyy_is_jam = (yy_current_state == 170);\n\n\t(void)yyg;\n\treturn yy_is_jam ? 0 : yy_current_state;\n}\n\n#ifndef YY_NO_UNPUT\n\n#endif\n\n#ifndef YY_NO_INPUT\n#ifdef __cplusplus\n    static int yyinput (yyscan_t yyscanner)\n#else\n    static int input  (yyscan_t yyscanner)\n#endif\n\n{\n\tint c;\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\t*yyg->yy_c_buf_p = yyg->yy_hold_char;\n\n\tif ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )\n\t\t{\n\t\t/* yy_c_buf_p now points to the character we want to return.\n\t\t * If this occurs *before* the EOB characters, then it's a\n\t\t * valid NUL; if not, then we've hit the end of the buffer.\n\t\t */\n\t\tif ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )\n\t\t\t/* This was really a NUL. */\n\t\t\t*yyg->yy_c_buf_p = '\\0';\n\n\t\telse\n\t\t\t{ /* need more input */\n\t\t\tint offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);\n\t\t\t++yyg->yy_c_buf_p;\n\n\t\t\tswitch ( yy_get_next_buffer( yyscanner ) )\n\t\t\t\t{\n\t\t\t\tcase EOB_ACT_LAST_MATCH:\n\t\t\t\t\t/* This happens because yy_g_n_b()\n\t\t\t\t\t * sees that we've accumulated a\n\t\t\t\t\t * token and flags that we need to\n\t\t\t\t\t * try matching the token before\n\t\t\t\t\t * proceeding.  But for input(),\n\t\t\t\t\t * there's no matching to consider.\n\t\t\t\t\t * So convert the EOB_ACT_LAST_MATCH\n\t\t\t\t\t * to EOB_ACT_END_OF_FILE.\n\t\t\t\t\t */\n\n\t\t\t\t\t/* Reset buffer status. */\n\t\t\t\t\tyyrestart( yyin , yyscanner);\n\n\t\t\t\t\t/*FALLTHROUGH*/\n\n\t\t\t\tcase EOB_ACT_END_OF_FILE:\n\t\t\t\t\t{\n\t\t\t\t\tif ( yywrap( yyscanner ) )\n\t\t\t\t\t\treturn 0;\n\n\t\t\t\t\tif ( ! yyg->yy_did_buffer_switch_on_eof )\n\t\t\t\t\t\tYY_NEW_FILE;\n#ifdef __cplusplus\n\t\t\t\t\treturn yyinput(yyscanner);\n#else\n\t\t\t\t\treturn input(yyscanner);\n#endif\n\t\t\t\t\t}\n\n\t\t\t\tcase EOB_ACT_CONTINUE_SCAN:\n\t\t\t\t\tyyg->yy_c_buf_p = yyg->yytext_ptr + offset;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\tc = *(unsigned char *) yyg->yy_c_buf_p;\t/* cast for 8-bit char's */\n\t*yyg->yy_c_buf_p = '\\0';\t/* preserve yytext */\n\tyyg->yy_hold_char = *++yyg->yy_c_buf_p;\n\n\treturn c;\n}\n#endif\t/* ifndef YY_NO_INPUT */\n\n/** Immediately switch to a different input stream.\n * @param input_file A readable stream.\n * @param yyscanner The scanner object.\n * @note This function does not reset the start condition to @c INITIAL .\n */\n    void yyrestart  (FILE * input_file , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\tif ( ! YY_CURRENT_BUFFER ){\n        yyensure_buffer_stack (yyscanner);\n\t\tYY_CURRENT_BUFFER_LVALUE =\n            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);\n\t}\n\n\tyy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);\n\tyy_load_buffer_state( yyscanner );\n}\n\n/** Switch to a different input buffer.\n * @param new_buffer The new input buffer.\n * @param yyscanner The scanner object.\n */\n    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\t/* TODO. We should be able to replace this entire function body\n\t * with\n\t *\t\tyypop_buffer_state();\n\t *\t\tyypush_buffer_state(new_buffer);\n     */\n\tyyensure_buffer_stack (yyscanner);\n\tif ( YY_CURRENT_BUFFER == new_buffer )\n\t\treturn;\n\n\tif ( YY_CURRENT_BUFFER )\n\t\t{\n\t\t/* Flush out information for old buffer. */\n\t\t*yyg->yy_c_buf_p = yyg->yy_hold_char;\n\t\tYY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;\n\t\tYY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;\n\t\t}\n\n\tYY_CURRENT_BUFFER_LVALUE = new_buffer;\n\tyy_load_buffer_state( yyscanner );\n\n\t/* We don't actually know whether we did this switch during\n\t * EOF (yywrap()) processing, but the only time this flag\n\t * is looked at is after yywrap() is called, so it's safe\n\t * to go ahead and always set it.\n\t */\n\tyyg->yy_did_buffer_switch_on_eof = 1;\n}\n\nstatic void yy_load_buffer_state  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\tyyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;\n\tyyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;\n\tyyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;\n\tyyg->yy_hold_char = *yyg->yy_c_buf_p;\n}\n\n/** Allocate and initialize an input buffer state.\n * @param file A readable stream.\n * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.\n * @param yyscanner The scanner object.\n * @return the allocated buffer state.\n */\n    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)\n{\n\tYY_BUFFER_STATE b;\n    \n\tb = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );\n\tif ( ! b )\n\t\tYY_FATAL_ERROR( \"out of dynamic memory in yy_create_buffer()\" );\n\n\tb->yy_buf_size = size;\n\n\t/* yy_ch_buf has to be 2 characters longer than the size given because\n\t * we need to put in 2 end-of-buffer characters.\n\t */\n\tb->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );\n\tif ( ! b->yy_ch_buf )\n\t\tYY_FATAL_ERROR( \"out of dynamic memory in yy_create_buffer()\" );\n\n\tb->yy_is_our_buffer = 1;\n\n\tyy_init_buffer( b, file , yyscanner);\n\n\treturn b;\n}\n\n/** Destroy the buffer.\n * @param b a buffer created with yy_create_buffer()\n * @param yyscanner The scanner object.\n */\n    void yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\tif ( ! b )\n\t\treturn;\n\n\tif ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */\n\t\tYY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;\n\n\tif ( b->yy_is_our_buffer )\n\t\tyyfree( (void *) b->yy_ch_buf , yyscanner );\n\n\tyyfree( (void *) b , yyscanner );\n}\n\n/* Initializes or reinitializes a buffer.\n * This function is sometimes called more than once on the same buffer,\n * such as during a yyrestart() or at EOF.\n */\n    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)\n\n{\n\tint oerrno = errno;\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\tyy_flush_buffer( b , yyscanner);\n\n\tb->yy_input_file = file;\n\tb->yy_fill_buffer = 1;\n\n    /* If b is the current buffer, then yy_init_buffer was _probably_\n     * called from yyrestart() or through yy_get_next_buffer.\n     * In that case, we don't want to reset the lineno or column.\n     */\n    if (b != YY_CURRENT_BUFFER){\n        b->yy_bs_lineno = 1;\n        b->yy_bs_column = 0;\n    }\n\n        b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;\n    \n\terrno = oerrno;\n}\n\n/** Discard all buffered characters. On the next scan, YY_INPUT will be called.\n * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.\n * @param yyscanner The scanner object.\n */\n    void yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\tif ( ! b )\n\t\treturn;\n\n\tb->yy_n_chars = 0;\n\n\t/* We always need two end-of-buffer characters.  The first causes\n\t * a transition to the end-of-buffer state.  The second causes\n\t * a jam in that state.\n\t */\n\tb->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;\n\tb->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;\n\n\tb->yy_buf_pos = &b->yy_ch_buf[0];\n\n\tb->yy_at_bol = 1;\n\tb->yy_buffer_status = YY_BUFFER_NEW;\n\n\tif ( b == YY_CURRENT_BUFFER )\n\t\tyy_load_buffer_state( yyscanner );\n}\n\n/** Pushes the new state onto the stack. The new state becomes\n *  the current state. This function will allocate the stack\n *  if necessary.\n *  @param new_buffer The new state.\n *  @param yyscanner The scanner object.\n */\nvoid yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\tif (new_buffer == NULL)\n\t\treturn;\n\n\tyyensure_buffer_stack(yyscanner);\n\n\t/* This block is copied from yy_switch_to_buffer. */\n\tif ( YY_CURRENT_BUFFER )\n\t\t{\n\t\t/* Flush out information for old buffer. */\n\t\t*yyg->yy_c_buf_p = yyg->yy_hold_char;\n\t\tYY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;\n\t\tYY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;\n\t\t}\n\n\t/* Only push if top exists. Otherwise, replace top. */\n\tif (YY_CURRENT_BUFFER)\n\t\tyyg->yy_buffer_stack_top++;\n\tYY_CURRENT_BUFFER_LVALUE = new_buffer;\n\n\t/* copied from yy_switch_to_buffer. */\n\tyy_load_buffer_state( yyscanner );\n\tyyg->yy_did_buffer_switch_on_eof = 1;\n}\n\n/** Removes and deletes the top of the stack, if present.\n *  The next element becomes the new top.\n *  @param yyscanner The scanner object.\n */\nvoid yypop_buffer_state (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\tif (!YY_CURRENT_BUFFER)\n\t\treturn;\n\n\tyy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);\n\tYY_CURRENT_BUFFER_LVALUE = NULL;\n\tif (yyg->yy_buffer_stack_top > 0)\n\t\t--yyg->yy_buffer_stack_top;\n\n\tif (YY_CURRENT_BUFFER) {\n\t\tyy_load_buffer_state( yyscanner );\n\t\tyyg->yy_did_buffer_switch_on_eof = 1;\n\t}\n}\n\n/* Allocates the stack if it does not exist.\n *  Guarantees space for at least one push.\n */\nstatic void yyensure_buffer_stack (yyscan_t yyscanner)\n{\n\tyy_size_t num_to_alloc;\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\tif (!yyg->yy_buffer_stack) {\n\n\t\t/* First allocation is just for 2 elements, since we don't know if this\n\t\t * scanner will even need a stack. We use 2 instead of 1 to avoid an\n\t\t * immediate realloc on the next call.\n         */\n      num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */\n\t\tyyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc\n\t\t\t\t\t\t\t\t(num_to_alloc * sizeof(struct yy_buffer_state*)\n\t\t\t\t\t\t\t\t, yyscanner);\n\t\tif ( ! yyg->yy_buffer_stack )\n\t\t\tYY_FATAL_ERROR( \"out of dynamic memory in yyensure_buffer_stack()\" );\n\n\t\tmemset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));\n\n\t\tyyg->yy_buffer_stack_max = num_to_alloc;\n\t\tyyg->yy_buffer_stack_top = 0;\n\t\treturn;\n\t}\n\n\tif (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){\n\n\t\t/* Increase the buffer to prepare for a possible push. */\n\t\tyy_size_t grow_size = 8 /* arbitrary grow size */;\n\n\t\tnum_to_alloc = yyg->yy_buffer_stack_max + grow_size;\n\t\tyyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc\n\t\t\t\t\t\t\t\t(yyg->yy_buffer_stack,\n\t\t\t\t\t\t\t\tnum_to_alloc * sizeof(struct yy_buffer_state*)\n\t\t\t\t\t\t\t\t, yyscanner);\n\t\tif ( ! yyg->yy_buffer_stack )\n\t\t\tYY_FATAL_ERROR( \"out of dynamic memory in yyensure_buffer_stack()\" );\n\n\t\t/* zero only the new slots.*/\n\t\tmemset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));\n\t\tyyg->yy_buffer_stack_max = num_to_alloc;\n\t}\n}\n\n/** Setup the input buffer state to scan directly from a user-specified character buffer.\n * @param base the character buffer\n * @param size the size in bytes of the character buffer\n * @param yyscanner The scanner object.\n * @return the newly allocated buffer state object.\n */\nYY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)\n{\n\tYY_BUFFER_STATE b;\n    \n\tif ( size < 2 ||\n\t     base[size-2] != YY_END_OF_BUFFER_CHAR ||\n\t     base[size-1] != YY_END_OF_BUFFER_CHAR )\n\t\t/* They forgot to leave room for the EOB's. */\n\t\treturn NULL;\n\n\tb = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );\n\tif ( ! b )\n\t\tYY_FATAL_ERROR( \"out of dynamic memory in yy_scan_buffer()\" );\n\n\tb->yy_buf_size = (int) (size - 2);\t/* \"- 2\" to take care of EOB's */\n\tb->yy_buf_pos = b->yy_ch_buf = base;\n\tb->yy_is_our_buffer = 0;\n\tb->yy_input_file = NULL;\n\tb->yy_n_chars = b->yy_buf_size;\n\tb->yy_is_interactive = 0;\n\tb->yy_at_bol = 1;\n\tb->yy_fill_buffer = 0;\n\tb->yy_buffer_status = YY_BUFFER_NEW;\n\n\tyy_switch_to_buffer( b , yyscanner );\n\n\treturn b;\n}\n\n/** Setup the input buffer state to scan a string. The next call to yylex() will\n * scan from a @e copy of @a str.\n * @param yystr a NUL-terminated string to scan\n * @param yyscanner The scanner object.\n * @return the newly allocated buffer state object.\n * @note If you want to scan bytes that may contain NUL values, then use\n *       yy_scan_bytes() instead.\n */\nYY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)\n{\n    \n\treturn yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);\n}\n\n/** Setup the input buffer state to scan the given bytes. The next call to yylex() will\n * scan from a @e copy of @a bytes.\n * @param yybytes the byte buffer to scan\n * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.\n * @param yyscanner The scanner object.\n * @return the newly allocated buffer state object.\n */\nYY_BUFFER_STATE yy_scan_bytes  (const char * yybytes, int  _yybytes_len , yyscan_t yyscanner)\n{\n\tYY_BUFFER_STATE b;\n\tchar *buf;\n\tyy_size_t n;\n\tint i;\n    \n\t/* Get memory for full buffer, including space for trailing EOB's. */\n\tn = (yy_size_t) (_yybytes_len + 2);\n\tbuf = (char *) yyalloc( n , yyscanner );\n\tif ( ! buf )\n\t\tYY_FATAL_ERROR( \"out of dynamic memory in yy_scan_bytes()\" );\n\n\tfor ( i = 0; i < _yybytes_len; ++i )\n\t\tbuf[i] = yybytes[i];\n\n\tbuf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;\n\n\tb = yy_scan_buffer( buf, n , yyscanner);\n\tif ( ! b )\n\t\tYY_FATAL_ERROR( \"bad buffer in yy_scan_bytes()\" );\n\n\t/* It's okay to grow etc. this buffer, and we should throw it\n\t * away when we're done.\n\t */\n\tb->yy_is_our_buffer = 1;\n\n\treturn b;\n}\n\n    static void yy_push_state (int  _new_state , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\tif ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth )\n\t\t{\n\t\tyy_size_t new_size;\n\n\t\tyyg->yy_start_stack_depth += YY_START_STACK_INCR;\n\t\tnew_size = (yy_size_t) yyg->yy_start_stack_depth * sizeof( int );\n\n\t\tif ( ! yyg->yy_start_stack )\n\t\t\tyyg->yy_start_stack = (int *) yyalloc( new_size , yyscanner );\n\n\t\telse\n\t\t\tyyg->yy_start_stack = (int *) yyrealloc(\n\t\t\t\t\t(void *) yyg->yy_start_stack, new_size , yyscanner );\n\n\t\tif ( ! yyg->yy_start_stack )\n\t\t\tYY_FATAL_ERROR( \"out of memory expanding start-condition stack\" );\n\t\t}\n\n\tyyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START;\n\n\tBEGIN(_new_state);\n}\n\n    static void yy_pop_state  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\tif ( --yyg->yy_start_stack_ptr < 0 )\n\t\tYY_FATAL_ERROR( \"start-condition stack underflow\" );\n\n\tBEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]);\n}\n\n    static int yy_top_state  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\treturn yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1];\n}\n\n#ifndef YY_EXIT_FAILURE\n#define YY_EXIT_FAILURE 2\n#endif\n\nstatic void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)\n{\n\tstruct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\t(void)yyg;\n\tfprintf( stderr, \"%s\\n\", msg );\n\texit( YY_EXIT_FAILURE );\n}\n\n/* Redefine yyless() so it works in section 3 code. */\n\n#undef yyless\n#define yyless(n) \\\n\tdo \\\n\t\t{ \\\n\t\t/* Undo effects of setting up yytext. */ \\\n        int yyless_macro_arg = (n); \\\n        YY_LESS_LINENO(yyless_macro_arg);\\\n\t\tyytext[yyleng] = yyg->yy_hold_char; \\\n\t\tyyg->yy_c_buf_p = yytext + yyless_macro_arg; \\\n\t\tyyg->yy_hold_char = *yyg->yy_c_buf_p; \\\n\t\t*yyg->yy_c_buf_p = '\\0'; \\\n\t\tyyleng = yyless_macro_arg; \\\n\t\t} \\\n\twhile ( 0 )\n\n/* Accessor  methods (get/set functions) to struct members. */\n\n/** Get the user-defined data for this scanner.\n * @param yyscanner The scanner object.\n */\nYY_EXTRA_TYPE yyget_extra  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    return yyextra;\n}\n\n/** Get the current line number.\n * @param yyscanner The scanner object.\n */\nint yyget_lineno  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n        if (! YY_CURRENT_BUFFER)\n            return 0;\n    \n    return yylineno;\n}\n\n/** Get the current column number.\n * @param yyscanner The scanner object.\n */\nint yyget_column  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n        if (! YY_CURRENT_BUFFER)\n            return 0;\n    \n    return yycolumn;\n}\n\n/** Get the input stream.\n * @param yyscanner The scanner object.\n */\nFILE *yyget_in  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    return yyin;\n}\n\n/** Get the output stream.\n * @param yyscanner The scanner object.\n */\nFILE *yyget_out  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    return yyout;\n}\n\n/** Get the length of the current token.\n * @param yyscanner The scanner object.\n */\nint yyget_leng  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    return yyleng;\n}\n\n/** Get the current token.\n * @param yyscanner The scanner object.\n */\n\nchar *yyget_text  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    return yytext;\n}\n\n/** Set the user-defined data. This data is never touched by the scanner.\n * @param user_defined The data to be associated with this scanner.\n * @param yyscanner The scanner object.\n */\nvoid yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    yyextra = user_defined ;\n}\n\n/** Set the current line number.\n * @param _line_number line number\n * @param yyscanner The scanner object.\n */\nvoid yyset_lineno (int  _line_number , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n        /* lineno is only valid if an input buffer exists. */\n        if (! YY_CURRENT_BUFFER )\n           YY_FATAL_ERROR( \"yyset_lineno called with no buffer\" );\n    \n    yylineno = _line_number;\n}\n\n/** Set the current column.\n * @param _column_no column number\n * @param yyscanner The scanner object.\n */\nvoid yyset_column (int  _column_no , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n        /* column is only valid if an input buffer exists. */\n        if (! YY_CURRENT_BUFFER )\n           YY_FATAL_ERROR( \"yyset_column called with no buffer\" );\n    \n    yycolumn = _column_no;\n}\n\n/** Set the input stream. This does not discard the current\n * input buffer.\n * @param _in_str A readable stream.\n * @param yyscanner The scanner object.\n * @see yy_switch_to_buffer\n */\nvoid yyset_in (FILE *  _in_str , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    yyin = _in_str ;\n}\n\nvoid yyset_out (FILE *  _out_str , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    yyout = _out_str ;\n}\n\nint yyget_debug  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    return yy_flex_debug;\n}\n\nvoid yyset_debug (int  _bdebug , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    yy_flex_debug = _bdebug ;\n}\n\n/* Accessor methods for yylval and yylloc */\n\nYYSTYPE * yyget_lval  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    return yylval;\n}\n\nvoid yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    yylval = yylval_param;\n}\n\nYYLTYPE *yyget_lloc  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    return yylloc;\n}\n    \nvoid yyset_lloc (YYLTYPE *  yylloc_param , yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    yylloc = yylloc_param;\n}\n    \n/* User-visible API */\n\n/* yylex_init is special because it creates the scanner itself, so it is\n * the ONLY reentrant function that doesn't take the scanner as the last argument.\n * That's why we explicitly handle the declaration, instead of using our macros.\n */\nint yylex_init(yyscan_t* ptr_yy_globals)\n{\n    if (ptr_yy_globals == NULL){\n        errno = EINVAL;\n        return 1;\n    }\n\n    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );\n\n    if (*ptr_yy_globals == NULL){\n        errno = ENOMEM;\n        return 1;\n    }\n\n    /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */\n    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));\n\n    return yy_init_globals ( *ptr_yy_globals );\n}\n\n/* yylex_init_extra has the same functionality as yylex_init, but follows the\n * convention of taking the scanner as the last argument. Note however, that\n * this is a *pointer* to a scanner, as it will be allocated by this call (and\n * is the reason, too, why this function also must handle its own declaration).\n * The user defined value in the first argument will be available to yyalloc in\n * the yyextra field.\n */\nint yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )\n{\n    struct yyguts_t dummy_yyguts;\n\n    yyset_extra (yy_user_defined, &dummy_yyguts);\n\n    if (ptr_yy_globals == NULL){\n        errno = EINVAL;\n        return 1;\n    }\n\n    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );\n\n    if (*ptr_yy_globals == NULL){\n        errno = ENOMEM;\n        return 1;\n    }\n\n    /* By setting to 0xAA, we expose bugs in\n    yy_init_globals. Leave at 0x00 for releases. */\n    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));\n\n    yyset_extra (yy_user_defined, *ptr_yy_globals);\n\n    return yy_init_globals ( *ptr_yy_globals );\n}\n\nstatic int yy_init_globals (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n    /* Initialization is the same as for the non-reentrant scanner.\n     * This function is called from yylex_destroy(), so don't allocate here.\n     */\n\n    yyg->yy_buffer_stack = NULL;\n    yyg->yy_buffer_stack_top = 0;\n    yyg->yy_buffer_stack_max = 0;\n    yyg->yy_c_buf_p = NULL;\n    yyg->yy_init = 0;\n    yyg->yy_start = 0;\n\n    yyg->yy_start_stack_ptr = 0;\n    yyg->yy_start_stack_depth = 0;\n    yyg->yy_start_stack =  NULL;\n\n/* Defined in main.c */\n#ifdef YY_STDINIT\n    yyin = stdin;\n    yyout = stdout;\n#else\n    yyin = NULL;\n    yyout = NULL;\n#endif\n\n    /* For future reference: Set errno on error, since we are called by\n     * yylex_init()\n     */\n    return 0;\n}\n\n/* yylex_destroy is for both reentrant and non-reentrant scanners. */\nint yylex_destroy  (yyscan_t yyscanner)\n{\n    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n    /* Pop the buffer stack, destroying each element. */\n\twhile(YY_CURRENT_BUFFER){\n\t\tyy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );\n\t\tYY_CURRENT_BUFFER_LVALUE = NULL;\n\t\tyypop_buffer_state(yyscanner);\n\t}\n\n\t/* Destroy the stack itself. */\n\tyyfree(yyg->yy_buffer_stack , yyscanner);\n\tyyg->yy_buffer_stack = NULL;\n\n    /* Destroy the start condition stack. */\n        yyfree( yyg->yy_start_stack , yyscanner );\n        yyg->yy_start_stack = NULL;\n\n    /* Reset the globals. This is important in a non-reentrant scanner so the next time\n     * yylex() is called, initialization will occur. */\n    yy_init_globals( yyscanner);\n\n    /* Destroy the main struct (reentrant only). */\n    yyfree ( yyscanner , yyscanner );\n    yyscanner = NULL;\n    return 0;\n}\n\n/*\n * Internal utility routines.\n */\n\n#ifndef yytext_ptr\nstatic void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)\n{\n\tstruct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\t(void)yyg;\n\n\tint i;\n\tfor ( i = 0; i < n; ++i )\n\t\ts1[i] = s2[i];\n}\n#endif\n\n#ifdef YY_NEED_STRLEN\nstatic int yy_flex_strlen (const char * s , yyscan_t yyscanner)\n{\n\tint n;\n\tfor ( n = 0; s[n]; ++n )\n\t\t;\n\n\treturn n;\n}\n#endif\n\n#define YYTABLES_NAME \"yytables\"\n\n#line 137 \"src/lexer.l\"\n\n/* perhaps these should be calls... */\n/*\n\"true\" { return TRUE; }\n\"false\" { return FALSE; }\n\"null\" { return NULL; }\n*/\nstatic int try_exit(int c, int state, yyscan_t yyscanner) {\n  char match = 0;\n  int ret;\n  switch (state) {\n  case IN_PAREN: match = ret = ')'; break;\n  case IN_BRACKET: match = ret = ']'; break;\n  case IN_BRACE: match = ret = '}'; break;\n\n  case IN_QQINTERP:\n    match = ')';\n    ret = QQSTRING_INTERP_END;\n    break;\n\n  default:\n    // may not be the best error to give\n    return INVALID_CHARACTER;\n  }\n  assert(match);\n  if (match == c) {\n    yy_pop_state(yyscanner);\n    return ret;\n  } else {\n    // FIXME: should we pop? Give a better error at least\n    return INVALID_CHARACTER;\n  }\n}\n\nstatic int enter(int c, int currstate, yyscan_t yyscanner) {\n  int state = 0;\n  switch (c) {\n  case '(': state = IN_PAREN; break;\n  case '[': state = IN_BRACKET; break;\n  case '{': state = IN_BRACE; break;\n  case QQSTRING_INTERP_START: state = IN_QQINTERP; break;\n  }\n  assert(state);\n  yy_push_state(state, yyscanner);\n  return c;\n}\n\nvoid* yyalloc(size_t sz, void* extra) {\n  return jv_mem_alloc(sz);\n}\nvoid* yyrealloc(void* p, size_t sz, void* extra) {\n  return jv_mem_realloc(p, sz);\n}\nvoid yyfree(void* p, void* extra) {\n  jv_mem_free(p);\n}\n\n"
  },
  {
    "path": "src/lexer.h",
    "content": "#ifndef jq_yyHEADER_H\n#define jq_yyHEADER_H 1\n#define jq_yyIN_HEADER 1\n\n#line 6 \"src/lexer.h\"\n\n#line 8 \"src/lexer.h\"\n\n#define  YY_INT_ALIGNED short int\n\n/* A lexical scanner generated by flex */\n\n#define FLEX_SCANNER\n#define YY_FLEX_MAJOR_VERSION 2\n#define YY_FLEX_MINOR_VERSION 6\n#define YY_FLEX_SUBMINOR_VERSION 4\n#if YY_FLEX_SUBMINOR_VERSION > 0\n#define FLEX_BETA\n#endif\n\n#ifdef yy_create_buffer\n#define jq_yy_create_buffer_ALREADY_DEFINED\n#else\n#define yy_create_buffer jq_yy_create_buffer\n#endif\n\n#ifdef yy_delete_buffer\n#define jq_yy_delete_buffer_ALREADY_DEFINED\n#else\n#define yy_delete_buffer jq_yy_delete_buffer\n#endif\n\n#ifdef yy_scan_buffer\n#define jq_yy_scan_buffer_ALREADY_DEFINED\n#else\n#define yy_scan_buffer jq_yy_scan_buffer\n#endif\n\n#ifdef yy_scan_string\n#define jq_yy_scan_string_ALREADY_DEFINED\n#else\n#define yy_scan_string jq_yy_scan_string\n#endif\n\n#ifdef yy_scan_bytes\n#define jq_yy_scan_bytes_ALREADY_DEFINED\n#else\n#define yy_scan_bytes jq_yy_scan_bytes\n#endif\n\n#ifdef yy_init_buffer\n#define jq_yy_init_buffer_ALREADY_DEFINED\n#else\n#define yy_init_buffer jq_yy_init_buffer\n#endif\n\n#ifdef yy_flush_buffer\n#define jq_yy_flush_buffer_ALREADY_DEFINED\n#else\n#define yy_flush_buffer jq_yy_flush_buffer\n#endif\n\n#ifdef yy_load_buffer_state\n#define jq_yy_load_buffer_state_ALREADY_DEFINED\n#else\n#define yy_load_buffer_state jq_yy_load_buffer_state\n#endif\n\n#ifdef yy_switch_to_buffer\n#define jq_yy_switch_to_buffer_ALREADY_DEFINED\n#else\n#define yy_switch_to_buffer jq_yy_switch_to_buffer\n#endif\n\n#ifdef yypush_buffer_state\n#define jq_yypush_buffer_state_ALREADY_DEFINED\n#else\n#define yypush_buffer_state jq_yypush_buffer_state\n#endif\n\n#ifdef yypop_buffer_state\n#define jq_yypop_buffer_state_ALREADY_DEFINED\n#else\n#define yypop_buffer_state jq_yypop_buffer_state\n#endif\n\n#ifdef yyensure_buffer_stack\n#define jq_yyensure_buffer_stack_ALREADY_DEFINED\n#else\n#define yyensure_buffer_stack jq_yyensure_buffer_stack\n#endif\n\n#ifdef yylex\n#define jq_yylex_ALREADY_DEFINED\n#else\n#define yylex jq_yylex\n#endif\n\n#ifdef yyrestart\n#define jq_yyrestart_ALREADY_DEFINED\n#else\n#define yyrestart jq_yyrestart\n#endif\n\n#ifdef yylex_init\n#define jq_yylex_init_ALREADY_DEFINED\n#else\n#define yylex_init jq_yylex_init\n#endif\n\n#ifdef yylex_init_extra\n#define jq_yylex_init_extra_ALREADY_DEFINED\n#else\n#define yylex_init_extra jq_yylex_init_extra\n#endif\n\n#ifdef yylex_destroy\n#define jq_yylex_destroy_ALREADY_DEFINED\n#else\n#define yylex_destroy jq_yylex_destroy\n#endif\n\n#ifdef yyget_debug\n#define jq_yyget_debug_ALREADY_DEFINED\n#else\n#define yyget_debug jq_yyget_debug\n#endif\n\n#ifdef yyset_debug\n#define jq_yyset_debug_ALREADY_DEFINED\n#else\n#define yyset_debug jq_yyset_debug\n#endif\n\n#ifdef yyget_extra\n#define jq_yyget_extra_ALREADY_DEFINED\n#else\n#define yyget_extra jq_yyget_extra\n#endif\n\n#ifdef yyset_extra\n#define jq_yyset_extra_ALREADY_DEFINED\n#else\n#define yyset_extra jq_yyset_extra\n#endif\n\n#ifdef yyget_in\n#define jq_yyget_in_ALREADY_DEFINED\n#else\n#define yyget_in jq_yyget_in\n#endif\n\n#ifdef yyset_in\n#define jq_yyset_in_ALREADY_DEFINED\n#else\n#define yyset_in jq_yyset_in\n#endif\n\n#ifdef yyget_out\n#define jq_yyget_out_ALREADY_DEFINED\n#else\n#define yyget_out jq_yyget_out\n#endif\n\n#ifdef yyset_out\n#define jq_yyset_out_ALREADY_DEFINED\n#else\n#define yyset_out jq_yyset_out\n#endif\n\n#ifdef yyget_leng\n#define jq_yyget_leng_ALREADY_DEFINED\n#else\n#define yyget_leng jq_yyget_leng\n#endif\n\n#ifdef yyget_text\n#define jq_yyget_text_ALREADY_DEFINED\n#else\n#define yyget_text jq_yyget_text\n#endif\n\n#ifdef yyget_lineno\n#define jq_yyget_lineno_ALREADY_DEFINED\n#else\n#define yyget_lineno jq_yyget_lineno\n#endif\n\n#ifdef yyset_lineno\n#define jq_yyset_lineno_ALREADY_DEFINED\n#else\n#define yyset_lineno jq_yyset_lineno\n#endif\n\n#ifdef yyget_column\n#define jq_yyget_column_ALREADY_DEFINED\n#else\n#define yyget_column jq_yyget_column\n#endif\n\n#ifdef yyset_column\n#define jq_yyset_column_ALREADY_DEFINED\n#else\n#define yyset_column jq_yyset_column\n#endif\n\n#ifdef yywrap\n#define jq_yywrap_ALREADY_DEFINED\n#else\n#define yywrap jq_yywrap\n#endif\n\n#ifdef yyget_lval\n#define jq_yyget_lval_ALREADY_DEFINED\n#else\n#define yyget_lval jq_yyget_lval\n#endif\n\n#ifdef yyset_lval\n#define jq_yyset_lval_ALREADY_DEFINED\n#else\n#define yyset_lval jq_yyset_lval\n#endif\n\n#ifdef yyget_lloc\n#define jq_yyget_lloc_ALREADY_DEFINED\n#else\n#define yyget_lloc jq_yyget_lloc\n#endif\n\n#ifdef yyset_lloc\n#define jq_yyset_lloc_ALREADY_DEFINED\n#else\n#define yyset_lloc jq_yyset_lloc\n#endif\n\n#ifdef yyalloc\n#define jq_yyalloc_ALREADY_DEFINED\n#else\n#define yyalloc jq_yyalloc\n#endif\n\n#ifdef yyrealloc\n#define jq_yyrealloc_ALREADY_DEFINED\n#else\n#define yyrealloc jq_yyrealloc\n#endif\n\n#ifdef yyfree\n#define jq_yyfree_ALREADY_DEFINED\n#else\n#define yyfree jq_yyfree\n#endif\n\n/* First, we deal with  platform-specific or compiler-specific issues. */\n\n/* begin standard C headers. */\n#include <stdio.h>\n#include <string.h>\n#include <errno.h>\n#include <stdlib.h>\n\n/* end standard C headers. */\n\n/* flex integer type definitions */\n\n#ifndef FLEXINT_H\n#define FLEXINT_H\n\n/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */\n\n#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n\n/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,\n * if you want the limit (max/min) macros for int types. \n */\n#ifndef __STDC_LIMIT_MACROS\n#define __STDC_LIMIT_MACROS 1\n#endif\n\n#include <inttypes.h>\ntypedef int8_t flex_int8_t;\ntypedef uint8_t flex_uint8_t;\ntypedef int16_t flex_int16_t;\ntypedef uint16_t flex_uint16_t;\ntypedef int32_t flex_int32_t;\ntypedef uint32_t flex_uint32_t;\n#else\ntypedef signed char flex_int8_t;\ntypedef short int flex_int16_t;\ntypedef int flex_int32_t;\ntypedef unsigned char flex_uint8_t; \ntypedef unsigned short int flex_uint16_t;\ntypedef unsigned int flex_uint32_t;\n\n/* Limits of integral types. */\n#ifndef INT8_MIN\n#define INT8_MIN               (-128)\n#endif\n#ifndef INT16_MIN\n#define INT16_MIN              (-32767-1)\n#endif\n#ifndef INT32_MIN\n#define INT32_MIN              (-2147483647-1)\n#endif\n#ifndef INT8_MAX\n#define INT8_MAX               (127)\n#endif\n#ifndef INT16_MAX\n#define INT16_MAX              (32767)\n#endif\n#ifndef INT32_MAX\n#define INT32_MAX              (2147483647)\n#endif\n#ifndef UINT8_MAX\n#define UINT8_MAX              (255U)\n#endif\n#ifndef UINT16_MAX\n#define UINT16_MAX             (65535U)\n#endif\n#ifndef UINT32_MAX\n#define UINT32_MAX             (4294967295U)\n#endif\n\n#ifndef SIZE_MAX\n#define SIZE_MAX               (~(size_t)0)\n#endif\n\n#endif /* ! C99 */\n\n#endif /* ! FLEXINT_H */\n\n/* begin standard C++ headers. */\n\n/* TODO: this is always defined, so inline it */\n#define yyconst const\n\n#if defined(__GNUC__) && __GNUC__ >= 3\n#define yynoreturn __attribute__((__noreturn__))\n#else\n#define yynoreturn\n#endif\n\n/* An opaque pointer. */\n#ifndef YY_TYPEDEF_YY_SCANNER_T\n#define YY_TYPEDEF_YY_SCANNER_T\ntypedef void* yyscan_t;\n#endif\n\n/* For convenience, these vars (plus the bison vars far below)\n   are macros in the reentrant scanner. */\n#define yyin yyg->yyin_r\n#define yyout yyg->yyout_r\n#define yyextra yyg->yyextra_r\n#define yyleng yyg->yyleng_r\n#define yytext yyg->yytext_r\n#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)\n#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)\n#define yy_flex_debug yyg->yy_flex_debug_r\n\n/* Size of default input buffer. */\n#ifndef YY_BUF_SIZE\n#ifdef __ia64__\n/* On IA-64, the buffer size is 16k, not 8k.\n * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.\n * Ditto for the __ia64__ case accordingly.\n */\n#define YY_BUF_SIZE 32768\n#else\n#define YY_BUF_SIZE 16384\n#endif /* __ia64__ */\n#endif\n\n#ifndef YY_TYPEDEF_YY_BUFFER_STATE\n#define YY_TYPEDEF_YY_BUFFER_STATE\ntypedef struct yy_buffer_state *YY_BUFFER_STATE;\n#endif\n\n#ifndef YY_TYPEDEF_YY_SIZE_T\n#define YY_TYPEDEF_YY_SIZE_T\ntypedef size_t yy_size_t;\n#endif\n\n#ifndef YY_STRUCT_YY_BUFFER_STATE\n#define YY_STRUCT_YY_BUFFER_STATE\nstruct yy_buffer_state\n\t{\n\tFILE *yy_input_file;\n\n\tchar *yy_ch_buf;\t\t/* input buffer */\n\tchar *yy_buf_pos;\t\t/* current position in input buffer */\n\n\t/* Size of input buffer in bytes, not including room for EOB\n\t * characters.\n\t */\n\tint yy_buf_size;\n\n\t/* Number of characters read into yy_ch_buf, not including EOB\n\t * characters.\n\t */\n\tint yy_n_chars;\n\n\t/* Whether we \"own\" the buffer - i.e., we know we created it,\n\t * and can realloc() it to grow it, and should free() it to\n\t * delete it.\n\t */\n\tint yy_is_our_buffer;\n\n\t/* Whether this is an \"interactive\" input source; if so, and\n\t * if we're using stdio for input, then we want to use getc()\n\t * instead of fread(), to make sure we stop fetching input after\n\t * each newline.\n\t */\n\tint yy_is_interactive;\n\n\t/* Whether we're considered to be at the beginning of a line.\n\t * If so, '^' rules will be active on the next match, otherwise\n\t * not.\n\t */\n\tint yy_at_bol;\n\n    int yy_bs_lineno; /**< The line count. */\n    int yy_bs_column; /**< The column count. */\n\n\t/* Whether to try to fill the input buffer when we reach the\n\t * end of it.\n\t */\n\tint yy_fill_buffer;\n\n\tint yy_buffer_status;\n\n\t};\n#endif /* !YY_STRUCT_YY_BUFFER_STATE */\n\nvoid yyrestart ( FILE *input_file , yyscan_t yyscanner );\nvoid yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );\nYY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );\nvoid yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );\nvoid yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );\nvoid yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );\nvoid yypop_buffer_state ( yyscan_t yyscanner );\n\nYY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );\nYY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );\nYY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );\n\nvoid *yyalloc ( yy_size_t , yyscan_t yyscanner );\nvoid *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );\nvoid yyfree ( void * , yyscan_t yyscanner );\n\n/* Begin user sect3 */\n\n#define jq_yywrap(yyscanner) (/*CONSTCOND*/1)\n#define YY_SKIP_YYWRAP\n\n#define yytext_ptr yytext_r\n\n#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n#define INITIAL 0\n#define IN_PAREN 1\n#define IN_BRACKET 2\n#define IN_BRACE 3\n#define IN_QQINTERP 4\n#define IN_QQSTRING 5\n#define IN_COMMENT 6\n\n#endif\n\n#ifndef YY_NO_UNISTD_H\n/* Special case for \"unistd.h\", since it is non-ANSI. We include it way\n * down here because we want the user's section 1 to have been scanned first.\n * The user has a chance to override it with an option.\n */\n#include <unistd.h>\n#endif\n\n#define YY_EXTRA_TYPE int\n\nint yylex_init (yyscan_t* scanner);\n\nint yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);\n\n/* Accessor methods to globals.\n   These are made visible to non-reentrant scanners for convenience. */\n\nint yylex_destroy ( yyscan_t yyscanner );\n\nint yyget_debug ( yyscan_t yyscanner );\n\nvoid yyset_debug ( int debug_flag , yyscan_t yyscanner );\n\nYY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );\n\nvoid yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );\n\nFILE *yyget_in ( yyscan_t yyscanner );\n\nvoid yyset_in  ( FILE * _in_str , yyscan_t yyscanner );\n\nFILE *yyget_out ( yyscan_t yyscanner );\n\nvoid yyset_out  ( FILE * _out_str , yyscan_t yyscanner );\n\n\t\t\tint yyget_leng ( yyscan_t yyscanner );\n\nchar *yyget_text ( yyscan_t yyscanner );\n\nint yyget_lineno ( yyscan_t yyscanner );\n\nvoid yyset_lineno ( int _line_number , yyscan_t yyscanner );\n\nint yyget_column  ( yyscan_t yyscanner );\n\nvoid yyset_column ( int _column_no , yyscan_t yyscanner );\n\nYYSTYPE * yyget_lval ( yyscan_t yyscanner );\n\nvoid yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );\n\n       YYLTYPE *yyget_lloc ( yyscan_t yyscanner );\n    \n        void yyset_lloc ( YYLTYPE * yylloc_param , yyscan_t yyscanner );\n    \n/* Macros after this point can all be overridden by user definitions in\n * section 1.\n */\n\n#ifndef YY_SKIP_YYWRAP\n#ifdef __cplusplus\nextern \"C\" int yywrap ( yyscan_t yyscanner );\n#else\nextern int yywrap ( yyscan_t yyscanner );\n#endif\n#endif\n\n#ifndef yytext_ptr\nstatic void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);\n#endif\n\n#ifdef YY_NEED_STRLEN\nstatic int yy_flex_strlen ( const char * , yyscan_t yyscanner);\n#endif\n\n#ifndef YY_NO_INPUT\n\n#endif\n\n/* Amount of stuff to slurp up with each read. */\n#ifndef YY_READ_BUF_SIZE\n#ifdef __ia64__\n/* On IA-64, the buffer size is 16k, not 8k */\n#define YY_READ_BUF_SIZE 16384\n#else\n#define YY_READ_BUF_SIZE 8192\n#endif /* __ia64__ */\n#endif\n\n/* Number of entries by which start-condition stack grows. */\n#ifndef YY_START_STACK_INCR\n#define YY_START_STACK_INCR 25\n#endif\n\n/* Default declaration of generated scanner - a define so the user can\n * easily add parameters.\n */\n#ifndef YY_DECL\n#define YY_DECL_IS_OURS 1\n\nextern int yylex \\\n               (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner);\n\n#define YY_DECL int yylex \\\n               (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)\n#endif /* !YY_DECL */\n\n/* yy_get_previous_state - get the state just before the EOB char was reached */\n\n#undef YY_NEW_FILE\n#undef YY_FLUSH_BUFFER\n#undef yy_set_bol\n#undef yy_new_buffer\n#undef yy_set_interactive\n#undef YY_DO_BEFORE_ACTION\n\n#ifdef YY_DECL_IS_OURS\n#undef YY_DECL_IS_OURS\n#undef YY_DECL\n#endif\n\n#ifndef jq_yy_create_buffer_ALREADY_DEFINED\n#undef yy_create_buffer\n#endif\n#ifndef jq_yy_delete_buffer_ALREADY_DEFINED\n#undef yy_delete_buffer\n#endif\n#ifndef jq_yy_scan_buffer_ALREADY_DEFINED\n#undef yy_scan_buffer\n#endif\n#ifndef jq_yy_scan_string_ALREADY_DEFINED\n#undef yy_scan_string\n#endif\n#ifndef jq_yy_scan_bytes_ALREADY_DEFINED\n#undef yy_scan_bytes\n#endif\n#ifndef jq_yy_init_buffer_ALREADY_DEFINED\n#undef yy_init_buffer\n#endif\n#ifndef jq_yy_flush_buffer_ALREADY_DEFINED\n#undef yy_flush_buffer\n#endif\n#ifndef jq_yy_load_buffer_state_ALREADY_DEFINED\n#undef yy_load_buffer_state\n#endif\n#ifndef jq_yy_switch_to_buffer_ALREADY_DEFINED\n#undef yy_switch_to_buffer\n#endif\n#ifndef jq_yypush_buffer_state_ALREADY_DEFINED\n#undef yypush_buffer_state\n#endif\n#ifndef jq_yypop_buffer_state_ALREADY_DEFINED\n#undef yypop_buffer_state\n#endif\n#ifndef jq_yyensure_buffer_stack_ALREADY_DEFINED\n#undef yyensure_buffer_stack\n#endif\n#ifndef jq_yylex_ALREADY_DEFINED\n#undef yylex\n#endif\n#ifndef jq_yyrestart_ALREADY_DEFINED\n#undef yyrestart\n#endif\n#ifndef jq_yylex_init_ALREADY_DEFINED\n#undef yylex_init\n#endif\n#ifndef jq_yylex_init_extra_ALREADY_DEFINED\n#undef yylex_init_extra\n#endif\n#ifndef jq_yylex_destroy_ALREADY_DEFINED\n#undef yylex_destroy\n#endif\n#ifndef jq_yyget_debug_ALREADY_DEFINED\n#undef yyget_debug\n#endif\n#ifndef jq_yyset_debug_ALREADY_DEFINED\n#undef yyset_debug\n#endif\n#ifndef jq_yyget_extra_ALREADY_DEFINED\n#undef yyget_extra\n#endif\n#ifndef jq_yyset_extra_ALREADY_DEFINED\n#undef yyset_extra\n#endif\n#ifndef jq_yyget_in_ALREADY_DEFINED\n#undef yyget_in\n#endif\n#ifndef jq_yyset_in_ALREADY_DEFINED\n#undef yyset_in\n#endif\n#ifndef jq_yyget_out_ALREADY_DEFINED\n#undef yyget_out\n#endif\n#ifndef jq_yyset_out_ALREADY_DEFINED\n#undef yyset_out\n#endif\n#ifndef jq_yyget_leng_ALREADY_DEFINED\n#undef yyget_leng\n#endif\n#ifndef jq_yyget_text_ALREADY_DEFINED\n#undef yyget_text\n#endif\n#ifndef jq_yyget_lineno_ALREADY_DEFINED\n#undef yyget_lineno\n#endif\n#ifndef jq_yyset_lineno_ALREADY_DEFINED\n#undef yyset_lineno\n#endif\n#ifndef jq_yyget_column_ALREADY_DEFINED\n#undef yyget_column\n#endif\n#ifndef jq_yyset_column_ALREADY_DEFINED\n#undef yyset_column\n#endif\n#ifndef jq_yywrap_ALREADY_DEFINED\n#undef yywrap\n#endif\n#ifndef jq_yyget_lval_ALREADY_DEFINED\n#undef yyget_lval\n#endif\n#ifndef jq_yyset_lval_ALREADY_DEFINED\n#undef yyset_lval\n#endif\n#ifndef jq_yyget_lloc_ALREADY_DEFINED\n#undef yyget_lloc\n#endif\n#ifndef jq_yyset_lloc_ALREADY_DEFINED\n#undef yyset_lloc\n#endif\n#ifndef jq_yyalloc_ALREADY_DEFINED\n#undef yyalloc\n#endif\n#ifndef jq_yyrealloc_ALREADY_DEFINED\n#undef yyrealloc\n#endif\n#ifndef jq_yyfree_ALREADY_DEFINED\n#undef yyfree\n#endif\n#ifndef jq_yytext_ALREADY_DEFINED\n#undef yytext\n#endif\n#ifndef jq_yyleng_ALREADY_DEFINED\n#undef yyleng\n#endif\n#ifndef jq_yyin_ALREADY_DEFINED\n#undef yyin\n#endif\n#ifndef jq_yyout_ALREADY_DEFINED\n#undef yyout\n#endif\n#ifndef jq_yy_flex_debug_ALREADY_DEFINED\n#undef yy_flex_debug\n#endif\n#ifndef jq_yylineno_ALREADY_DEFINED\n#undef yylineno\n#endif\n#ifndef jq_yytables_fload_ALREADY_DEFINED\n#undef yytables_fload\n#endif\n#ifndef jq_yytables_destroy_ALREADY_DEFINED\n#undef yytables_destroy\n#endif\n#ifndef jq_yyTABLES_NAME_ALREADY_DEFINED\n#undef yyTABLES_NAME\n#endif\n\n#line 137 \"src/lexer.l\"\n\n\n#line 739 \"src/lexer.h\"\n#undef jq_yyIN_HEADER\n#endif /* jq_yyHEADER_H */\n"
  },
  {
    "path": "src/lexer.l",
    "content": "%{\n#include <assert.h>\n#include \"jv_alloc.h\"\n#include \"compile.h\"\n\nstruct lexer_param;\n\n#include \"parser.h\"  /* Generated by bison. */\n\n#define YY_USER_ACTION                           \\\n  do {                                           \\\n    yylloc->start = yyget_extra(yyscanner);      \\\n    yylloc->end = yylloc->start + yyleng;        \\\n    yyset_extra(yylloc->end, yyscanner);         \\\n  } while (0);\n\n%}\n\n%s IN_PAREN\n%s IN_BRACKET\n%s IN_BRACE\n%s IN_QQINTERP\n%x IN_QQSTRING\n%x IN_COMMENT\n%{\n  static int enter(int opening, int state, yyscan_t yyscanner);\n  static int try_exit(int closing, int state, yyscan_t yyscanner);\n%}\n\n%option noyywrap nounput noinput nodefault\n%option noyyalloc noyyrealloc noyyfree\n%option reentrant\n%option extra-type=\"int\"\n%option bison-bridge bison-locations\n%option prefix=\"jq_yy\"\n%option stack\n\n\n%%\n\n\"#\" { yy_push_state(IN_COMMENT, yyscanner); }\n<IN_COMMENT>{\n  \\\\(\\\\|\\r?\\n)|. { }\n  \\r?\\n { yy_pop_state(yyscanner); }\n}\n<IN_COMMENT><<EOF>> { yy_pop_state(yyscanner); }\n\n\"!=\" { return NEQ; }\n\"==\" { return EQ; }\n\"as\" { return AS; }\n\"import\" { return IMPORT; }\n\"include\" { return INCLUDE; }\n\"module\" { return MODULE; }\n\"def\" { return DEF; }\n\"if\" { return IF; }\n\"then\" { return THEN; }\n\"else\" { return ELSE; }\n\"elif\" { return ELSE_IF; }\n\"and\" { return AND; }\n\"or\" { return OR; }\n\"end\" { return END; }\n\"reduce\" { return REDUCE; }\n\"foreach\" { return FOREACH; }\n\"//\" { return DEFINEDOR; }\n\"try\" { return TRY; }\n\"catch\" { return CATCH; }\n\"label\" { return LABEL; }\n\"break\" { return BREAK; }\n\"$__loc__\" { return LOC; }\n\"|=\" { return SETPIPE; }\n\"+=\" { return SETPLUS; }\n\"-=\" { return SETMINUS; }\n\"*=\" { return SETMULT; }\n\"/=\" { return SETDIV; }\n\"%=\" { return SETMOD; }\n\"//=\" { return SETDEFINEDOR; }\n\"<=\" { return LESSEQ; }\n\">=\" { return GREATEREQ; }\n\"..\" { return REC; }\n\"?//\" { return ALTERNATION; }\n\".\"|\"?\"|\"=\"|\";\"|\",\"|\":\"|\"|\"|\"+\"|\"-\"|\"*\"|\"/\"|\"%\"|\"\\$\"|\"<\"|\">\" { return yytext[0];}\n\n\"[\"|\"{\"|\"(\" {\n  return enter(yytext[0], YY_START, yyscanner);\n}\n\n\"]\"|\"}\"|\")\" {\n  return try_exit(yytext[0], YY_START, yyscanner);\n}\n\n\"@\"[a-zA-Z0-9_]+ {\n  yylval->literal = jv_string_sized(yytext + 1, yyleng - 1); return FORMAT;\n}\n\n([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([eE][+-]?[0-9]+)? {\n   yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL;\n}\n\n\"\\\"\" {\n  yy_push_state(IN_QQSTRING, yyscanner);\n  return QQSTRING_START;\n}\n\n<IN_QQSTRING>{\n  \"\\\\(\" {\n    return enter(QQSTRING_INTERP_START, YY_START, yyscanner);\n  }\n  \"\\\"\" {\n    yy_pop_state(yyscanner);\n    return QQSTRING_END;\n  }\n  (\\\\[^u(]|\\\\u[a-zA-Z0-9]{0,4})+ {\n    /* pass escapes to the json parser */\n    jv escapes = jv_string_fmt(\"\\\"%.*s\\\"\", (int)yyleng, yytext);\n    yylval->literal = jv_parse_sized(jv_string_value(escapes), jv_string_length_bytes(jv_copy(escapes)));\n    jv_free(escapes);\n    return QQSTRING_TEXT;\n  }\n  [^\\\\\\\"]+ {\n    yylval->literal = jv_string_sized(yytext, yyleng);\n    return QQSTRING_TEXT;\n  }\n  . {\n    return INVALID_CHARACTER;\n  }\n}\n\n\n([a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*  { yylval->literal = jv_string(yytext); return IDENT;}\n\\.[a-zA-Z_][a-zA-Z_0-9]*  { yylval->literal = jv_string(yytext+1); return FIELD;}\n\\$([a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*  { yylval->literal = jv_string(yytext+1); return BINDING;}\n\n[ \\r\\n\\t]+  {}\n\n. { return INVALID_CHARACTER; }\n\n%%\n/* perhaps these should be calls... */\n/*\n\"true\" { return TRUE; }\n\"false\" { return FALSE; }\n\"null\" { return NULL; }\n*/\nstatic int try_exit(int c, int state, yyscan_t yyscanner) {\n  char match = 0;\n  int ret;\n  switch (state) {\n  case IN_PAREN: match = ret = ')'; break;\n  case IN_BRACKET: match = ret = ']'; break;\n  case IN_BRACE: match = ret = '}'; break;\n\n  case IN_QQINTERP:\n    match = ')';\n    ret = QQSTRING_INTERP_END;\n    break;\n\n  default:\n    // may not be the best error to give\n    return INVALID_CHARACTER;\n  }\n  assert(match);\n  if (match == c) {\n    yy_pop_state(yyscanner);\n    return ret;\n  } else {\n    // FIXME: should we pop? Give a better error at least\n    return INVALID_CHARACTER;\n  }\n}\n\nstatic int enter(int c, int currstate, yyscan_t yyscanner) {\n  int state = 0;\n  switch (c) {\n  case '(': state = IN_PAREN; break;\n  case '[': state = IN_BRACKET; break;\n  case '{': state = IN_BRACE; break;\n  case QQSTRING_INTERP_START: state = IN_QQINTERP; break;\n  }\n  assert(state);\n  yy_push_state(state, yyscanner);\n  return c;\n}\n\nvoid* yyalloc(size_t sz, void* extra) {\n  return jv_mem_alloc(sz);\n}\nvoid* yyrealloc(void* p, size_t sz, void* extra) {\n  return jv_mem_realloc(p, sz);\n}\nvoid yyfree(void* p, void* extra) {\n  jv_mem_free(p);\n}\n"
  },
  {
    "path": "src/libm.h",
    "content": "#ifdef HAVE_ACOS\nLIBM_DD(acos)\n#else\nLIBM_DD_NO(acos)\n#endif\n#ifdef HAVE_ACOSH\nLIBM_DD(acosh)\n#else\nLIBM_DD_NO(acosh)\n#endif\n#ifdef HAVE_ASIN\nLIBM_DD(asin)\n#else\nLIBM_DD_NO(asin)\n#endif\n#ifdef HAVE_ASINH\nLIBM_DD(asinh)\n#else\nLIBM_DD_NO(asinh)\n#endif\n#ifdef HAVE_ATAN\nLIBM_DD(atan)\n#else\nLIBM_DD_NO(atan)\n#endif\n#ifdef HAVE_ATAN2\nLIBM_DDD(atan2)\n#else\nLIBM_DDD_NO(atan2)\n#endif\n#ifdef HAVE_ATANH\nLIBM_DD(atanh)\n#else\nLIBM_DD_NO(atanh)\n#endif\n#ifdef HAVE_CBRT\nLIBM_DD(cbrt)\n#else\nLIBM_DD_NO(cbrt)\n#endif\n#ifdef HAVE_COS\nLIBM_DD(cos)\n#else\nLIBM_DD_NO(cos)\n#endif\n#ifdef HAVE_COSH\nLIBM_DD(cosh)\n#else\nLIBM_DD_NO(cosh)\n#endif\n#ifdef HAVE_EXP\nLIBM_DD(exp)\n#else\nLIBM_DD_NO(exp)\n#endif\n#ifdef HAVE_EXP2\nLIBM_DD(exp2)\n#else\nLIBM_DD_NO(exp2)\n#endif\n#ifdef HAVE_FLOOR\nLIBM_DD(floor)\n#else\nLIBM_DD_NO(floor)\n#endif\n#ifdef HAVE_HYPOT\nLIBM_DDD(hypot)\n#else\nLIBM_DDD_NO(hypot)\n#endif\n#ifdef HAVE_J0\nLIBM_DD(j0)\n#else\nLIBM_DD_NO(j0)\n#endif\n#ifdef HAVE_J1\nLIBM_DD(j1)\n#else\nLIBM_DD_NO(j1)\n#endif\n#ifdef HAVE_LOG\nLIBM_DD(log)\n#else\nLIBM_DD_NO(log)\n#endif\n#ifdef HAVE_LOG10\nLIBM_DD(log10)\n#else\nLIBM_DD_NO(log10)\n#endif\n#ifdef HAVE_LOG2\nLIBM_DD(log2)\n#else\nLIBM_DD_NO(log2)\n#endif\n#ifdef HAVE_POW\nLIBM_DDD(pow)\n#else\nLIBM_DDD_NO(pow)\n#endif\n#ifdef HAVE_REMAINDER\nLIBM_DDD(remainder)\n#else\nLIBM_DDD_NO(remainder)\n#endif\n#ifdef HAVE_SIN\nLIBM_DD(sin)\n#else\nLIBM_DD_NO(sin)\n#endif\n#ifdef HAVE_SINH\nLIBM_DD(sinh)\n#else\nLIBM_DD_NO(sinh)\n#endif\n#ifdef HAVE_SQRT\nLIBM_DD(sqrt)\n#else\nLIBM_DD_NO(sqrt)\n#endif\n#ifdef HAVE_TAN\nLIBM_DD(tan)\n#else\nLIBM_DD_NO(tan)\n#endif\n#ifdef HAVE_TANH\nLIBM_DD(tanh)\n#else\nLIBM_DD_NO(tanh)\n#endif\n#ifdef HAVE_TGAMMA\nLIBM_DD(tgamma)\n#else\nLIBM_DD_NO(tgamma)\n#endif\n#ifdef HAVE_Y0\nLIBM_DD(y0)\n#else\nLIBM_DD_NO(y0)\n#endif\n#ifdef HAVE_Y1\nLIBM_DD(y1)\n#else\nLIBM_DD_NO(y1)\n#endif\n#ifdef HAVE_JN\nLIBM_DDD(jn)\n#endif\n#ifdef HAVE_YN\nLIBM_DDD(yn)\n#endif\n#ifdef HAVE_CEIL\nLIBM_DD(ceil)\n#else\nLIBM_DD_NO(ceil)\n#endif\n#ifdef HAVE_COPYSIGN\nLIBM_DDD(copysign)\n#else\nLIBM_DDD_NO(copysign)\n#endif\n#if defined(HAVE_DREM) && !defined(WIN32)\nLIBM_DDD(drem)\n#else\nLIBM_DDD_NO(drem)\n#endif\n#ifdef HAVE_ERF\nLIBM_DD(erf)\n#else\nLIBM_DD_NO(erf)\n#endif\n#ifdef HAVE_ERFC\nLIBM_DD(erfc)\n#else\nLIBM_DD_NO(erfc)\n#endif\n#if defined(HAVE_EXP10) && !defined(WIN32)\nLIBM_DD(exp10)\n#else\nLIBM_DD_NO(exp10)\n#endif\n#ifdef HAVE_EXPM1\nLIBM_DD(expm1)\n#else\nLIBM_DD_NO(expm1)\n#endif\n#ifdef HAVE_FABS\nLIBM_DD(fabs)\n#else\nLIBM_DD_NO(fabs)\n#endif\n#ifdef HAVE_FDIM\nLIBM_DDD(fdim)\n#else\nLIBM_DDD_NO(fdim)\n#endif\n#ifdef HAVE_FMA\nLIBM_DDDD(fma)\n#else\nLIBM_DDDD_NO(fma)\n#endif\n#ifdef HAVE_FMAX\nLIBM_DDD(fmax)\n#else\nLIBM_DDD_NO(fmax)\n#endif\n#ifdef HAVE_FMIN\nLIBM_DDD(fmin)\n#else\nLIBM_DDD_NO(fmin)\n#endif\n#ifdef HAVE_FMOD\nLIBM_DDD(fmod)\n#else\nLIBM_DDD_NO(fmod)\n#endif\n#if defined(HAVE_GAMMA)\nLIBM_DD(gamma)\n#else\nLIBM_DD_NO(gamma)\n#endif\n#ifdef HAVE_LGAMMA\nLIBM_DD(lgamma)\n#else\nLIBM_DD_NO(lgamma)\n#endif\n#ifdef HAVE_LOG1P\nLIBM_DD(log1p)\n#else\nLIBM_DD_NO(log1p)\n#endif\n#ifdef HAVE_LOGB\nLIBM_DD(logb)\n#else\nLIBM_DD_NO(logb)\n#endif\n#ifdef HAVE_NEARBYINT\nLIBM_DD(nearbyint)\n#else\nLIBM_DD_NO(nearbyint)\n#endif\n#ifdef HAVE_NEXTAFTER\nLIBM_DDD(nextafter)\n#else\nLIBM_DDD_NO(nextafter)\n#endif\n#ifdef HAVE_NEXTTOWARD\nLIBM_DDD(nexttoward)\n#else\nLIBM_DDD_NO(nexttoward)\n#endif\n#ifdef HAVE_RINT\nLIBM_DD(rint)\n#else\nLIBM_DD_NO(rint)\n#endif\n#ifdef HAVE_ROUND\nLIBM_DD(round)\n#else\nLIBM_DD_NO(round)\n#endif\n#ifdef HAVE_SCALB\nLIBM_DDD(scalb)\n#else\nLIBM_DDD_NO(scalb)\n#endif\n#ifdef HAVE_SCALBLN\nLIBM_DDD(scalbln)\n#else\nLIBM_DDD_NO(scalbln)\n#endif\n#if defined(HAVE_SIGNIFICAND) && !defined(WIN32)\nLIBM_DD(significand)\n#else\nLIBM_DD_NO(significand)\n#endif\n#ifdef HAVE_TRUNC\nLIBM_DD(trunc)\n#else\nLIBM_DD_NO(trunc)\n#endif\n#ifdef HAVE_LDEXP\nLIBM_DDD(ldexp)\n#else\nLIBM_DDD_NO(ldexp)\n#endif\n#ifdef HAVE_MODF\nLIBM_DA(modf, double)\n#else\nLIBM_DA_NO(modf, double)\n#endif\n#ifdef HAVE_FREXP\nLIBM_DA(frexp, int)\n#else\nLIBM_DA_NO(frexp, int)\n#endif\n#ifdef HAVE_LGAMMA_R\nLIBM_DA(lgamma_r, int)\n#else\nLIBM_DA_NO(lgamma_r, int)\n#endif\n"
  },
  {
    "path": "src/linker.c",
    "content": "#include <assert.h>\n#include <errno.h>\n#include <limits.h>\n#include <string.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdint.h>\n#include <sys/stat.h>\n#include <libgen.h>\n\n#ifdef WIN32\n#include <shlwapi.h>\n#endif\n\n#include \"jq_parser.h\"\n#include \"locfile.h\"\n#include \"jv.h\"\n#include \"jq.h\"\n#include \"util.h\"\n#include \"compile.h\"\n#include \"jv_alloc.h\"\n\nstruct lib_loading_state {\n  char **names;\n  block *defs;\n  uint64_t ct;\n};\nstatic int load_library(jq_state *jq, jv lib_path,\n                        int is_data, int raw, int optional,\n                        const char *as, block *out_block,\n                        struct lib_loading_state *lib_state);\n\nstatic int path_is_relative(jv p) {\n  const char *s = jv_string_value(p);\n\n#ifdef WIN32\n  int res = PathIsRelativeA(s);\n#else\n  int res = *s != '/';\n#endif\n  jv_free(p);\n  return res;\n}\n\n\n// Given a lib_path to search first, creates a chain of search paths\n// in the following order:\n// 1. lib_path\n// 2. -L paths passed in on the command line (from jq_state*) or builtin list\nstatic jv build_lib_search_chain(jq_state *jq, jv search_path, jv jq_origin, jv lib_origin) {\n  assert(jv_get_kind(search_path) == JV_KIND_ARRAY);\n  jv expanded = jv_array();\n  jv expanded_elt;\n  jv err = jv_null();\n  jv_array_foreach(search_path, i, path) {\n    if (jv_get_kind(path) != JV_KIND_STRING) {\n      jv_free(path);\n      continue;\n    }\n    path = expand_path(path);\n    if (!jv_is_valid(path)) {\n      jv_free(err);\n      err = path;\n      path = jv_null();\n      continue;\n    }\n    if (strcmp(\".\",jv_string_value(path)) == 0) {\n      expanded_elt = jv_copy(path);\n    } else if (strncmp(\"$ORIGIN/\",jv_string_value(path),sizeof(\"$ORIGIN/\") - 1) == 0) {\n      expanded_elt = jv_string_fmt(\"%s/%s\",\n                               jv_string_value(jq_origin),\n                               jv_string_value(path) + sizeof (\"$ORIGIN/\") - 1);\n    } else if (jv_get_kind(lib_origin) == JV_KIND_STRING &&\n               path_is_relative(jv_copy(path))) {\n      expanded_elt = jv_string_fmt(\"%s/%s\",\n                               jv_string_value(lib_origin),\n                               jv_string_value(path));\n    } else {\n      expanded_elt = path;\n      path = jv_invalid();\n    }\n    expanded = jv_array_append(expanded, expanded_elt);\n    jv_free(path);\n  }\n  jv_free(jq_origin);\n  jv_free(lib_origin);\n  jv_free(search_path);\n  return JV_ARRAY(expanded, err);\n}\n\n// Doesn't actually check that name not be an absolute path, and we\n// don't have to: we always append relative paths to others (with a '/'\n// in between).\nstatic jv validate_relpath(jv name) {\n  const char *s = jv_string_value(name);\n  if (strchr(s, '\\\\')) {\n    jv res = jv_invalid_with_msg(jv_string_fmt(\"Modules must be named by relative paths using '/', not '\\\\' (%s)\", s));\n    jv_free(name);\n    return res;\n  }\n  jv components = jv_string_split(jv_copy(name), jv_string(\"/\"));\n  jv_array_foreach(components, i, x) {\n    if (!strcmp(jv_string_value(x), \"..\")) {\n      jv_free(x);\n      jv_free(components);\n      jv res = jv_invalid_with_msg(jv_string_fmt(\"Relative paths to modules may not traverse to parent directories (%s)\", s));\n      jv_free(name);\n      return res;\n    }\n    if (i > 0 && jv_equal(jv_copy(x), jv_array_get(jv_copy(components), i - 1))) {\n      jv_free(x);\n      jv_free(components);\n      jv res = jv_invalid_with_msg(jv_string_fmt(\"module names must not have equal consecutive components: %s\",\n                                                 jv_string_value(name)));\n      jv_free(name);\n      return res;\n    }\n    jv_free(x);\n  }\n  jv_free(components);\n  return name;\n}\n\n// Assumes name has been validated\nstatic jv jv_basename(jv name) {\n  const char *s = jv_string_value(name);\n  const char *p = strrchr(s, '/');\n  if (!p)\n    return name;\n  jv res = jv_string_fmt(\"%s\", p);\n  jv_free(name);\n  return res;\n}\n\n// Asummes validated relative path to module\nstatic jv find_lib(jq_state *jq, jv rel_path, jv search, const char *suffix, jv jq_origin, jv lib_origin) {\n  if (!jv_is_valid(rel_path)) {\n    jv_free(search);\n    jv_free(jq_origin);\n    jv_free(lib_origin);\n    return rel_path;\n  }\n  if (jv_get_kind(rel_path) != JV_KIND_STRING) {\n    jv_free(rel_path);\n    jv_free(search);\n    jv_free(jq_origin);\n    jv_free(lib_origin);\n    return jv_invalid_with_msg(jv_string_fmt(\"Module path must be a string\"));\n  }\n  if (jv_get_kind(search) != JV_KIND_ARRAY) {\n    jv_free(rel_path);\n    jv_free(search);\n    jv_free(jq_origin);\n    jv_free(lib_origin);\n    return jv_invalid_with_msg(jv_string_fmt(\"Module search path must be an array\"));\n  }\n\n  struct stat st;\n  int ret;\n\n  // Ideally we should cache this somewhere\n  search = build_lib_search_chain(jq, search, jq_origin, lib_origin);\n  jv err = jv_array_get(jv_copy(search), 1);\n  search = jv_array_get(search, 0);\n\n  jv bname = jv_basename(jv_copy(rel_path));\n\n  jv_array_foreach(search, i, spath) {\n    if (jv_get_kind(spath) == JV_KIND_NULL) {\n      jv_free(spath);\n      break;\n    }\n    if (jv_get_kind(spath) != JV_KIND_STRING ||\n        strcmp(jv_string_value(spath), \"\") == 0) {\n      jv_free(spath);\n      continue; /* XXX report non-strings in search path?? */\n    }\n    // Try ${search_dir}/${rel_path}.jq\n    jv testpath = jq_realpath(jv_string_fmt(\"%s/%s%s\",\n                                            jv_string_value(spath),\n                                            jv_string_value(rel_path),\n                                            suffix));\n    ret = stat(jv_string_value(testpath),&st);\n    if (ret == -1 && errno == ENOENT) {\n      jv_free(testpath);\n      // Try ${search_dir}/$(dirname ${rel_path})/jq/main.jq\n      testpath = jq_realpath(jv_string_fmt(\"%s/%s/%s%s\",\n                                           jv_string_value(spath),\n                                           jv_string_value(rel_path),\n                                           \"jq/main\",\n                                           suffix));\n      ret = stat(jv_string_value(testpath),&st);\n    }\n    if (ret == -1 && errno == ENOENT) {\n      jv_free(testpath);\n      // Try ${search_dir}/${rel_path}/$(basename ${rel_path}).jq\n      testpath = jq_realpath(jv_string_fmt(\"%s/%s/%s%s\",\n                                           jv_string_value(spath),\n                                           jv_string_value(rel_path),\n                                           jv_string_value(bname),\n                                           suffix));\n      ret = stat(jv_string_value(testpath),&st);\n    }\n    if (ret == 0) {\n      jv_free(err);\n      jv_free(rel_path);\n      jv_free(search);\n      jv_free(bname);\n      jv_free(spath);\n      return testpath;\n    }\n    jv_free(testpath);\n    jv_free(spath);\n  }\n  jv output;\n  if (!jv_is_valid(err)) {\n    err = jv_invalid_get_msg(err);\n    output = jv_invalid_with_msg(jv_string_fmt(\"module not found: %s (%s)\",\n                                               jv_string_value(rel_path),\n                                               jv_string_value(err)));\n  } else {\n    output = jv_invalid_with_msg(jv_string_fmt(\"module not found: %s\",\n                                               jv_string_value(rel_path)));\n  }\n  jv_free(err);\n  jv_free(rel_path);\n  jv_free(search);\n  jv_free(bname);\n  return output;\n}\n\nstatic jv default_search(jq_state *jq, jv value) {\n  if (!jv_is_valid(value)) {\n    // dependent didn't say; prepend . to system search path listj\n    jv_free(value);\n    return jv_array_concat(JV_ARRAY(jv_string(\".\")), jq_get_lib_dirs(jq));\n  }\n  if (jv_get_kind(value) != JV_KIND_ARRAY)\n    return JV_ARRAY(value);\n  return value;\n}\n\n// XXX Split this into a util that takes a callback, and then...\nstatic int process_dependencies(jq_state *jq, jv jq_origin, jv lib_origin, block *src_block, struct lib_loading_state *lib_state) {\n  jv deps = block_take_imports(src_block);\n  block bk = *src_block;\n  int nerrors = 0;\n\n  // XXX This is a backward jv_array_foreach because bindings go in reverse\n  for (int i = jv_array_length(jv_copy(deps)); i > 0; ) {\n    i--;\n    jv dep = jv_array_get(jv_copy(deps), i);\n\n    const char *as_str = NULL;\n    int is_data = jv_get_kind(jv_object_get(jv_copy(dep), jv_string(\"is_data\"))) == JV_KIND_TRUE;\n    int raw = 0;\n    jv v = jv_object_get(jv_copy(dep), jv_string(\"raw\"));\n    if (jv_get_kind(v) == JV_KIND_TRUE)\n      raw = 1;\n    int optional = 0;\n    if (jv_get_kind(jv_object_get(jv_copy(dep), jv_string(\"optional\"))) == JV_KIND_TRUE)\n      optional = 1;\n    jv_free(v);\n    jv relpath = validate_relpath(jv_object_get(jv_copy(dep), jv_string(\"relpath\")));\n    jv as = jv_object_get(jv_copy(dep), jv_string(\"as\"));\n    assert(!jv_is_valid(as) || jv_get_kind(as) == JV_KIND_STRING);\n    if (jv_get_kind(as) == JV_KIND_STRING)\n      as_str = jv_string_value(as);\n    jv search = default_search(jq, jv_object_get(dep, jv_string(\"search\")));\n    // dep is now freed; do not reuse\n\n    // find_lib does a lot of work that could be cached...\n    jv resolved = find_lib(jq, relpath, search, is_data ? \".json\" : \".jq\", jv_copy(jq_origin), jv_copy(lib_origin));\n    // XXX ...move the rest of this into a callback.\n    if (!jv_is_valid(resolved)) {\n      jv_free(as);\n      if (optional) {\n        jv_free(resolved);\n        continue;\n      }\n      jv emsg = jv_invalid_get_msg(resolved);\n      jq_report_error(jq, jv_string_fmt(\"jq: error: %s\\n\",jv_string_value(emsg)));\n      jv_free(emsg);\n      jv_free(deps);\n      jv_free(jq_origin);\n      jv_free(lib_origin);\n      return 1;\n    }\n\n    if (is_data) {\n      // Can't reuse data libs because the wrong name is bound\n      block dep_def_block;\n      nerrors += load_library(jq, resolved, is_data, raw, optional, as_str, &dep_def_block, lib_state);\n      if (nerrors == 0) {\n        // Bind as both $data::data and $data for backward compatibility vs common sense\n        bk = block_bind_library(dep_def_block, bk, OP_IS_CALL_PSEUDO, as_str);\n        bk = block_bind_library(dep_def_block, bk, OP_IS_CALL_PSEUDO, NULL);\n      }\n    } else {\n      uint64_t state_idx = 0;\n      for (; state_idx < lib_state->ct; ++state_idx) {\n        if (strcmp(lib_state->names[state_idx],jv_string_value(resolved)) == 0)\n          break;\n      }\n\n      if (state_idx < lib_state->ct) { // Found\n        jv_free(resolved);\n        // Bind the library to the program\n        bk = block_bind_library(lib_state->defs[state_idx], bk, OP_IS_CALL_PSEUDO, as_str);\n      } else { // Not found.   Add it to the table before binding.\n        block dep_def_block = gen_noop();\n        nerrors += load_library(jq, resolved, is_data, raw, optional, as_str, &dep_def_block, lib_state);\n        // resolved has been freed\n        if (nerrors == 0) {\n          // Bind the library to the program\n          bk = block_bind_library(dep_def_block, bk, OP_IS_CALL_PSEUDO, as_str);\n        }\n      }\n    }\n\n    jv_free(as);\n  }\n  jv_free(lib_origin);\n  jv_free(jq_origin);\n  jv_free(deps);\n  return nerrors;\n}\n\n// Loads the library at lib_path into lib_state, putting the library's defs\n// into *out_block\nstatic int load_library(jq_state *jq, jv lib_path, int is_data, int raw, int optional, const char *as, block *out_block, struct lib_loading_state *lib_state) {\n  int nerrors = 0;\n  struct locfile* src = NULL;\n  block program;\n  jv data;\n  if (is_data && !raw)\n    data = jv_load_file(jv_string_value(lib_path), 0);\n  else\n    data = jv_load_file(jv_string_value(lib_path), 1);\n  int state_idx;\n  if (!jv_is_valid(data)) {\n    program = gen_noop();\n    if (!optional) {\n      if (jv_invalid_has_msg(jv_copy(data)))\n        data = jv_invalid_get_msg(data);\n      else\n        data = jv_string(\"unknown error\");\n      jq_report_error(jq, jv_string_fmt(\"jq: error loading data file %s: %s\\n\", jv_string_value(lib_path), jv_string_value(data)));\n      nerrors++;\n    }\n    goto out;\n  } else if (is_data) {\n    // import \"foo\" as $bar;\n    program = gen_const_global(jv_copy(data), as);\n  } else {\n    // import \"foo\" as bar;\n    src = locfile_init(jq, jv_string_value(lib_path), jv_string_value(data), jv_string_length_bytes(jv_copy(data)));\n    nerrors += jq_parse_library(src, &program);\n    locfile_free(src);\n    if (nerrors == 0) {\n      char *lib_origin = strdup(jv_string_value(lib_path));\n      nerrors += process_dependencies(jq, jq_get_jq_origin(jq),\n                                      jv_string(dirname(lib_origin)),\n                                      &program, lib_state);\n      free(lib_origin);\n      program = block_bind_self(program, OP_IS_CALL_PSEUDO);\n    }\n  }\n  if (nerrors == 0) {\n    state_idx = lib_state->ct++;\n    lib_state->names = jv_mem_realloc(lib_state->names, lib_state->ct * sizeof(const char *));\n    lib_state->defs = jv_mem_realloc(lib_state->defs, lib_state->ct * sizeof(block));\n    lib_state->names[state_idx] = strdup(jv_string_value(lib_path));\n    lib_state->defs[state_idx] = program;\n  }\nout:\n  *out_block = program;\n  jv_free(lib_path);\n  jv_free(data);\n  return nerrors;\n}\n\n// FIXME It'd be nice to have an option to search the same search path\n// as we do in process_dependencies.\njv load_module_meta(jq_state *jq, jv mod_relpath) {\n  // We can't know the caller's origin; we could though, if it was passed in\n  jv lib_path = find_lib(jq, validate_relpath(mod_relpath), jq_get_lib_dirs(jq), \".jq\", jq_get_jq_origin(jq), jv_null());\n  if (!jv_is_valid(lib_path))\n    return lib_path;\n  jv meta = jv_null();\n  jv data = jv_load_file(jv_string_value(lib_path), 1);\n  if (jv_is_valid(data)) {\n    block program;\n    struct locfile* src = locfile_init(jq, jv_string_value(lib_path), jv_string_value(data), jv_string_length_bytes(jv_copy(data)));\n    int nerrors = jq_parse_library(src, &program);\n    if (nerrors == 0) {\n      meta = block_module_meta(program);\n      if (jv_get_kind(meta) == JV_KIND_NULL)\n        meta = jv_object();\n      meta = jv_object_set(meta, jv_string(\"deps\"), block_take_imports(&program));\n      meta = jv_object_set(meta, jv_string(\"defs\"), block_list_funcs(program, 0));\n    }\n    locfile_free(src);\n    block_free(program);\n  }\n  jv_free(lib_path);\n  jv_free(data);\n  return meta;\n}\n\nint load_program(jq_state *jq, struct locfile* src, block *out_block) {\n  int nerrors = 0;\n  block program;\n  struct lib_loading_state lib_state = {0,0,0};\n  nerrors = jq_parse(src, &program);\n  if (nerrors)\n    return nerrors;\n\n  if (!block_has_main(program)) {\n    jq_report_error(jq, jv_string(\"jq: error: Top-level program not given (try \\\".\\\")\"));\n    block_free(program);\n    return 1;\n  }\n\n  jv home = get_home();\n  if (jv_is_valid(home)) {\n    /* Import ~/.jq as a library named \"\" found in $HOME or %USERPROFILE% */\n    block import = gen_import_meta(gen_import(\"\", NULL, 0),\n        gen_const(JV_OBJECT(\n            jv_string(\"optional\"), jv_true(),\n            jv_string(\"search\"), home)));\n    program = BLOCK(import, program);\n  } else {    // silently ignore if home dir not determined\n    jv_free(home);\n  }\n\n  nerrors = process_dependencies(jq, jq_get_jq_origin(jq), jq_get_prog_origin(jq), &program, &lib_state);\n  block libs = gen_noop();\n  for (uint64_t i = 0; i < lib_state.ct; ++i) {\n    free(lib_state.names[i]);\n    if (nerrors == 0 && !block_is_const(lib_state.defs[i]))\n      libs = block_join(libs, lib_state.defs[i]);\n    else\n      block_free(lib_state.defs[i]);\n  }\n  free(lib_state.names);\n  free(lib_state.defs);\n  if (nerrors)\n    block_free(program);\n  else\n    *out_block = block_drop_unreferenced(block_join(libs, program));\n\n  return nerrors;\n}\n"
  },
  {
    "path": "src/linker.h",
    "content": "#ifndef LINKER_H\n#define LINKER_H\n\nint load_program(jq_state *jq, struct locfile* src, block *out_block);\njv load_module_meta(jq_state *jq, jv modname);\n\n#endif\n"
  },
  {
    "path": "src/locfile.c",
    "content": "#include <assert.h>\n#include <errno.h>\n#include <stdarg.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include \"jq.h\"\n#include \"jv_alloc.h\"\n#include \"locfile.h\"\n#include \"util.h\"\n\nstruct locfile* locfile_init(jq_state *jq, const char *fname, const char* data, int length) {\n  struct locfile* l = jv_mem_alloc(sizeof(struct locfile));\n  l->jq = jq;\n  l->fname = jv_string(fname);\n  l->data = jv_mem_alloc(length);\n  memcpy((char*)l->data,data,length);\n  l->length = length;\n  l->nlines = 1;\n  l->refct = 1;\n  for (int i=0; i<length; i++) {\n    if (data[i] == '\\n') l->nlines++;\n  }\n  l->linemap = jv_mem_calloc(l->nlines + 1, sizeof(int));\n  l->linemap[0] = 0;\n  int line = 1;\n  for (int i=0; i<length; i++) {\n    if (data[i] == '\\n') {\n      l->linemap[line] = i+1;   // at start of line, not of \\n\n      line++;\n    }\n  }\n  l->linemap[l->nlines] = length+1;   // virtual last \\n\n  return l;\n}\n\nstruct locfile* locfile_retain(struct locfile* l) {\n  l->refct++;\n  return l;\n}\nvoid locfile_free(struct locfile* l) {\n  if (--(l->refct) == 0) {\n    jv_free(l->fname);\n    jv_mem_free(l->linemap);\n    jv_mem_free((char*)l->data);\n    jv_mem_free(l);\n  }\n}\n\nint locfile_get_line(struct locfile* l, int pos) {\n  assert(pos < l->length);\n  int line = 1;\n  while (l->linemap[line] <= pos) line++;   // == if pos at start (before, never ==, because pos never on \\n)\n  assert(line-1 < l->nlines);\n  return line-1;\n}\n\nstatic int locfile_line_length(struct locfile* l, int line) {\n  assert(line < l->nlines);\n  return l->linemap[line+1] - l->linemap[line] -1;   // -1 to omit \\n\n}\n\nvoid locfile_locate(struct locfile* l, location loc, const char* fmt, ...) {\n  va_list fmtargs;\n  va_start(fmtargs, fmt);\n\n  jv m1 = jv_string_vfmt(fmt, fmtargs);\n  va_end(fmtargs);\n  if (!jv_is_valid(m1)) {\n    jq_report_error(l->jq, m1);\n    return;\n  }\n  if (loc.start == -1) {\n    jq_report_error(l->jq, jv_string_fmt(\"jq: error: %s\", jv_string_value(m1)));\n    jv_free(m1);\n    return;\n  }\n\n  int startline = locfile_get_line(l, loc.start);\n  int offset = l->linemap[startline];\n  int end = MIN(loc.end, MAX(l->linemap[startline+1] - 1, loc.start + 1));\n  jv underline = jv_string_repeat(jv_string(\"^\"), end - loc.start);\n  jv m2 = jv_string_fmt(\"%s at %s, line %d, column %d:\\n    %.*s\\n    %*s\",\n                        jv_string_value(m1), jv_string_value(l->fname),\n                        startline + 1, loc.start - offset + 1,\n                        locfile_line_length(l, startline), l->data + offset,\n                        end - offset, jv_string_value(underline));\n  jv_free(m1);\n  jv_free(underline);\n  jq_report_error(l->jq, m2);\n  return;\n}\n"
  },
  {
    "path": "src/locfile.h",
    "content": "#ifndef LOCFILE_H\n#define LOCFILE_H\n\n#include \"jq.h\"\n\ntypedef struct {\n  int start, end;\n} location;\n\nstatic const location UNKNOWN_LOCATION = {-1, -1};\n\nstruct locfile {\n  jv fname;\n  const char* data;\n  int length;\n  int* linemap;\n  int nlines;\n  char *error;\n  jq_state *jq;\n  int refct;\n};\n\nstruct locfile* locfile_init(jq_state *, const char *, const char *, int);\nstruct locfile* locfile_retain(struct locfile *);\nint locfile_get_line(struct locfile *, int);\nvoid locfile_free(struct locfile *);\nvoid locfile_locate(struct locfile *, location, const char *, ...);\n\n#endif\n"
  },
  {
    "path": "src/main.c",
    "content": "#include <assert.h>\n#include <ctype.h>\n#include <errno.h>\n#include <libgen.h>\n#ifdef HAVE_SETLOCALE\n#include <locale.h>\n#endif\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <unistd.h>\n\n#ifdef WIN32\n#include <windows.h>\n#include <io.h>\n#include <fcntl.h>\n#include <processenv.h>\n#include <shellapi.h>\n#include <wchar.h>\n#include <wtypes.h>\nextern void jv_tsd_dtoa_ctx_init();\n#endif\n\n#ifdef HAVE_LIBONIG\n#include <oniguruma.h>\n#endif\n\n#if !defined(HAVE_ISATTY) && defined(HAVE__ISATTY)\n#undef isatty\n#define isatty _isatty\n#endif\n\n#if defined(HAVE_ISATTY) || defined(HAVE__ISATTY)\n#define USE_ISATTY\n#endif\n\n#include \"jv.h\"\n#include \"jq.h\"\n#include \"util.h\"\n#include \"src/version.h\"\n#include \"src/config_opts.inc\"\n\nint jq_testsuite(jv lib_dirs, int verbose, int argc, char* argv[]);\n\n/*\n * For a longer help message we could use a better option parsing\n * strategy, one that lets stack options.\n */\nstatic void usage(int code, int keep_it_short) {\n  FILE *f = stderr;\n\n  if (code == 0)\n    f = stdout;\n\n  int ret = fprintf(f,\n    \"jq - commandline JSON processor [version %s]\\n\"\n    \"\\nUsage:\\tjq [options] <jq filter> [file...]\\n\"\n    \"\\tjq [options] --args <jq filter> [strings...]\\n\"\n    \"\\tjq [options] --jsonargs <jq filter> [JSON_TEXTS...]\\n\\n\"\n    \"jq is a tool for processing JSON inputs, applying the given filter to\\n\"\n    \"its JSON text inputs and producing the filter's results as JSON on\\n\"\n    \"standard output.\\n\\n\"\n    \"The simplest filter is ., which copies jq's input to its output\\n\"\n    \"unmodified except for formatting. For more advanced filters see\\n\"\n    \"the jq(1) manpage (\\\"man jq\\\") and/or https://jqlang.org/.\\n\\n\"\n    \"Example:\\n\\n\\t$ echo '{\\\"foo\\\": 0}' | jq .\\n\"\n    \"\\t{\\n\\t  \\\"foo\\\": 0\\n\\t}\\n\\n\", JQ_VERSION);\n  if (keep_it_short) {\n    fprintf(f, \"For listing the command options, use jq --help.\\n\");\n  } else {\n    (void) fprintf(f,\n      \"Command options:\\n\"\n      \"  -n, --null-input          use `null` as the single input value;\\n\"\n      \"  -R, --raw-input           read each line as string instead of JSON;\\n\"\n      \"  -s, --slurp               read all inputs into an array and use it as\\n\"\n      \"                            the single input value;\\n\"\n      \"  -c, --compact-output      compact instead of pretty-printed output;\\n\"\n      \"  -r, --raw-output          output strings without escapes and quotes;\\n\"\n      \"      --raw-output0         implies -r and output NUL after each output;\\n\"\n      \"  -j, --join-output         implies -r and output without newline after\\n\"\n      \"                            each output;\\n\"\n      \"  -a, --ascii-output        output strings by only ASCII characters\\n\"\n      \"                            using escape sequences;\\n\"\n      \"  -S, --sort-keys           sort keys of each object on output;\\n\"\n      \"  -C, --color-output        colorize JSON output;\\n\"\n      \"  -M, --monochrome-output   disable colored output;\\n\"\n      \"      --tab                 use tabs for indentation;\\n\"\n      \"      --indent n            use n spaces for indentation (max 7 spaces);\\n\"\n      \"      --unbuffered          flush output stream after each output;\\n\"\n      \"      --stream              parse the input value in streaming fashion;\\n\"\n      \"      --stream-errors       implies --stream and report parse error as\\n\"\n      \"                            an array;\\n\"\n      \"      --seq                 parse input/output as application/json-seq;\\n\"\n      \"  -f, --from-file           load the filter from a file;\\n\"\n      \"  -L, --library-path dir    search modules from the directory;\\n\"\n      \"      --arg name value      set $name to the string value;\\n\"\n      \"      --argjson name value  set $name to the JSON value;\\n\"\n      \"      --slurpfile name file set $name to an array of JSON values read\\n\"\n      \"                            from the file;\\n\"\n      \"      --rawfile name file   set $name to string contents of file;\\n\"\n      \"      --args                consume remaining arguments as positional\\n\"\n      \"                            string values;\\n\"\n      \"      --jsonargs            consume remaining arguments as positional\\n\"\n      \"                            JSON values;\\n\"\n      \"  -e, --exit-status         set exit status code based on the output;\\n\"\n#ifdef WIN32\n      \"  -b, --binary              open input/output streams in binary mode;\\n\"\n#endif\n      \"  -V, --version             show the version;\\n\"\n      \"  --build-configuration     show jq's build configuration;\\n\"\n      \"  -h, --help                show the help;\\n\"\n      \"  --                        terminates argument processing;\\n\\n\"\n      \"Named arguments are also available as $ARGS.named[], while\\n\"\n      \"positional arguments are available as $ARGS.positional[].\\n\");\n  }\n  exit((ret < 0 && code == 0) ? 2 : code);\n}\n\nstatic void die(void) {\n  fprintf(stderr, \"Use jq --help for help with command-line options,\\n\");\n  fprintf(stderr, \"or see the jq manpage, or online docs at https://jqlang.org\\n\");\n  exit(2);\n}\n\nstatic int isoptish(const char* text) {\n  return text[0] == '-' && (text[1] == '-' || isalpha((unsigned char)text[1]));\n}\n\nstatic int isoption(const char** text, char shortopt, const char* longopt, int is_short) {\n  if (is_short) {\n    if (shortopt && **text == shortopt) {\n      (*text)++;\n      if (!**text) *text = NULL;\n      return 1;\n    }\n  } else {\n    if (!strcmp(*text, longopt)) {\n      *text = NULL;\n      return 1;\n    }\n  }\n  return 0;\n}\n\nenum {\n  SLURP                 = 1,\n  RAW_INPUT             = 2,\n  PROVIDE_NULL          = 4,\n  RAW_OUTPUT            = 8,\n  RAW_OUTPUT0           = 16,\n  ASCII_OUTPUT          = 32,\n  COLOR_OUTPUT          = 64,\n  NO_COLOR_OUTPUT       = 128,\n  SORTED_OUTPUT         = 256,\n  FROM_FILE             = 512,\n  RAW_NO_LF             = 1024,\n  UNBUFFERED_OUTPUT     = 2048,\n  EXIT_STATUS           = 4096,\n  SEQ                   = 16384,\n  /* debugging only */\n  DUMP_DISASM           = 32768,\n};\n\nenum {\n    JQ_OK              =  0,\n    JQ_OK_NULL_KIND    = -1, /* exit 0 if --exit-status is not set*/\n    JQ_ERROR_SYSTEM    =  2,\n    JQ_ERROR_COMPILE   =  3,\n    JQ_OK_NO_OUTPUT    = -4, /* exit 0 if --exit-status is not set*/\n    JQ_ERROR_UNKNOWN   =  5,\n};\n#define jq_exit_with_status(r)  exit(abs(r))\n#define jq_exit(r)              exit( r > 0 ? r : 0 )\n\nstatic int process(jq_state *jq, jv value, int flags, int dumpopts, int options) {\n  int ret = JQ_OK_NO_OUTPUT; // No valid results && -e -> exit(4)\n  jq_start(jq, value, flags);\n  jv result;\n  while (jv_is_valid(result = jq_next(jq))) {\n    if ((options & RAW_OUTPUT) && jv_get_kind(result) == JV_KIND_STRING) {\n      if (options & ASCII_OUTPUT) {\n        jv_dumpf(jv_copy(result), stdout, JV_PRINT_ASCII);\n      } else if ((options & RAW_OUTPUT0) && strlen(jv_string_value(result)) != (unsigned long)jv_string_length_bytes(jv_copy(result))) {\n        jv_free(result);\n        result = jv_invalid_with_msg(jv_string(\n              \"Cannot dump a string containing NUL with --raw-output0 option\"));\n        break;\n      } else {\n        priv_fwrite(jv_string_value(result), jv_string_length_bytes(jv_copy(result)),\n            stdout, dumpopts & JV_PRINT_ISATTY);\n      }\n      ret = JQ_OK;\n      jv_free(result);\n    } else {\n      if (jv_get_kind(result) == JV_KIND_FALSE || jv_get_kind(result) == JV_KIND_NULL)\n        ret = JQ_OK_NULL_KIND;\n      else\n        ret = JQ_OK;\n      if (options & SEQ)\n        priv_fwrite(\"\\036\", 1, stdout, dumpopts & JV_PRINT_ISATTY);\n      jv_dump(result, dumpopts);\n    }\n    if (!(options & RAW_NO_LF))\n      priv_fwrite(\"\\n\", 1, stdout, dumpopts & JV_PRINT_ISATTY);\n    if (options & RAW_OUTPUT0)\n      priv_fwrite(\"\\0\", 1, stdout, dumpopts & JV_PRINT_ISATTY);\n    if (options & UNBUFFERED_OUTPUT)\n      fflush(stdout);\n  }\n  if (jq_halted(jq)) {\n    // jq program invoked `halt` or `halt_error`\n    jv exit_code = jq_get_exit_code(jq);\n    if (!jv_is_valid(exit_code))\n      ret = JQ_OK;\n    else if (jv_get_kind(exit_code) == JV_KIND_NUMBER)\n      ret = jv_number_value(exit_code);\n    else\n      ret = JQ_ERROR_UNKNOWN;\n    jv_free(exit_code);\n    jv error_message = jq_get_error_message(jq);\n    if (jv_get_kind(error_message) == JV_KIND_STRING) {\n      // No prefix should be added to the output of `halt_error`.\n      priv_fwrite(jv_string_value(error_message), jv_string_length_bytes(jv_copy(error_message)),\n          stderr, dumpopts & JV_PRINT_ISATTY);\n    } else if (jv_get_kind(error_message) == JV_KIND_NULL) {\n      // Halt with no output\n    } else if (jv_is_valid(error_message)) {\n      error_message = jv_dump_string(error_message, 0);\n      fprintf(stderr, \"%s\\n\", jv_string_value(error_message));\n    } // else no message on stderr; use --debug-trace to see a message\n    fflush(stderr);\n    jv_free(error_message);\n  } else if (jv_invalid_has_msg(jv_copy(result))) {\n    // Uncaught jq exception\n    jv msg = jv_invalid_get_msg(jv_copy(result));\n    jv input_pos = jq_util_input_get_position(jq);\n    if (jv_get_kind(msg) == JV_KIND_STRING) {\n      fprintf(stderr, \"jq: error (at %s): %s\\n\",\n              jv_string_value(input_pos), jv_string_value(msg));\n    } else {\n      msg = jv_dump_string(msg, 0);\n      fprintf(stderr, \"jq: error (at %s) (not a string): %s\\n\",\n              jv_string_value(input_pos), jv_string_value(msg));\n    }\n    ret = JQ_ERROR_UNKNOWN;\n    jv_free(input_pos);\n    jv_free(msg);\n  }\n  jv_free(result);\n  return ret;\n}\n\nstatic void debug_cb(void *data, jv input) {\n  int dumpopts = *(int *)data;\n  jv_dumpf(JV_ARRAY(jv_string(\"DEBUG:\"), input), stderr, dumpopts & ~(JV_PRINT_PRETTY));\n  fprintf(stderr, \"\\n\");\n}\n\nstatic void stderr_cb(void *data, jv input) {\n  if (jv_get_kind(input) == JV_KIND_STRING) {\n    int dumpopts = *(int *)data;\n    priv_fwrite(jv_string_value(input), jv_string_length_bytes(jv_copy(input)),\n        stderr, dumpopts & JV_PRINT_ISATTY);\n  } else {\n    input = jv_dump_string(input, 0);\n    fprintf(stderr, \"%s\", jv_string_value(input));\n  }\n  jv_free(input);\n}\n\n#ifdef WIN32\nint umain(int argc, char* argv[]);\n\nint wmain(int argc, wchar_t* wargv[]) {\n  size_t arg_sz;\n  char **argv = alloca(argc * sizeof(wchar_t*));\n  for (int i = 0; i < argc; i++) {\n    argv[i] = alloca((arg_sz = WideCharToMultiByte(CP_UTF8,\n                                                   0,\n                                                   wargv[i],\n                                                   -1, 0, 0, 0, 0)));\n    WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, argv[i], arg_sz, 0, 0);\n  }\n  return umain(argc, argv);\n}\n\nint umain(int argc, char* argv[]) {\n#else /*}*/\nint main(int argc, char* argv[]) {\n#endif\n  jq_state *jq = NULL;\n  jq_util_input_state *input_state = NULL;\n  int ret = JQ_OK_NO_OUTPUT;\n  int compiled = 0;\n  int parser_flags = 0;\n  int nfiles = 0;\n  int last_result = -1; /* -1 = no result, 0=null or false, 1=true */\n  int badwrite;\n  int options = 0;\n\n#ifdef HAVE_SETLOCALE\n  (void) setlocale(LC_ALL, \"\");\n#endif\n\n#ifdef HAVE_LIBONIG\n  // use a lower regex parse depth limit than the default (4096) to protect\n  // from stack-overflows\n  // https://github.com/jqlang/jq/security/advisories/GHSA-f946-j5j2-4w5m\n  onig_set_parse_depth_limit(1024);\n#endif\n\n#ifdef __OpenBSD__\n  if (pledge(\"stdio rpath\", NULL) == -1) {\n    perror(\"pledge\");\n    exit(JQ_ERROR_SYSTEM);\n  }\n#endif\n\n#ifdef WIN32\n  jv_tsd_dtoa_ctx_init();\n  fflush(stdout);\n  fflush(stderr);\n  _setmode(fileno(stdout), _O_TEXT | _O_U8TEXT);\n  _setmode(fileno(stderr), _O_TEXT | _O_U8TEXT);\n#endif\n\n  jv ARGS = jv_array(); /* positional arguments */\n  jv program_arguments = jv_object(); /* named arguments */\n\n  jq = jq_init();\n  if (jq == NULL) {\n    perror(\"jq_init\");\n    ret = JQ_ERROR_SYSTEM;\n    goto out;\n  }\n\n  int dumpopts = JV_PRINT_INDENT_FLAGS(2);\n  const char* program = 0;\n\n  input_state = jq_util_input_init(NULL, NULL); // XXX add err_cb\n\n  int further_args_are_strings = 0;\n  int further_args_are_json = 0;\n  int args_done = 0;\n  int jq_flags = 0;\n  jv lib_search_paths = jv_null();\n  for (int i=1; i<argc; i++) {\n    if (args_done || !isoptish(argv[i])) {\n      if (!program) {\n        program = argv[i];\n      } else if (further_args_are_strings) {\n        ARGS = jv_array_append(ARGS, jv_string(argv[i]));\n      } else if (further_args_are_json) {\n        jv v =  jv_parse(argv[i]);\n        if (!jv_is_valid(v)) {\n          fprintf(stderr, \"jq: invalid JSON text passed to --jsonargs\\n\");\n          die();\n        }\n        ARGS = jv_array_append(ARGS, v);\n      } else {\n        jq_util_input_add_input(input_state, argv[i]);\n        nfiles++;\n      }\n    } else if (!strcmp(argv[i], \"--\")) {\n      args_done = 1;\n    } else {\n      const char* text = argv[i];\n      int is_short;\n      // First '-' already checked by isoptish\n      if (text[1] == '-') {\n        text += 2;\n        is_short = 0;\n      } else {\n        text++;\n        is_short = 1;\n      }\n      int raw; // Temporary for --rawfile\n\n      // Parse a long option in one iteration or iterate over short options\n      while (text != NULL) {\n        if (isoption(&text, 's', \"slurp\", is_short)) {\n          options |= SLURP;\n        } else if (isoption(&text, 'r', \"raw-output\", is_short)) {\n          options |= RAW_OUTPUT;\n        } else if (isoption(&text, 0, \"raw-output0\", is_short)) {\n          options |= RAW_OUTPUT | RAW_NO_LF | RAW_OUTPUT0;\n        } else if (isoption(&text, 'j', \"join-output\", is_short)) {\n          options |= RAW_OUTPUT | RAW_NO_LF;\n        } else if (isoption(&text, 'c', \"compact-output\", is_short)) {\n          dumpopts &= ~(JV_PRINT_TAB | JV_PRINT_INDENT_FLAGS(7));\n        } else if (isoption(&text, 'C', \"color-output\", is_short)) {\n          options |= COLOR_OUTPUT;\n        } else if (isoption(&text, 'M', \"monochrome-output\", is_short)) {\n          options |= NO_COLOR_OUTPUT;\n        } else if (isoption(&text, 'a', \"ascii-output\", is_short)) {\n          options |= ASCII_OUTPUT;\n        } else if (isoption(&text, 0, \"unbuffered\", is_short)) {\n          options |= UNBUFFERED_OUTPUT;\n        } else if (isoption(&text, 'S', \"sort-keys\", is_short)) {\n          options |= SORTED_OUTPUT;\n        } else if (isoption(&text, 'R', \"raw-input\", is_short)) {\n          options |= RAW_INPUT;\n        } else if (isoption(&text, 'n', \"null-input\", is_short)) {\n          options |= PROVIDE_NULL;\n        } else if (isoption(&text, 'f', \"from-file\", is_short)) {\n          options |= FROM_FILE;\n        } else if (isoption(&text, 'L', \"library-path\", is_short)) {\n          if (jv_get_kind(lib_search_paths) == JV_KIND_NULL)\n            lib_search_paths = jv_array();\n          if (text != NULL) { // -Lname\n            lib_search_paths = jv_array_append(lib_search_paths, jq_realpath(jv_string(text)));\n            text = NULL;\n          } else if (i >= argc - 1) {\n            fprintf(stderr, \"-L takes a parameter: (e.g. -L /search/path or -L/search/path)\\n\");\n            die();\n          } else {\n            lib_search_paths = jv_array_append(lib_search_paths, jq_realpath(jv_string(argv[i+1])));\n            i++;\n          }\n        } else if (isoption(&text, 'b', \"binary\", is_short)) {\n#ifdef WIN32\n          fflush(stdout);\n          fflush(stderr);\n          _setmode(fileno(stdin),  _O_BINARY);\n          _setmode(fileno(stdout), _O_BINARY);\n          _setmode(fileno(stderr), _O_BINARY);\n#endif\n        } else if (isoption(&text, 0, \"tab\", is_short)) {\n          dumpopts &= ~JV_PRINT_INDENT_FLAGS(7);\n          dumpopts |= JV_PRINT_TAB | JV_PRINT_PRETTY;\n        } else if (isoption(&text, 0, \"indent\", is_short)) {\n          if (i >= argc - 1) {\n            fprintf(stderr, \"jq: --indent takes one parameter\\n\");\n            die();\n          }\n          char* end = NULL;\n          errno = 0;\n          long indent = strtol(argv[i+1], &end, 10);\n          if (errno || indent < -1 || indent > 7 ||\n              isspace(*argv[i+1]) || end == argv[i+1] || *end) {\n            fprintf(stderr, \"jq: --indent takes a number between -1 and 7\\n\");\n            die();\n          }\n          dumpopts &= ~(JV_PRINT_TAB | JV_PRINT_INDENT_FLAGS(7));\n          dumpopts |= JV_PRINT_INDENT_FLAGS(indent);\n          i++;\n        } else if (isoption(&text, 0, \"seq\", is_short)) {\n          options |= SEQ;\n        } else if (isoption(&text, 0, \"stream\", is_short)) {\n          parser_flags |= JV_PARSE_STREAMING;\n        } else if (isoption(&text, 0, \"stream-errors\", is_short)) {\n          parser_flags |= JV_PARSE_STREAMING | JV_PARSE_STREAM_ERRORS;\n        } else if (isoption(&text, 'e', \"exit-status\", is_short)) {\n          options |= EXIT_STATUS;\n        } else if (isoption(&text, 0, \"args\", is_short)) {\n          further_args_are_strings = 1;\n          further_args_are_json = 0;\n        } else if (isoption(&text, 0, \"jsonargs\", is_short)) {\n          further_args_are_strings = 0;\n          further_args_are_json = 1;\n        } else if (isoption(&text, 0, \"arg\", is_short)) {\n          if (i >= argc - 2) {\n            fprintf(stderr, \"jq: --arg takes two parameters (e.g. --arg varname value)\\n\");\n            die();\n          }\n          if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1])))\n            program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), jv_string(argv[i+2]));\n          i += 2; // skip the next two arguments\n        } else if (isoption(&text, 0, \"argjson\", is_short)) {\n          if (i >= argc - 2) {\n            fprintf(stderr, \"jq: --argjson takes two parameters (e.g. --argjson varname text)\\n\");\n            die();\n          }\n          if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1]))) {\n            jv v = jv_parse(argv[i+2]);\n            if (!jv_is_valid(v)) {\n              fprintf(stderr, \"jq: invalid JSON text passed to --argjson\\n\");\n              die();\n            }\n            program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), v);\n          }\n          i += 2; // skip the next two arguments\n        } else if ((raw = isoption(&text, 0, \"rawfile\", is_short)) ||\n            isoption(&text, 0, \"slurpfile\", is_short)) {\n          const char *which = raw ? \"rawfile\" : \"slurpfile\";\n          if (i >= argc - 2) {\n            fprintf(stderr, \"jq: --%s takes two parameters (e.g. --%s varname filename)\\n\", which, which);\n            die();\n          }\n          if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1]))) {\n            jv data = jv_load_file(argv[i+2], raw);\n            if (!jv_is_valid(data)) {\n              data = jv_invalid_get_msg(data);\n              fprintf(stderr, \"jq: Bad JSON in --%s %s %s: %s\\n\", which,\n                      argv[i+1], argv[i+2], jv_string_value(data));\n              jv_free(data);\n              ret = JQ_ERROR_SYSTEM;\n              goto out;\n            }\n            program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), data);\n          }\n          i += 2; // skip the next two arguments\n        } else if (isoption(&text,  0,  \"debug-dump-disasm\", is_short)) {\n          options |= DUMP_DISASM;\n        } else if (isoption(&text,  0,  \"debug-trace=all\", is_short)) {\n          jq_flags |= JQ_DEBUG_TRACE_ALL;\n        } else if (isoption(&text,  0,  \"debug-trace\", is_short)) {\n          jq_flags |= JQ_DEBUG_TRACE;\n        } else if (isoption(&text, 'h', \"help\", is_short)) {\n          usage(0, 0);\n        } else if (isoption(&text, 'V', \"version\", is_short)) {\n          printf(\"jq-%s\\n\", JQ_VERSION);\n          ret = JQ_OK;\n          goto out;\n        } else if (isoption(&text, 0, \"build-configuration\", is_short)) {\n          printf(\"%s\\n\", JQ_CONFIG);\n          ret = JQ_OK;\n          goto out;\n        } else if (isoption(&text, 0, \"run-tests\", is_short)) {\n          i++;\n          // XXX Pass program_arguments, even a whole jq_state *, through;\n          // could be useful for testing\n          ret = jq_testsuite(lib_search_paths,\n                             (options & DUMP_DISASM) || (jq_flags & JQ_DEBUG_TRACE),\n                             argc - i, argv + i);\n          goto out;\n        } else {\n          if (is_short) {\n            fprintf(stderr, \"jq: Unknown option -%c\\n\", text[0]);\n          } else {\n            fprintf(stderr, \"jq: Unknown option --%s\\n\", text);\n          }\n          die();\n        }\n      }\n    }\n  }\n\n#ifdef USE_ISATTY\n  if (isatty(STDOUT_FILENO)) {\n#ifndef WIN32\n    dumpopts |= JV_PRINT_ISATTY | JV_PRINT_COLOR;\n#else\n  /* Verify we actually have the console, as the NUL device is also regarded as\n     tty.  Windows can handle color if ANSICON (or ConEmu) is installed, or\n     Windows 10 supports the virtual terminal */\n    DWORD mode;\n    HANDLE con = GetStdHandle(STD_OUTPUT_HANDLE);\n    if (GetConsoleMode(con, &mode)) {\n      dumpopts |= JV_PRINT_ISATTY;\n      if (getenv(\"ANSICON\") != NULL ||\n          SetConsoleMode(con, mode | 4/*ENABLE_VIRTUAL_TERMINAL_PROCESSING*/))\n        dumpopts |= JV_PRINT_COLOR;\n    }\n#endif\n    if (dumpopts & JV_PRINT_COLOR) {\n      char *no_color = getenv(\"NO_COLOR\");\n      if (no_color != NULL && no_color[0] != '\\0')\n        dumpopts &= ~JV_PRINT_COLOR;\n    }\n  }\n#endif\n  if (options & SORTED_OUTPUT) dumpopts |= JV_PRINT_SORTED;\n  if (options & ASCII_OUTPUT) dumpopts |= JV_PRINT_ASCII;\n  if (options & COLOR_OUTPUT) dumpopts |= JV_PRINT_COLOR;\n  if (options & NO_COLOR_OUTPUT) dumpopts &= ~JV_PRINT_COLOR;\n\n  if (!jq_set_colors(getenv(\"JQ_COLORS\")))\n      fprintf(stderr, \"Failed to set $JQ_COLORS\\n\");\n\n  if (jv_get_kind(lib_search_paths) == JV_KIND_NULL) {\n    // Default search path list\n    lib_search_paths = JV_ARRAY(jv_string(\"~/.jq\"),\n                                jv_string(\"$ORIGIN/../lib/jq\"),\n                                jv_string(\"$ORIGIN/../lib\"));\n  }\n  jq_set_attr(jq, jv_string(\"JQ_LIBRARY_PATH\"), lib_search_paths);\n\n  char *origin = strdup(argv[0]);\n  if (origin == NULL) {\n    fprintf(stderr, \"jq: error: out of memory\\n\");\n    exit(1);\n  }\n  jq_set_attr(jq, jv_string(\"JQ_ORIGIN\"), jv_string(dirname(origin)));\n  free(origin);\n\n  if (strchr(JQ_VERSION, '-') == NULL)\n    jq_set_attr(jq, jv_string(\"VERSION_DIR\"), jv_string(JQ_VERSION));\n  else\n    jq_set_attr(jq, jv_string(\"VERSION_DIR\"), jv_string_fmt(\"%.*s-master\", (int)(strchr(JQ_VERSION, '-') - JQ_VERSION), JQ_VERSION));\n\n#ifdef USE_ISATTY\n  if (!program && !(options & FROM_FILE) && (!isatty(STDOUT_FILENO) || !isatty(STDIN_FILENO)))\n    program = \".\";\n#endif\n\n  if (!program) usage(2, 1);\n\n  if (options & FROM_FILE) {\n    char *program_origin = strdup(program);\n    if (program_origin == NULL) {\n      perror(\"malloc\");\n      exit(2);\n    }\n\n    jv data = jv_load_file(program, 1);\n    if (!jv_is_valid(data)) {\n      data = jv_invalid_get_msg(data);\n      fprintf(stderr, \"jq: %s\\n\", jv_string_value(data));\n      free(program_origin);\n      jv_free(data);\n      ret = JQ_ERROR_SYSTEM;\n      goto out;\n    }\n    jq_set_attr(jq, jv_string(\"PROGRAM_ORIGIN\"), jq_realpath(jv_string(dirname(program_origin))));\n    ARGS = JV_OBJECT(jv_string(\"positional\"), ARGS,\n                     jv_string(\"named\"), jv_copy(program_arguments));\n    program_arguments = jv_object_set(program_arguments, jv_string(\"ARGS\"), jv_copy(ARGS));\n    if (!jv_object_has(jv_copy(program_arguments), jv_string(\"JQ_BUILD_CONFIGURATION\")))\n      program_arguments = jv_object_set(program_arguments,\n                                        jv_string(\"JQ_BUILD_CONFIGURATION\"),\n                                        jv_string(JQ_CONFIG)); /* named arguments */\n    compiled = jq_compile_args(jq, jv_string_value(data), jv_copy(program_arguments));\n    free(program_origin);\n    jv_free(data);\n  } else {\n    jq_set_attr(jq, jv_string(\"PROGRAM_ORIGIN\"), jq_realpath(jv_string(\".\"))); // XXX is this good?\n    ARGS = JV_OBJECT(jv_string(\"positional\"), ARGS,\n                     jv_string(\"named\"), jv_copy(program_arguments));\n    program_arguments = jv_object_set(program_arguments, jv_string(\"ARGS\"), jv_copy(ARGS));\n    if (!jv_object_has(jv_copy(program_arguments), jv_string(\"JQ_BUILD_CONFIGURATION\")))\n      program_arguments = jv_object_set(program_arguments,\n                                        jv_string(\"JQ_BUILD_CONFIGURATION\"),\n                                        jv_string(JQ_CONFIG)); /* named arguments */\n    compiled = jq_compile_args(jq, program, jv_copy(program_arguments));\n  }\n  if (!compiled){\n    ret = JQ_ERROR_COMPILE;\n    goto out;\n  }\n\n  if (options & DUMP_DISASM) {\n    jq_dump_disassembly(jq, 0);\n    printf(\"\\n\");\n  }\n\n  if ((options & SEQ))\n    parser_flags |= JV_PARSE_SEQ;\n\n  if ((options & RAW_INPUT))\n    jq_util_input_set_parser(input_state, NULL, (options & SLURP) ? 1 : 0);\n  else\n    jq_util_input_set_parser(input_state, jv_parser_new(parser_flags), (options & SLURP) ? 1 : 0);\n\n  // Let jq program read from inputs\n  jq_set_input_cb(jq, jq_util_input_next_input_cb, input_state);\n\n  // Let jq program call `debug` builtin and have that go somewhere\n  jq_set_debug_cb(jq, debug_cb, &dumpopts);\n\n  // Let jq program call `stderr` builtin and have that go somewhere\n  jq_set_stderr_cb(jq, stderr_cb, &dumpopts);\n\n  if (nfiles == 0)\n    jq_util_input_add_input(input_state, \"-\");\n\n  if (options & PROVIDE_NULL) {\n    ret = process(jq, jv_null(), jq_flags, dumpopts, options);\n  } else {\n    jv value;\n    while (jq_util_input_errors(input_state) == 0 &&\n           (jv_is_valid((value = jq_util_input_next_input(input_state))) || jv_invalid_has_msg(jv_copy(value)))) {\n      if (jv_is_valid(value)) {\n        ret = process(jq, value, jq_flags, dumpopts, options);\n        if (ret <= 0 && ret != JQ_OK_NO_OUTPUT)\n          last_result = (ret != JQ_OK_NULL_KIND);\n        if (jq_halted(jq))\n          break;\n        continue;\n      }\n\n      // Parse error\n      jv msg = jv_invalid_get_msg(value);\n      if (!(options & SEQ)) {\n        ret = JQ_ERROR_UNKNOWN;\n        fprintf(stderr, \"jq: parse error: %s\\n\", jv_string_value(msg));\n        jv_free(msg);\n        break;\n      }\n      // --seq -> errors are not fatal\n      fprintf(stderr, \"jq: ignoring parse error: %s\\n\", jv_string_value(msg));\n      jv_free(msg);\n    }\n  }\n\n  if (jq_util_input_errors(input_state) != 0)\n    ret = JQ_ERROR_SYSTEM;\n\nout:\n  badwrite = ferror(stdout);\n  if (fclose(stdout)!=0 || badwrite) {\n    fprintf(stderr,\"jq: error: writing output failed: %s\\n\", strerror(errno));\n    ret = JQ_ERROR_SYSTEM;\n  }\n\n  jv_free(ARGS);\n  jv_free(program_arguments);\n  jq_util_input_free(&input_state);\n  jq_teardown(&jq);\n\n  if (options & EXIT_STATUS) {\n    if (ret != JQ_OK_NO_OUTPUT)\n      jq_exit_with_status(ret);\n    else\n      switch (last_result) {\n        case -1: jq_exit_with_status(JQ_OK_NO_OUTPUT);\n        case  0: jq_exit_with_status(JQ_OK_NULL_KIND);\n        default: jq_exit_with_status(JQ_OK);\n      }\n  } else\n    jq_exit(ret);\n}\n"
  },
  {
    "path": "src/opcode_list.h",
    "content": "OP(LOADK, CONSTANT, 1, 1)\nOP(DUP,   NONE,     1, 2)\nOP(DUPN,  NONE,     1, 2)\nOP(DUP2,  NONE,     2, 3)\nOP(PUSHK_UNDER, CONSTANT, 1, 2)\nOP(POP,   NONE,     1, 0)\nOP(LOADV, VARIABLE, 1, 1)\nOP(LOADVN, VARIABLE, 1, 1)\nOP(STOREV, VARIABLE, 1, 0)\nOP(STORE_GLOBAL, GLOBAL, 0, 0)\nOP(INDEX, NONE,     2, 1)\nOP(INDEX_OPT, NONE,     2, 1)\nOP(EACH,  NONE,     1, 1)\nOP(EACH_OPT,  NONE, 1, 1)\nOP(FORK,  BRANCH,   0, 0)\nOP(TRY_BEGIN,  BRANCH,   0, 0)\nOP(TRY_END,  NONE,   0, 0)\nOP(JUMP,  BRANCH,   0, 0)\nOP(JUMP_F,BRANCH,   1, 0)\nOP(BACKTRACK, NONE, 0, 0)\nOP(APPEND, VARIABLE,1, 0)\nOP(INSERT, NONE,    4, 2)\nOP(RANGE, VARIABLE, 1, 1)\n\nOP(SUBEXP_BEGIN,  NONE,     1, 2)\nOP(SUBEXP_END,    NONE,     2, 2)\n\nOP(PATH_BEGIN, NONE, 1, 2)\nOP(PATH_END,   NONE, 2, 1)\n\nOP(CALL_BUILTIN, CFUNC, -1, 1)\n\nOP(CALL_JQ, UFUNC, 1, 1)\nOP(RET, NONE, 1, 1)\nOP(TAIL_CALL_JQ, UFUNC, 1, 1)\n\nOP(CLOSURE_PARAM, DEFINITION, 0, 0)\nOP(CLOSURE_REF, CLOSURE_REF_IMM, 0, 0)\nOP(CLOSURE_CREATE, DEFINITION, 0, 0)\nOP(CLOSURE_CREATE_C, DEFINITION, 0, 0)\n\nOP(TOP, NONE, 0, 0)\nOP(CLOSURE_PARAM_REGULAR, DEFINITION, 0, 0)\nOP(DEPS, CONSTANT, 0, 0)\nOP(MODULEMETA, CONSTANT, 0, 0)\nOP(GENLABEL, NONE, 0, 1)\n\nOP(DESTRUCTURE_ALT, BRANCH, 0, 0)\nOP(STOREVN, VARIABLE, 1, 0)\n\nOP(ERRORK, CONSTANT, 1, 0)\n"
  },
  {
    "path": "src/parser.c",
    "content": "/* A Bison parser, made by GNU Bison 3.8.2.  */\n\n/* Bison implementation for Yacc-like parsers in C\n\n   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,\n   Inc.\n\n   This program is free software: you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */\n\n/* As a special exception, you may create a larger work that contains\n   part or all of the Bison parser skeleton and distribute that work\n   under terms of your choice, so long as that work isn't itself a\n   parser generator using the skeleton or a modified version thereof\n   as a parser skeleton.  Alternatively, if you modify or redistribute\n   the parser skeleton itself, you may (at your option) remove this\n   special exception, which will cause the skeleton and the resulting\n   Bison output files to be licensed under the GNU General Public\n   License without this special exception.\n\n   This special exception was added by the Free Software Foundation in\n   version 2.2 of Bison.  */\n\n/* C LALR(1) parser skeleton written by Richard Stallman, by\n   simplifying the original so-called \"semantic\" parser.  */\n\n/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,\n   especially those whose name start with YY_ or yy_.  They are\n   private implementation details that can be changed or removed.  */\n\n/* All symbols defined below should begin with yy or YY, to avoid\n   infringing on user name space.  This should be done even for local\n   variables, as they might otherwise be expanded by user macros.\n   There are some unavoidable exceptions within include files to\n   define necessary library symbols; they are noted \"INFRINGES ON\n   USER NAME SPACE\" below.  */\n\n/* Identify Bison output, and Bison version.  */\n#define YYBISON 30802\n\n/* Bison version string.  */\n#define YYBISON_VERSION \"3.8.2\"\n\n/* Skeleton name.  */\n#define YYSKELETON_NAME \"yacc.c\"\n\n/* Pure parsers.  */\n#define YYPURE 1\n\n/* Push parsers.  */\n#define YYPUSH 0\n\n/* Pull parsers.  */\n#define YYPULL 1\n\n\n\n\n/* First part of user prologue.  */\n#line 1 \"src/parser.y\"\n\n#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n#include <string.h>\n#include \"compile.h\"\n#include \"jv_alloc.h\"\n#include \"builtin.h\"\n#define YYMALLOC jv_mem_alloc\n#define YYFREE jv_mem_free\n\n#line 83 \"src/parser.c\"\n\n# ifndef YY_CAST\n#  ifdef __cplusplus\n#   define YY_CAST(Type, Val) static_cast<Type> (Val)\n#   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)\n#  else\n#   define YY_CAST(Type, Val) ((Type) (Val))\n#   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))\n#  endif\n# endif\n# ifndef YY_NULLPTR\n#  if defined __cplusplus\n#   if 201103L <= __cplusplus\n#    define YY_NULLPTR nullptr\n#   else\n#    define YY_NULLPTR 0\n#   endif\n#  else\n#   define YY_NULLPTR ((void*)0)\n#  endif\n# endif\n\n/* Use api.header.include to #include this header\n   instead of duplicating it here.  */\n#ifndef YY_YY_SRC_PARSER_H_INCLUDED\n# define YY_YY_SRC_PARSER_H_INCLUDED\n/* Debug traces.  */\n#ifndef YYDEBUG\n# define YYDEBUG 0\n#endif\n#if YYDEBUG\nextern int yydebug;\n#endif\n/* \"%code requires\" blocks.  */\n#line 12 \"src/parser.y\"\n\n#include \"locfile.h\"\nstruct lexer_param;\n\n#define YYLTYPE location\n#define YYLLOC_DEFAULT(Loc, Rhs, N)             \\\n  do {                                          \\\n    if (N) {                                    \\\n      (Loc).start = YYRHSLOC(Rhs, 1).start;     \\\n      (Loc).end = YYRHSLOC(Rhs, N).end;         \\\n    } else {                                    \\\n      (Loc).start = YYRHSLOC(Rhs, 0).end;       \\\n      (Loc).end = YYRHSLOC(Rhs, 0).end;         \\\n    }                                           \\\n  } while (0)\n\n#line 135 \"src/parser.c\"\n\n/* Token kinds.  */\n#ifndef YYTOKENTYPE\n# define YYTOKENTYPE\n  enum yytokentype\n  {\n    YYEMPTY = -2,\n    YYEOF = 0,                     /* \"end of file\"  */\n    YYerror = 256,                 /* error  */\n    YYUNDEF = 257,                 /* \"invalid token\"  */\n    INVALID_CHARACTER = 258,       /* INVALID_CHARACTER  */\n    IDENT = 259,                   /* IDENT  */\n    FIELD = 260,                   /* FIELD  */\n    BINDING = 261,                 /* BINDING  */\n    LITERAL = 262,                 /* LITERAL  */\n    FORMAT = 263,                  /* FORMAT  */\n    REC = 264,                     /* \"..\"  */\n    SETMOD = 265,                  /* \"%=\"  */\n    EQ = 266,                      /* \"==\"  */\n    NEQ = 267,                     /* \"!=\"  */\n    DEFINEDOR = 268,               /* \"//\"  */\n    AS = 269,                      /* \"as\"  */\n    DEF = 270,                     /* \"def\"  */\n    MODULE = 271,                  /* \"module\"  */\n    IMPORT = 272,                  /* \"import\"  */\n    INCLUDE = 273,                 /* \"include\"  */\n    IF = 274,                      /* \"if\"  */\n    THEN = 275,                    /* \"then\"  */\n    ELSE = 276,                    /* \"else\"  */\n    ELSE_IF = 277,                 /* \"elif\"  */\n    REDUCE = 278,                  /* \"reduce\"  */\n    FOREACH = 279,                 /* \"foreach\"  */\n    END = 280,                     /* \"end\"  */\n    AND = 281,                     /* \"and\"  */\n    OR = 282,                      /* \"or\"  */\n    TRY = 283,                     /* \"try\"  */\n    CATCH = 284,                   /* \"catch\"  */\n    LABEL = 285,                   /* \"label\"  */\n    BREAK = 286,                   /* \"break\"  */\n    LOC = 287,                     /* \"$__loc__\"  */\n    SETPIPE = 288,                 /* \"|=\"  */\n    SETPLUS = 289,                 /* \"+=\"  */\n    SETMINUS = 290,                /* \"-=\"  */\n    SETMULT = 291,                 /* \"*=\"  */\n    SETDIV = 292,                  /* \"/=\"  */\n    SETDEFINEDOR = 293,            /* \"//=\"  */\n    LESSEQ = 294,                  /* \"<=\"  */\n    GREATEREQ = 295,               /* \">=\"  */\n    ALTERNATION = 296,             /* \"?//\"  */\n    QQSTRING_START = 297,          /* QQSTRING_START  */\n    QQSTRING_TEXT = 298,           /* QQSTRING_TEXT  */\n    QQSTRING_INTERP_START = 299,   /* QQSTRING_INTERP_START  */\n    QQSTRING_INTERP_END = 300,     /* QQSTRING_INTERP_END  */\n    QQSTRING_END = 301,            /* QQSTRING_END  */\n    FUNCDEF = 302,                 /* FUNCDEF  */\n    NONOPT = 303                   /* NONOPT  */\n  };\n  typedef enum yytokentype yytoken_kind_t;\n#endif\n/* Token kinds.  */\n#define YYEMPTY -2\n#define YYEOF 0\n#define YYerror 256\n#define YYUNDEF 257\n#define INVALID_CHARACTER 258\n#define IDENT 259\n#define FIELD 260\n#define BINDING 261\n#define LITERAL 262\n#define FORMAT 263\n#define REC 264\n#define SETMOD 265\n#define EQ 266\n#define NEQ 267\n#define DEFINEDOR 268\n#define AS 269\n#define DEF 270\n#define MODULE 271\n#define IMPORT 272\n#define INCLUDE 273\n#define IF 274\n#define THEN 275\n#define ELSE 276\n#define ELSE_IF 277\n#define REDUCE 278\n#define FOREACH 279\n#define END 280\n#define AND 281\n#define OR 282\n#define TRY 283\n#define CATCH 284\n#define LABEL 285\n#define BREAK 286\n#define LOC 287\n#define SETPIPE 288\n#define SETPLUS 289\n#define SETMINUS 290\n#define SETMULT 291\n#define SETDIV 292\n#define SETDEFINEDOR 293\n#define LESSEQ 294\n#define GREATEREQ 295\n#define ALTERNATION 296\n#define QQSTRING_START 297\n#define QQSTRING_TEXT 298\n#define QQSTRING_INTERP_START 299\n#define QQSTRING_INTERP_END 300\n#define QQSTRING_END 301\n#define FUNCDEF 302\n#define NONOPT 303\n\n/* Value type.  */\n#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED\nunion YYSTYPE\n{\n#line 32 \"src/parser.y\"\n\n  jv literal;\n  block blk;\n\n#line 256 \"src/parser.c\"\n\n};\ntypedef union YYSTYPE YYSTYPE;\n# define YYSTYPE_IS_TRIVIAL 1\n# define YYSTYPE_IS_DECLARED 1\n#endif\n\n/* Location type.  */\n#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED\ntypedef struct YYLTYPE YYLTYPE;\nstruct YYLTYPE\n{\n  int first_line;\n  int first_column;\n  int last_line;\n  int last_column;\n};\n# define YYLTYPE_IS_DECLARED 1\n# define YYLTYPE_IS_TRIVIAL 1\n#endif\n\n\n\n\nint yyparse (block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr);\n\n\n#endif /* !YY_YY_SRC_PARSER_H_INCLUDED  */\n/* Symbol kind.  */\nenum yysymbol_kind_t\n{\n  YYSYMBOL_YYEMPTY = -2,\n  YYSYMBOL_YYEOF = 0,                      /* \"end of file\"  */\n  YYSYMBOL_YYerror = 1,                    /* error  */\n  YYSYMBOL_YYUNDEF = 2,                    /* \"invalid token\"  */\n  YYSYMBOL_INVALID_CHARACTER = 3,          /* INVALID_CHARACTER  */\n  YYSYMBOL_IDENT = 4,                      /* IDENT  */\n  YYSYMBOL_FIELD = 5,                      /* FIELD  */\n  YYSYMBOL_BINDING = 6,                    /* BINDING  */\n  YYSYMBOL_LITERAL = 7,                    /* LITERAL  */\n  YYSYMBOL_FORMAT = 8,                     /* FORMAT  */\n  YYSYMBOL_REC = 9,                        /* \"..\"  */\n  YYSYMBOL_SETMOD = 10,                    /* \"%=\"  */\n  YYSYMBOL_EQ = 11,                        /* \"==\"  */\n  YYSYMBOL_NEQ = 12,                       /* \"!=\"  */\n  YYSYMBOL_DEFINEDOR = 13,                 /* \"//\"  */\n  YYSYMBOL_AS = 14,                        /* \"as\"  */\n  YYSYMBOL_DEF = 15,                       /* \"def\"  */\n  YYSYMBOL_MODULE = 16,                    /* \"module\"  */\n  YYSYMBOL_IMPORT = 17,                    /* \"import\"  */\n  YYSYMBOL_INCLUDE = 18,                   /* \"include\"  */\n  YYSYMBOL_IF = 19,                        /* \"if\"  */\n  YYSYMBOL_THEN = 20,                      /* \"then\"  */\n  YYSYMBOL_ELSE = 21,                      /* \"else\"  */\n  YYSYMBOL_ELSE_IF = 22,                   /* \"elif\"  */\n  YYSYMBOL_REDUCE = 23,                    /* \"reduce\"  */\n  YYSYMBOL_FOREACH = 24,                   /* \"foreach\"  */\n  YYSYMBOL_END = 25,                       /* \"end\"  */\n  YYSYMBOL_AND = 26,                       /* \"and\"  */\n  YYSYMBOL_OR = 27,                        /* \"or\"  */\n  YYSYMBOL_TRY = 28,                       /* \"try\"  */\n  YYSYMBOL_CATCH = 29,                     /* \"catch\"  */\n  YYSYMBOL_LABEL = 30,                     /* \"label\"  */\n  YYSYMBOL_BREAK = 31,                     /* \"break\"  */\n  YYSYMBOL_LOC = 32,                       /* \"$__loc__\"  */\n  YYSYMBOL_SETPIPE = 33,                   /* \"|=\"  */\n  YYSYMBOL_SETPLUS = 34,                   /* \"+=\"  */\n  YYSYMBOL_SETMINUS = 35,                  /* \"-=\"  */\n  YYSYMBOL_SETMULT = 36,                   /* \"*=\"  */\n  YYSYMBOL_SETDIV = 37,                    /* \"/=\"  */\n  YYSYMBOL_SETDEFINEDOR = 38,              /* \"//=\"  */\n  YYSYMBOL_LESSEQ = 39,                    /* \"<=\"  */\n  YYSYMBOL_GREATEREQ = 40,                 /* \">=\"  */\n  YYSYMBOL_ALTERNATION = 41,               /* \"?//\"  */\n  YYSYMBOL_QQSTRING_START = 42,            /* QQSTRING_START  */\n  YYSYMBOL_QQSTRING_TEXT = 43,             /* QQSTRING_TEXT  */\n  YYSYMBOL_QQSTRING_INTERP_START = 44,     /* QQSTRING_INTERP_START  */\n  YYSYMBOL_QQSTRING_INTERP_END = 45,       /* QQSTRING_INTERP_END  */\n  YYSYMBOL_QQSTRING_END = 46,              /* QQSTRING_END  */\n  YYSYMBOL_FUNCDEF = 47,                   /* FUNCDEF  */\n  YYSYMBOL_48_ = 48,                       /* '|'  */\n  YYSYMBOL_49_ = 49,                       /* ','  */\n  YYSYMBOL_50_ = 50,                       /* '='  */\n  YYSYMBOL_51_ = 51,                       /* '<'  */\n  YYSYMBOL_52_ = 52,                       /* '>'  */\n  YYSYMBOL_53_ = 53,                       /* '+'  */\n  YYSYMBOL_54_ = 54,                       /* '-'  */\n  YYSYMBOL_55_ = 55,                       /* '*'  */\n  YYSYMBOL_56_ = 56,                       /* '/'  */\n  YYSYMBOL_57_ = 57,                       /* '%'  */\n  YYSYMBOL_NONOPT = 58,                    /* NONOPT  */\n  YYSYMBOL_59_ = 59,                       /* '?'  */\n  YYSYMBOL_60_ = 60,                       /* '.'  */\n  YYSYMBOL_61_ = 61,                       /* '['  */\n  YYSYMBOL_62_ = 62,                       /* ';'  */\n  YYSYMBOL_63_ = 63,                       /* ':'  */\n  YYSYMBOL_64_ = 64,                       /* '('  */\n  YYSYMBOL_65_ = 65,                       /* ')'  */\n  YYSYMBOL_66_ = 66,                       /* ']'  */\n  YYSYMBOL_67_ = 67,                       /* '{'  */\n  YYSYMBOL_68_ = 68,                       /* '}'  */\n  YYSYMBOL_69_ = 69,                       /* '$'  */\n  YYSYMBOL_YYACCEPT = 70,                  /* $accept  */\n  YYSYMBOL_TopLevel = 71,                  /* TopLevel  */\n  YYSYMBOL_Module = 72,                    /* Module  */\n  YYSYMBOL_Imports = 73,                   /* Imports  */\n  YYSYMBOL_FuncDefs = 74,                  /* FuncDefs  */\n  YYSYMBOL_Query = 75,                     /* Query  */\n  YYSYMBOL_Expr = 76,                      /* Expr  */\n  YYSYMBOL_Import = 77,                    /* Import  */\n  YYSYMBOL_ImportWhat = 78,                /* ImportWhat  */\n  YYSYMBOL_ImportFrom = 79,                /* ImportFrom  */\n  YYSYMBOL_FuncDef = 80,                   /* FuncDef  */\n  YYSYMBOL_Params = 81,                    /* Params  */\n  YYSYMBOL_Param = 82,                     /* Param  */\n  YYSYMBOL_StringStart = 83,               /* StringStart  */\n  YYSYMBOL_String = 84,                    /* String  */\n  YYSYMBOL_QQString = 85,                  /* QQString  */\n  YYSYMBOL_ElseBody = 86,                  /* ElseBody  */\n  YYSYMBOL_Term = 87,                      /* Term  */\n  YYSYMBOL_Args = 88,                      /* Args  */\n  YYSYMBOL_Arg = 89,                       /* Arg  */\n  YYSYMBOL_RepPatterns = 90,               /* RepPatterns  */\n  YYSYMBOL_Patterns = 91,                  /* Patterns  */\n  YYSYMBOL_Pattern = 92,                   /* Pattern  */\n  YYSYMBOL_ArrayPats = 93,                 /* ArrayPats  */\n  YYSYMBOL_ObjPats = 94,                   /* ObjPats  */\n  YYSYMBOL_ObjPat = 95,                    /* ObjPat  */\n  YYSYMBOL_Keyword = 96,                   /* Keyword  */\n  YYSYMBOL_DictPairs = 97,                 /* DictPairs  */\n  YYSYMBOL_DictPair = 98,                  /* DictPair  */\n  YYSYMBOL_DictExpr = 99                   /* DictExpr  */\n};\ntypedef enum yysymbol_kind_t yysymbol_kind_t;\n\n\n/* Second part of user prologue.  */\n#line 127 \"src/parser.y\"\n\n#include \"lexer.h\"\nstruct lexer_param {\n  yyscan_t lexer;\n};\n#define FAIL(loc, msg)                                             \\\n  do {                                                             \\\n    location l = loc;                                              \\\n    yyerror(&l, answer, errors, locations, lexer_param_ptr, msg);  \\\n    /*YYERROR*/;                                                   \\\n  } while (0)\n\nvoid yyerror(YYLTYPE* loc, block* answer, int* errors,\n             struct locfile* locations, struct lexer_param* lexer_param_ptr, const char *s){\n  (*errors)++;\n  locfile_locate(locations, *loc, \"jq: error: %s\", s);\n}\n\nint yylex(YYSTYPE* yylval, YYLTYPE* yylloc, block* answer, int* errors,\n          struct locfile* locations, struct lexer_param* lexer_param_ptr) {\n  yyscan_t lexer = lexer_param_ptr->lexer;\n  int tok = jq_yylex(yylval, yylloc, lexer);\n  if ((tok == LITERAL || tok == QQSTRING_TEXT) && !jv_is_valid(yylval->literal)) {\n    jv msg = jv_invalid_get_msg(jv_copy(yylval->literal));\n    if (jv_get_kind(msg) == JV_KIND_STRING) {\n      FAIL(*yylloc, jv_string_value(msg));\n    } else {\n      FAIL(*yylloc, \"Invalid literal\");\n    }\n    jv_free(msg);\n    jv_free(yylval->literal);\n    yylval->literal = jv_null();\n  }\n  return tok;\n}\n\n/* Returns string message if the block is a constant that is not valid as an\n * object key. */\nstatic jv check_object_key(block k) {\n  if (block_is_const(k) && block_const_kind(k) != JV_KIND_STRING) {\n    char errbuf[30];\n    return jv_string_fmt(\"Cannot use %s (%s) as object key\",\n        jv_kind_name(block_const_kind(k)),\n        jv_dump_string_trunc(block_const(k), errbuf, sizeof(errbuf)));\n  }\n  return jv_invalid();\n}\n\nstatic block gen_index(block obj, block key) {\n  return BLOCK(gen_subexp(key), obj, gen_op_simple(INDEX));\n}\n\nstatic block gen_index_opt(block obj, block key) {\n  return BLOCK(gen_subexp(key), obj, gen_op_simple(INDEX_OPT));\n}\n\nstatic block gen_slice_index(block obj, block start, block end, opcode idx_op) {\n  block key = BLOCK(gen_subexp(gen_const(jv_object())),\n                    gen_subexp(gen_const(jv_string(\"start\"))),\n                    gen_subexp(start),\n                    gen_op_simple(INSERT),\n                    gen_subexp(gen_const(jv_string(\"end\"))),\n                    gen_subexp(end),\n                    gen_op_simple(INSERT));\n  return BLOCK(key, obj, gen_op_simple(idx_op));\n}\n\nstatic block constant_fold(block a, block b, int op) {\n  if (!block_is_single(a) || !block_is_const(a) ||\n      !block_is_single(b) || !block_is_const(b))\n    return gen_noop();\n\n  jv jv_a = block_const(a);\n  block_free(a);\n  jv jv_b = block_const(b);\n  block_free(b);\n\n  jv res = jv_invalid();\n  switch (op) {\n  case '+': res = binop_plus(jv_a, jv_b); break;\n  case '-': res = binop_minus(jv_a, jv_b); break;\n  case '*': res = binop_multiply(jv_a, jv_b); break;\n  case '/': res = binop_divide(jv_a, jv_b); break;\n  case '%': res = binop_mod(jv_a, jv_b); break;\n  case EQ: res = binop_equal(jv_a, jv_b); break;\n  case NEQ: res = binop_notequal(jv_a, jv_b); break;\n  case '<': res = binop_less(jv_a, jv_b); break;\n  case '>': res = binop_greater(jv_a, jv_b); break;\n  case LESSEQ: res = binop_lesseq(jv_a, jv_b); break;\n  case GREATEREQ: res = binop_greatereq(jv_a, jv_b); break;\n  }\n\n  if (jv_is_valid(res))\n    return gen_const(res);\n\n  return gen_error(jv_invalid_get_msg(res));\n}\n\nstatic block gen_binop(block a, block b, int op) {\n  block folded = constant_fold(a, b, op);\n  if (!block_is_noop(folded))\n    return folded;\n\n  const char* funcname = 0;\n  switch (op) {\n  case '+': funcname = \"_plus\"; break;\n  case '-': funcname = \"_minus\"; break;\n  case '*': funcname = \"_multiply\"; break;\n  case '/': funcname = \"_divide\"; break;\n  case '%': funcname = \"_mod\"; break;\n  case EQ: funcname = \"_equal\"; break;\n  case NEQ: funcname = \"_notequal\"; break;\n  case '<': funcname = \"_less\"; break;\n  case '>': funcname = \"_greater\"; break;\n  case LESSEQ: funcname = \"_lesseq\"; break;\n  case GREATEREQ: funcname = \"_greatereq\"; break;\n  }\n  assert(funcname);\n\n  return gen_call(funcname, BLOCK(gen_lambda(a), gen_lambda(b)));\n}\n\nstatic block gen_format(block a, jv fmt) {\n  return BLOCK(a, gen_call(\"format\", gen_lambda(gen_const(fmt))));\n}\n\nstatic block gen_definedor_assign(block object, block val) {\n  block tmp = gen_op_var_fresh(STOREV, \"tmp\");\n  return BLOCK(gen_op_simple(DUP),\n               val, tmp,\n               gen_call(\"_modify\", BLOCK(gen_lambda(object),\n                                         gen_lambda(gen_definedor(gen_noop(),\n                                                                  gen_op_bound(LOADV, tmp))))));\n}\n\nstatic block gen_update(block object, block val, int optype) {\n  block tmp = gen_op_var_fresh(STOREV, \"tmp\");\n  return BLOCK(gen_op_simple(DUP),\n               val,\n               tmp,\n               gen_call(\"_modify\", BLOCK(gen_lambda(object),\n                                         gen_lambda(gen_binop(gen_noop(),\n                                                              gen_op_bound(LOADV, tmp),\n                                                              optype)))));\n}\n\nstatic block gen_loc_object(location *loc, struct locfile *locations) {\n  return gen_const(JV_OBJECT(jv_string(\"file\"), jv_copy(locations->fname),\n                             jv_string(\"line\"), jv_number(locfile_get_line(locations, loc->start) + 1)));\n}\n\n\n#line 547 \"src/parser.c\"\n\n\n#ifdef short\n# undef short\n#endif\n\n/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure\n   <limits.h> and (if available) <stdint.h> are included\n   so that the code can choose integer types of a good width.  */\n\n#ifndef __PTRDIFF_MAX__\n# include <limits.h> /* INFRINGES ON USER NAME SPACE */\n# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__\n#  include <stdint.h> /* INFRINGES ON USER NAME SPACE */\n#  define YY_STDINT_H\n# endif\n#endif\n\n/* Narrow types that promote to a signed type and that can represent a\n   signed or unsigned integer of at least N bits.  In tables they can\n   save space and decrease cache pressure.  Promoting to a signed type\n   helps avoid bugs in integer arithmetic.  */\n\n#ifdef __INT_LEAST8_MAX__\ntypedef __INT_LEAST8_TYPE__ yytype_int8;\n#elif defined YY_STDINT_H\ntypedef int_least8_t yytype_int8;\n#else\ntypedef signed char yytype_int8;\n#endif\n\n#ifdef __INT_LEAST16_MAX__\ntypedef __INT_LEAST16_TYPE__ yytype_int16;\n#elif defined YY_STDINT_H\ntypedef int_least16_t yytype_int16;\n#else\ntypedef short yytype_int16;\n#endif\n\n/* Work around bug in HP-UX 11.23, which defines these macros\n   incorrectly for preprocessor constants.  This workaround can likely\n   be removed in 2023, as HPE has promised support for HP-UX 11.23\n   (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of\n   <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>.  */\n#ifdef __hpux\n# undef UINT_LEAST8_MAX\n# undef UINT_LEAST16_MAX\n# define UINT_LEAST8_MAX 255\n# define UINT_LEAST16_MAX 65535\n#endif\n\n#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__\ntypedef __UINT_LEAST8_TYPE__ yytype_uint8;\n#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \\\n       && UINT_LEAST8_MAX <= INT_MAX)\ntypedef uint_least8_t yytype_uint8;\n#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX\ntypedef unsigned char yytype_uint8;\n#else\ntypedef short yytype_uint8;\n#endif\n\n#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__\ntypedef __UINT_LEAST16_TYPE__ yytype_uint16;\n#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \\\n       && UINT_LEAST16_MAX <= INT_MAX)\ntypedef uint_least16_t yytype_uint16;\n#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX\ntypedef unsigned short yytype_uint16;\n#else\ntypedef int yytype_uint16;\n#endif\n\n#ifndef YYPTRDIFF_T\n# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__\n#  define YYPTRDIFF_T __PTRDIFF_TYPE__\n#  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__\n# elif defined PTRDIFF_MAX\n#  ifndef ptrdiff_t\n#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */\n#  endif\n#  define YYPTRDIFF_T ptrdiff_t\n#  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX\n# else\n#  define YYPTRDIFF_T long\n#  define YYPTRDIFF_MAXIMUM LONG_MAX\n# endif\n#endif\n\n#ifndef YYSIZE_T\n# ifdef __SIZE_TYPE__\n#  define YYSIZE_T __SIZE_TYPE__\n# elif defined size_t\n#  define YYSIZE_T size_t\n# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__\n#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */\n#  define YYSIZE_T size_t\n# else\n#  define YYSIZE_T unsigned\n# endif\n#endif\n\n#define YYSIZE_MAXIMUM                                  \\\n  YY_CAST (YYPTRDIFF_T,                                 \\\n           (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \\\n            ? YYPTRDIFF_MAXIMUM                         \\\n            : YY_CAST (YYSIZE_T, -1)))\n\n#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))\n\n\n/* Stored state numbers (used for stacks). */\ntypedef yytype_int16 yy_state_t;\n\n/* State numbers in computations.  */\ntypedef int yy_state_fast_t;\n\n#ifndef YY_\n# if defined YYENABLE_NLS && YYENABLE_NLS\n#  if ENABLE_NLS\n#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */\n#   define YY_(Msgid) dgettext (\"bison-runtime\", Msgid)\n#  endif\n# endif\n# ifndef YY_\n#  define YY_(Msgid) Msgid\n# endif\n#endif\n\n\n#ifndef YY_ATTRIBUTE_PURE\n# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)\n#  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))\n# else\n#  define YY_ATTRIBUTE_PURE\n# endif\n#endif\n\n#ifndef YY_ATTRIBUTE_UNUSED\n# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)\n#  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))\n# else\n#  define YY_ATTRIBUTE_UNUSED\n# endif\n#endif\n\n/* Suppress unused-variable warnings by \"using\" E.  */\n#if ! defined lint || defined __GNUC__\n# define YY_USE(E) ((void) (E))\n#else\n# define YY_USE(E) /* empty */\n#endif\n\n/* Suppress an incorrect diagnostic about yylval being uninitialized.  */\n#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__\n# if __GNUC__ * 100 + __GNUC_MINOR__ < 407\n#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \\\n    _Pragma (\"GCC diagnostic push\")                                     \\\n    _Pragma (\"GCC diagnostic ignored \\\"-Wuninitialized\\\"\")\n# else\n#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \\\n    _Pragma (\"GCC diagnostic push\")                                     \\\n    _Pragma (\"GCC diagnostic ignored \\\"-Wuninitialized\\\"\")              \\\n    _Pragma (\"GCC diagnostic ignored \\\"-Wmaybe-uninitialized\\\"\")\n# endif\n# define YY_IGNORE_MAYBE_UNINITIALIZED_END      \\\n    _Pragma (\"GCC diagnostic pop\")\n#else\n# define YY_INITIAL_VALUE(Value) Value\n#endif\n#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN\n# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN\n# define YY_IGNORE_MAYBE_UNINITIALIZED_END\n#endif\n#ifndef YY_INITIAL_VALUE\n# define YY_INITIAL_VALUE(Value) /* Nothing. */\n#endif\n\n#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__\n# define YY_IGNORE_USELESS_CAST_BEGIN                          \\\n    _Pragma (\"GCC diagnostic push\")                            \\\n    _Pragma (\"GCC diagnostic ignored \\\"-Wuseless-cast\\\"\")\n# define YY_IGNORE_USELESS_CAST_END            \\\n    _Pragma (\"GCC diagnostic pop\")\n#endif\n#ifndef YY_IGNORE_USELESS_CAST_BEGIN\n# define YY_IGNORE_USELESS_CAST_BEGIN\n# define YY_IGNORE_USELESS_CAST_END\n#endif\n\n\n#define YY_ASSERT(E) ((void) (0 && (E)))\n\n#if 1\n\n/* The parser invokes alloca or malloc; define the necessary symbols.  */\n\n# ifdef YYSTACK_USE_ALLOCA\n#  if YYSTACK_USE_ALLOCA\n#   ifdef __GNUC__\n#    define YYSTACK_ALLOC __builtin_alloca\n#   elif defined __BUILTIN_VA_ARG_INCR\n#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */\n#   elif defined _AIX\n#    define YYSTACK_ALLOC __alloca\n#   elif defined _MSC_VER\n#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */\n#    define alloca _alloca\n#   else\n#    define YYSTACK_ALLOC alloca\n#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS\n#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */\n      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */\n#     ifndef EXIT_SUCCESS\n#      define EXIT_SUCCESS 0\n#     endif\n#    endif\n#   endif\n#  endif\n# endif\n\n# ifdef YYSTACK_ALLOC\n   /* Pacify GCC's 'empty if-body' warning.  */\n#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)\n#  ifndef YYSTACK_ALLOC_MAXIMUM\n    /* The OS might guarantee only one guard page at the bottom of the stack,\n       and a page size can be as small as 4096 bytes.  So we cannot safely\n       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number\n       to allow for a few compiler-allocated temporary stack slots.  */\n#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */\n#  endif\n# else\n#  define YYSTACK_ALLOC YYMALLOC\n#  define YYSTACK_FREE YYFREE\n#  ifndef YYSTACK_ALLOC_MAXIMUM\n#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM\n#  endif\n#  if (defined __cplusplus && ! defined EXIT_SUCCESS \\\n       && ! ((defined YYMALLOC || defined malloc) \\\n             && (defined YYFREE || defined free)))\n#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */\n#   ifndef EXIT_SUCCESS\n#    define EXIT_SUCCESS 0\n#   endif\n#  endif\n#  ifndef YYMALLOC\n#   define YYMALLOC malloc\n#   if ! defined malloc && ! defined EXIT_SUCCESS\nvoid *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */\n#   endif\n#  endif\n#  ifndef YYFREE\n#   define YYFREE free\n#   if ! defined free && ! defined EXIT_SUCCESS\nvoid free (void *); /* INFRINGES ON USER NAME SPACE */\n#   endif\n#  endif\n# endif\n#endif /* 1 */\n\n#if (! defined yyoverflow \\\n     && (! defined __cplusplus \\\n         || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \\\n             && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))\n\n/* A type that is properly aligned for any stack member.  */\nunion yyalloc\n{\n  yy_state_t yyss_alloc;\n  YYSTYPE yyvs_alloc;\n  YYLTYPE yyls_alloc;\n};\n\n/* The size of the maximum gap between one aligned stack and the next.  */\n# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)\n\n/* The size of an array large to enough to hold all stacks, each with\n   N elements.  */\n# define YYSTACK_BYTES(N) \\\n     ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \\\n             + YYSIZEOF (YYLTYPE)) \\\n      + 2 * YYSTACK_GAP_MAXIMUM)\n\n# define YYCOPY_NEEDED 1\n\n/* Relocate STACK from its old location to the new one.  The\n   local variables YYSIZE and YYSTACKSIZE give the old and new number of\n   elements in the stack, and YYPTR gives the new location of the\n   stack.  Advance YYPTR to a properly aligned location for the next\n   stack.  */\n# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \\\n    do                                                                  \\\n      {                                                                 \\\n        YYPTRDIFF_T yynewbytes;                                         \\\n        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \\\n        Stack = &yyptr->Stack_alloc;                                    \\\n        yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \\\n        yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \\\n      }                                                                 \\\n    while (0)\n\n#endif\n\n#if defined YYCOPY_NEEDED && YYCOPY_NEEDED\n/* Copy COUNT objects from SRC to DST.  The source and destination do\n   not overlap.  */\n# ifndef YYCOPY\n#  if defined __GNUC__ && 1 < __GNUC__\n#   define YYCOPY(Dst, Src, Count) \\\n      __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))\n#  else\n#   define YYCOPY(Dst, Src, Count)              \\\n      do                                        \\\n        {                                       \\\n          YYPTRDIFF_T yyi;                      \\\n          for (yyi = 0; yyi < (Count); yyi++)   \\\n            (Dst)[yyi] = (Src)[yyi];            \\\n        }                                       \\\n      while (0)\n#  endif\n# endif\n#endif /* !YYCOPY_NEEDED */\n\n/* YYFINAL -- State number of the termination state.  */\n#define YYFINAL  31\n/* YYLAST -- Last index in YYTABLE.  */\n#define YYLAST   1226\n\n/* YYNTOKENS -- Number of terminals.  */\n#define YYNTOKENS  70\n/* YYNNTS -- Number of nonterminals.  */\n#define YYNNTS  30\n/* YYNRULES -- Number of rules.  */\n#define YYNRULES  168\n/* YYNSTATES -- Number of states.  */\n#define YYNSTATES  312\n\n/* YYMAXUTOK -- Last valid token kind.  */\n#define YYMAXUTOK   303\n\n\n/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM\n   as returned by yylex, with out-of-bounds checking.  */\n#define YYTRANSLATE(YYX)                                \\\n  (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \\\n   ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \\\n   : YYSYMBOL_YYUNDEF)\n\n/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM\n   as returned by yylex.  */\nstatic const yytype_int8 yytranslate[] =\n{\n       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,    69,    57,     2,     2,\n      64,    65,    55,    53,    49,    54,    60,    56,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,    63,    62,\n      51,    50,    52,    59,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,    61,     2,    66,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,    67,    48,    68,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,\n       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,\n       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,\n      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,\n      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,\n      35,    36,    37,    38,    39,    40,    41,    42,    43,    44,\n      45,    46,    47,    58\n};\n\n#if YYDEBUG\n/* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */\nstatic const yytype_int16 yyrline[] =\n{\n       0,   282,   282,   285,   290,   293,   308,   311,   316,   319,\n     325,   328,   331,   337,   340,   343,   349,   352,   355,   358,\n     361,   364,   367,   370,   373,   376,   379,   382,   385,   388,\n     391,   394,   397,   400,   403,   406,   409,   412,   415,   421,\n     424,   441,   450,   457,   465,   476,   481,   487,   490,   495,\n     499,   506,   509,   515,   522,   525,   528,   534,   537,   540,\n     546,   549,   552,   560,   564,   567,   570,   573,   576,   579,\n     582,   585,   588,   592,   598,   601,   604,   607,   610,   613,\n     616,   619,   622,   625,   628,   631,   634,   637,   640,   643,\n     646,   649,   652,   655,   658,   661,   664,   671,   674,   677,\n     680,   683,   687,   690,   694,   712,   716,   720,   723,   735,\n     740,   741,   742,   743,   746,   749,   754,   759,   762,   767,\n     770,   775,   779,   782,   787,   790,   795,   798,   803,   806,\n     809,   812,   815,   818,   826,   832,   835,   838,   841,   844,\n     847,   850,   853,   856,   859,   862,   865,   868,   871,   874,\n     877,   880,   883,   889,   892,   895,   900,   903,   906,   909,\n     913,   918,   922,   926,   930,   934,   942,   948,   951\n};\n#endif\n\n/** Accessing symbol of state STATE.  */\n#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])\n\n#if 1\n/* The user-facing name of the symbol whose (internal) number is\n   YYSYMBOL.  No bounds checking.  */\nstatic const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;\n\n/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.\n   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */\nstatic const char *const yytname[] =\n{\n  \"\\\"end of file\\\"\", \"error\", \"\\\"invalid token\\\"\", \"INVALID_CHARACTER\",\n  \"IDENT\", \"FIELD\", \"BINDING\", \"LITERAL\", \"FORMAT\", \"\\\"..\\\"\", \"\\\"%=\\\"\",\n  \"\\\"==\\\"\", \"\\\"!=\\\"\", \"\\\"//\\\"\", \"\\\"as\\\"\", \"\\\"def\\\"\", \"\\\"module\\\"\",\n  \"\\\"import\\\"\", \"\\\"include\\\"\", \"\\\"if\\\"\", \"\\\"then\\\"\", \"\\\"else\\\"\",\n  \"\\\"elif\\\"\", \"\\\"reduce\\\"\", \"\\\"foreach\\\"\", \"\\\"end\\\"\", \"\\\"and\\\"\", \"\\\"or\\\"\",\n  \"\\\"try\\\"\", \"\\\"catch\\\"\", \"\\\"label\\\"\", \"\\\"break\\\"\", \"\\\"$__loc__\\\"\",\n  \"\\\"|=\\\"\", \"\\\"+=\\\"\", \"\\\"-=\\\"\", \"\\\"*=\\\"\", \"\\\"/=\\\"\", \"\\\"//=\\\"\", \"\\\"<=\\\"\",\n  \"\\\">=\\\"\", \"\\\"?//\\\"\", \"QQSTRING_START\", \"QQSTRING_TEXT\",\n  \"QQSTRING_INTERP_START\", \"QQSTRING_INTERP_END\", \"QQSTRING_END\",\n  \"FUNCDEF\", \"'|'\", \"','\", \"'='\", \"'<'\", \"'>'\", \"'+'\", \"'-'\", \"'*'\", \"'/'\",\n  \"'%'\", \"NONOPT\", \"'?'\", \"'.'\", \"'['\", \"';'\", \"':'\", \"'('\", \"')'\", \"']'\",\n  \"'{'\", \"'}'\", \"'$'\", \"$accept\", \"TopLevel\", \"Module\", \"Imports\",\n  \"FuncDefs\", \"Query\", \"Expr\", \"Import\", \"ImportWhat\", \"ImportFrom\",\n  \"FuncDef\", \"Params\", \"Param\", \"StringStart\", \"String\", \"QQString\",\n  \"ElseBody\", \"Term\", \"Args\", \"Arg\", \"RepPatterns\", \"Patterns\", \"Pattern\",\n  \"ArrayPats\", \"ObjPats\", \"ObjPat\", \"Keyword\", \"DictPairs\", \"DictPair\",\n  \"DictExpr\", YY_NULLPTR\n};\n\nstatic const char *\nyysymbol_name (yysymbol_kind_t yysymbol)\n{\n  return yytname[yysymbol];\n}\n#endif\n\n#define YYPACT_NINF (-146)\n\n#define yypact_value_is_default(Yyn) \\\n  ((Yyn) == YYPACT_NINF)\n\n#define YYTABLE_NINF (-154)\n\n#define yytable_value_is_error(Yyn) \\\n  ((Yyn) == YYTABLE_NINF)\n\n/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing\n   STATE-NUM.  */\nstatic const yytype_int16 yypact[] =\n{\n      31,   890,    44,    35,    11,     9,  -146,  -146,    38,  -146,\n      85,   890,   956,   956,   956,   112,    26,  -146,  -146,   956,\n     279,   345,   412,   608,    59,    25,  1040,   890,  -146,  -146,\n      -2,  -146,     4,     4,   890,    35,   692,   890,  -146,  -146,\n      20,   -18,  1073,  1105,   131,    86,  -146,  -146,    -2,  -146,\n     164,    38,   108,   107,  -146,    22,   104,     0,   -34,   121,\n     124,  -146,  -146,  -146,  -146,  -146,  -146,  -146,  -146,  -146,\n    -146,  -146,  -146,  -146,  -146,  -146,  -146,  -146,  -146,  -146,\n     890,   135,   137,   134,   126,   141,   890,   890,  -146,   956,\n     956,   956,   956,    -5,   956,   956,   956,   956,   956,   956,\n     956,   956,   956,   956,   956,   956,   956,   956,   956,   956,\n     956,   956,    84,   177,   147,  -146,     3,   173,   199,  -146,\n    -146,  -146,    84,   890,  -146,  -146,   114,    84,    77,  -146,\n     890,    13,   479,    -5,    -5,   546,   890,  -146,  -146,  -146,\n    -146,  -146,  -146,   956,  -146,   956,   956,    78,   956,   956,\n    -146,   663,   220,    84,  -146,  1169,   505,   505,  1137,  -146,\n      -5,  1018,   187,   166,   188,   606,   205,  1169,  1169,  1169,\n    1169,  1169,  1169,   505,   505,  1169,   505,   505,   208,   208,\n    -146,  -146,  -146,  -146,   890,  -146,  -146,   758,   176,   175,\n     890,   184,     6,    57,  -146,  -146,   890,  -146,   123,  -146,\n    -146,    83,  -146,  -146,    18,   185,   189,  -146,  -146,    84,\n    1137,   200,   200,   200,   203,   200,   200,   206,  -146,  -146,\n    -146,   -42,   207,   209,   210,   890,   212,   -45,  -146,   213,\n      -5,   890,    33,   193,    28,  -146,  -146,    71,  -146,   824,\n     218,  -146,  -146,  -146,  -146,    13,   215,   890,   890,  -146,\n    -146,   890,   890,   956,   956,    -5,  -146,    -5,    -5,    -5,\n     103,    -5,  1018,  -146,    -5,   227,    84,  -146,  -146,   222,\n     223,   226,    74,  -146,  -146,   890,    -7,     2,   160,   163,\n     200,   200,  -146,  -146,  -146,  -146,   225,  -146,  -146,  -146,\n    -146,  -146,  -146,   235,   170,  -146,   890,   890,   890,    -5,\n    -146,  -146,    18,   105,    76,  -146,  -146,  -146,   890,  -146,\n     142,  -146\n};\n\n/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.\n   Performed when YYTABLE does not specify something else to do.  Zero\n   means the default is an error.  */\nstatic const yytype_uint8 yydefact[] =\n{\n       4,     0,     0,     6,   108,    69,   106,    89,    91,    61,\n       0,     0,     0,     0,     0,     0,     0,   107,    52,     0,\n       0,     0,     0,     0,     0,     0,    15,     0,    54,    90,\n      38,     1,     0,     0,     8,     6,     0,     0,    65,    51,\n       0,     0,     0,     0,   104,     0,    63,    62,    92,    72,\n       0,     0,    71,     0,    95,     0,     0,     0,     0,   162,\n     161,   135,   136,   137,   138,   139,   140,   141,   142,   143,\n     144,   145,   146,   147,   148,   149,   150,   151,   152,   163,\n       0,   159,   164,     0,   154,     0,     0,     0,     5,     0,\n       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,\n       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,\n       0,     0,    10,     0,    68,    88,     0,     0,     0,    44,\n      43,     3,     2,     8,     7,    39,     0,   116,     0,   114,\n       0,     0,     0,     0,     0,     0,     0,    73,    67,   111,\n      94,   110,    93,     0,   113,     0,     0,     0,     0,     0,\n      96,     0,     0,    13,    14,    31,    32,    33,    16,   121,\n       0,     0,     0,     0,   120,    19,    18,    21,    23,    25,\n      27,    30,    20,    36,    37,    17,    34,    35,    22,    24,\n      26,    28,    29,    55,     0,    53,    64,     0,    70,     0,\n       0,    79,     0,     0,     9,    40,     0,   109,     0,    50,\n      49,     0,    47,   101,     0,     0,     0,   103,   102,    12,\n     168,   166,   156,   160,     0,   158,   157,     0,   155,   105,\n     124,     0,     0,     0,   128,     0,     0,     0,   126,     0,\n       0,     0,     0,    81,     0,    66,   112,     0,    78,     0,\n      75,    42,    41,   115,    45,     0,     0,     0,     0,    59,\n     100,     0,     0,     0,     0,     0,   122,     0,     0,     0,\n       0,     0,     0,   123,     0,   119,    11,    56,    80,    77,\n      87,    86,     0,    74,    48,     0,     0,     0,     0,     0,\n     167,   165,   125,   134,   130,   129,     0,   132,   127,   131,\n      76,    84,    83,    85,     0,    58,     0,     0,     0,     0,\n      82,    46,     0,     0,     0,   133,    57,    97,     0,    99,\n       0,    98\n};\n\n/* YYPGOTO[NTERM-NUM].  */\nstatic const yytype_int16 yypgoto[] =\n{\n    -146,  -146,  -146,   236,   179,    -1,     1,  -146,  -146,   253,\n      -8,  -146,    53,  -146,     5,  -146,     7,   284,  -146,   115,\n    -146,    60,  -100,  -146,  -146,    48,  -145,   169,  -146,  -140\n};\n\n/* YYDEFGOTO[NTERM-NUM].  */\nstatic const yytype_uint8 yydefgoto[] =\n{\n       0,     2,     3,    34,   121,   112,    26,    35,    36,   118,\n      27,   201,   202,    28,    29,   113,   250,    30,   128,   129,\n     162,   163,   164,   221,   227,   228,    82,    83,    84,   211\n};\n\n/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If\n   positive, shift that token.  If negative, reduce the rule whose\n   number is the opposite.  If YYTABLE_NINF, syntax error.  */\nstatic const yytype_int16 yytable[] =\n{\n      25,   159,   132,   114,   262,   212,   213,   255,   215,   216,\n      41,    51,    51,    42,    43,    44,   229,   199,   295,   200,\n      55,    57,   296,   263,   256,    52,   123,    46,    81,   143,\n      86,    87,    47,   122,   144,   126,   127,   119,   119,   247,\n     248,    86,    87,   249,    31,    18,    18,     1,    86,    87,\n      86,    87,    32,    33,    86,    87,   160,   115,   116,   117,\n     220,   241,   161,   242,   187,   142,    86,    87,    38,   239,\n      86,    87,   240,    86,    87,    37,    86,    87,   267,   147,\n      39,    86,    87,   130,   131,   153,   154,    88,   140,    40,\n     155,   156,   157,   158,   269,   165,   166,   167,   168,   169,\n     170,   171,   172,   173,   174,   175,   176,   177,   178,   179,\n     180,   181,   182,   280,   281,   123,   192,   229,    45,    86,\n      87,   188,    86,    87,    86,    87,    86,    87,    85,   198,\n     265,   204,    86,    87,   136,   209,   208,   270,   308,   196,\n     293,   309,   197,   214,   210,   245,   210,   210,   246,   210,\n     210,    86,    87,    86,    87,   282,    81,   283,   284,   285,\n     135,   287,    86,    87,   289,   137,   226,   138,   286,   141,\n     307,    86,    87,   139,   189,   151,   195,     4,     5,     6,\n       7,     8,     9,   232,   145,   244,   234,   146,    10,   237,\n      86,    87,    11,   205,   206,   127,    12,    13,   148,   305,\n     149,    14,   150,    15,    16,    17,   186,   311,    86,    87,\n     152,    86,    87,   193,   231,    18,    90,    91,    86,    87,\n     183,   184,   297,   185,   260,   298,   219,    19,   230,  -118,\n     266,    94,   301,    20,    21,   235,   190,    22,   272,   191,\n      23,   236,    24,   238,   102,   103,   276,   277,   253,   251,\n     278,   279,   268,   252,   210,   210,   105,   106,   107,   108,\n     109,   110,   111,   109,   110,   111,   254,   226,  -117,   143,\n     257,   124,   258,   259,   294,   261,   264,   273,   275,   -60,\n      49,   290,   291,    50,   -60,   292,   120,    51,   299,   -60,\n     -60,   -60,   -60,   -60,   300,   302,   303,   304,   274,   -60,\n     -60,   -60,   194,    48,   -60,   -60,   -60,   310,   -60,   306,\n     288,   243,   -60,   -60,   -60,   -60,   -60,   -60,   -60,   -60,\n     218,    18,     0,     0,   -60,     0,     0,   -60,   -60,   -60,\n     -60,   -60,   -60,   -60,   -60,   -60,   -60,     0,   -60,   -60,\n     -60,   -60,   -60,     0,   -60,   -60,    53,   -60,     0,     4,\n       5,     6,     7,     8,     9,     0,     0,     0,     0,     0,\n      10,     0,     0,     0,    11,     0,     0,     0,    12,    13,\n       0,     0,     0,    14,     0,    15,    16,    17,     0,     0,\n       0,     0,     0,     0,     0,     0,     0,    18,     0,     0,\n       0,     0,     0,     0,     0,     0,     0,     0,     0,    19,\n       0,     0,     0,     0,     0,    20,    21,     0,     0,    22,\n       0,    54,    23,    56,    24,     0,     4,     5,     6,     7,\n       8,     9,     0,     0,     0,     0,     0,    10,     0,     0,\n       0,    11,     0,     0,     0,    12,    13,     0,     0,     0,\n      14,     0,    15,    16,    17,     0,     0,     0,     0,     0,\n       0,     0,     0,     0,    18,     0,     0,     0,     0,     0,\n       0,     0,     0,     0,     0,     0,    19,     0,     0,     0,\n       0,     0,    20,    21,     0,     0,    22,     0,     0,    23,\n     203,    24,     0,     4,     5,     6,     7,     8,     9,     0,\n       0,     0,     0,     0,    10,     0,     0,     0,    11,     0,\n       0,     0,    12,    13,     0,     0,     0,    14,     0,    15,\n      16,    17,     0,     0,     0,     0,  -154,  -154,     0,     0,\n       0,    18,     0,     0,     0,     0,     0,     0,     0,     0,\n       0,     0,     0,    19,     0,     0,     0,     0,     0,    20,\n      21,     0,     0,    22,  -154,  -154,    23,   207,    24,     0,\n       4,     5,     6,     7,     8,     9,  -154,  -154,   107,   108,\n     109,   110,   111,     0,     0,    11,     0,     0,     0,    12,\n      13,     0,     0,     0,    14,     0,     0,    16,    17,     0,\n       0,     0,     0,     0,     0,     0,     0,     0,    18,     0,\n       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,\n      19,     0,     0,     0,     0,     0,    20,    21,     0,    58,\n      22,     0,    59,    23,    60,    24,    51,    90,    91,     0,\n       0,     0,    61,    62,    63,    64,    65,    66,    67,    68,\n      69,    70,    71,    72,    73,    74,    75,    76,    77,    78,\n      79,     0,     0,     0,     0,   102,   103,     0,     0,     0,\n      18,     0,     0,     0,     0,     0,     0,   105,   106,   107,\n     108,   109,   110,   111,   217,     0,     0,    59,     0,    60,\n       0,    51,    80,     0,     0,     0,  -153,    61,    62,    63,\n      64,    65,    66,    67,    68,    69,    70,    71,    72,    73,\n      74,    75,    76,    77,    78,    79,     4,     5,     6,     7,\n       8,     9,     0,     0,     0,    18,     0,    10,     0,     0,\n       0,    11,     0,     0,     0,    12,    13,     0,     0,     0,\n      14,     0,    15,    16,    17,     0,     0,    80,     0,     0,\n       0,  -153,     0,     0,    18,     0,     0,     0,     0,     0,\n       0,     0,     0,     0,     0,     0,    19,     0,     0,     0,\n       0,     0,    20,    21,   125,     0,    22,     0,     0,    23,\n       0,    24,     4,     5,     6,     7,     8,     9,     0,     0,\n       0,     0,     0,    10,     0,     0,     0,    11,     0,     0,\n       0,    12,    13,     0,     0,     0,    14,     0,    15,    16,\n      17,     0,     0,     0,     0,     0,     0,     0,     0,     0,\n      18,     0,     0,     0,     0,     0,     0,     0,     0,     0,\n       0,     0,    19,     0,     0,     0,     0,     0,    20,    21,\n       0,     0,    22,     0,   233,    23,     0,    24,     4,     5,\n       6,     7,     8,     9,     0,     0,     0,     0,     0,    10,\n       0,     0,     0,    11,     0,     0,     0,    12,    13,     0,\n       0,     0,    14,     0,    15,    16,    17,     0,     0,     0,\n       0,     0,     0,     0,     0,     0,    18,     0,     0,     0,\n       0,     0,     0,     0,     0,     0,     0,     0,    19,     0,\n       0,     0,     0,     0,    20,    21,     0,     0,    22,     0,\n     271,    23,     0,    24,     4,     5,     6,     7,     8,     9,\n       0,     0,     0,     0,     0,    10,     0,     0,     0,    11,\n       0,     0,     0,    12,    13,     0,     0,     0,    14,     0,\n      15,    16,    17,     0,     0,     0,     0,     0,     0,     0,\n       0,     0,    18,     0,     0,     0,     0,     0,     0,     0,\n       0,     0,     0,     0,    19,     0,     0,     0,     0,     0,\n      20,    21,     0,     0,    22,     0,     0,    23,     0,    24,\n       4,     5,     6,     7,     8,     9,     0,     0,     0,     0,\n       0,     0,     0,     0,     0,    11,     0,     0,     0,    12,\n      13,     0,     0,     0,    14,     0,     0,    16,    17,     0,\n       0,     0,     0,     0,     0,     0,     0,     0,    18,     0,\n       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,\n      19,     0,     0,     0,     0,     0,    20,    21,     0,   222,\n      22,     0,   223,    23,   224,    24,    51,     0,     0,     0,\n       0,     0,    61,    62,    63,    64,    65,    66,    67,    68,\n      69,    70,    71,    72,    73,    74,    75,    76,    77,    78,\n      89,    90,    91,    92,    93,     0,     0,     0,     0,     0,\n      18,     0,     0,     0,     0,     0,    94,    95,     0,     0,\n       0,     0,     0,    96,    97,    98,    99,   100,   101,   102,\n     103,     0,   225,    89,    90,    91,    92,   133,     0,     0,\n     104,   105,   106,   107,   108,   109,   110,   111,     0,    94,\n      95,     0,     0,     0,     0,     0,    96,    97,    98,    99,\n     100,   101,   102,   103,     0,    89,    90,    91,    92,   134,\n       0,     0,     0,   104,   105,   106,   107,   108,   109,   110,\n     111,    94,    95,     0,     0,     0,     0,     0,    96,    97,\n      98,    99,   100,   101,   102,   103,     0,    89,    90,    91,\n      92,     0,     0,     0,     0,   104,   105,   106,   107,   108,\n     109,   110,   111,    94,    95,     0,     0,     0,     0,     0,\n      96,    97,    98,    99,   100,   101,   102,   103,     0,  -154,\n      90,    91,     0,     0,     0,     0,     0,   104,   105,   106,\n     107,   108,   109,   110,   111,    94,    95,     0,     0,     0,\n       0,     0,  -154,  -154,  -154,  -154,  -154,  -154,   102,   103,\n       0,     0,     0,     0,     0,     0,     0,     0,     0,  -154,\n     105,   106,   107,   108,   109,   110,   111\n};\n\nstatic const yytype_int16 yycheck[] =\n{\n       1,     6,    20,     5,    49,   145,   146,    49,   148,   149,\n      11,     8,     8,    12,    13,    14,   161,     4,    25,     6,\n      21,    22,    20,    68,    66,    20,    34,     1,    23,    63,\n      48,    49,     6,    34,    68,    36,    37,    32,    33,    21,\n      22,    48,    49,    25,     0,    42,    42,    16,    48,    49,\n      48,    49,    17,    18,    48,    49,    61,    59,    60,    61,\n     160,     4,    67,     6,    61,    65,    48,    49,    59,    63,\n      48,    49,    66,    48,    49,    64,    48,    49,    45,    80,\n      42,    48,    49,    63,    64,    86,    87,    62,    66,     4,\n      89,    90,    91,    92,    66,    94,    95,    96,    97,    98,\n      99,   100,   101,   102,   103,   104,   105,   106,   107,   108,\n     109,   110,   111,   253,   254,   123,   117,   262,     6,    48,\n      49,   116,    48,    49,    48,    49,    48,    49,    69,   130,\n     230,   132,    48,    49,    48,   136,   135,    66,    62,    62,\n      66,    65,    65,    65,   143,    62,   145,   146,    65,   148,\n     149,    48,    49,    48,    49,   255,   151,   257,   258,   259,\n      29,   261,    48,    49,   264,     1,   161,    59,    65,    65,\n      65,    48,    49,    66,     1,    49,    62,     4,     5,     6,\n       7,     8,     9,   184,    63,    62,   187,    63,    15,   190,\n      48,    49,    19,   133,   134,   196,    23,    24,    63,   299,\n      63,    28,    68,    30,    31,    32,    59,    65,    48,    49,\n      69,    48,    49,    14,    48,    42,    11,    12,    48,    49,\n      43,    44,    62,    46,   225,    62,     6,    54,    41,    41,\n     231,    26,    62,    60,    61,    59,    63,    64,   239,    66,\n      67,    66,    69,    59,    39,    40,   247,   248,    48,    64,\n     251,   252,    59,    64,   253,   254,    51,    52,    53,    54,\n      55,    56,    57,    55,    56,    57,    63,   262,    41,    63,\n      63,    35,    63,    63,   275,    63,    63,    59,    63,     0,\n       1,    59,    59,     4,     5,    59,    33,     8,    63,    10,\n      11,    12,    13,    14,    59,   296,   297,   298,   245,    20,\n      21,    22,   123,    19,    25,    26,    27,   308,    29,   302,\n     262,   196,    33,    34,    35,    36,    37,    38,    39,    40,\n     151,    42,    -1,    -1,    45,    -1,    -1,    48,    49,    50,\n      51,    52,    53,    54,    55,    56,    57,    -1,    59,    60,\n      61,    62,    63,    -1,    65,    66,     1,    68,    -1,     4,\n       5,     6,     7,     8,     9,    -1,    -1,    -1,    -1,    -1,\n      15,    -1,    -1,    -1,    19,    -1,    -1,    -1,    23,    24,\n      -1,    -1,    -1,    28,    -1,    30,    31,    32,    -1,    -1,\n      -1,    -1,    -1,    -1,    -1,    -1,    -1,    42,    -1,    -1,\n      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    54,\n      -1,    -1,    -1,    -1,    -1,    60,    61,    -1,    -1,    64,\n      -1,    66,    67,     1,    69,    -1,     4,     5,     6,     7,\n       8,     9,    -1,    -1,    -1,    -1,    -1,    15,    -1,    -1,\n      -1,    19,    -1,    -1,    -1,    23,    24,    -1,    -1,    -1,\n      28,    -1,    30,    31,    32,    -1,    -1,    -1,    -1,    -1,\n      -1,    -1,    -1,    -1,    42,    -1,    -1,    -1,    -1,    -1,\n      -1,    -1,    -1,    -1,    -1,    -1,    54,    -1,    -1,    -1,\n      -1,    -1,    60,    61,    -1,    -1,    64,    -1,    -1,    67,\n       1,    69,    -1,     4,     5,     6,     7,     8,     9,    -1,\n      -1,    -1,    -1,    -1,    15,    -1,    -1,    -1,    19,    -1,\n      -1,    -1,    23,    24,    -1,    -1,    -1,    28,    -1,    30,\n      31,    32,    -1,    -1,    -1,    -1,    11,    12,    -1,    -1,\n      -1,    42,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,\n      -1,    -1,    -1,    54,    -1,    -1,    -1,    -1,    -1,    60,\n      61,    -1,    -1,    64,    39,    40,    67,     1,    69,    -1,\n       4,     5,     6,     7,     8,     9,    51,    52,    53,    54,\n      55,    56,    57,    -1,    -1,    19,    -1,    -1,    -1,    23,\n      24,    -1,    -1,    -1,    28,    -1,    -1,    31,    32,    -1,\n      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    42,    -1,\n      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,\n      54,    -1,    -1,    -1,    -1,    -1,    60,    61,    -1,     1,\n      64,    -1,     4,    67,     6,    69,     8,    11,    12,    -1,\n      -1,    -1,    14,    15,    16,    17,    18,    19,    20,    21,\n      22,    23,    24,    25,    26,    27,    28,    29,    30,    31,\n      32,    -1,    -1,    -1,    -1,    39,    40,    -1,    -1,    -1,\n      42,    -1,    -1,    -1,    -1,    -1,    -1,    51,    52,    53,\n      54,    55,    56,    57,     1,    -1,    -1,     4,    -1,     6,\n      -1,     8,    64,    -1,    -1,    -1,    68,    14,    15,    16,\n      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,\n      27,    28,    29,    30,    31,    32,     4,     5,     6,     7,\n       8,     9,    -1,    -1,    -1,    42,    -1,    15,    -1,    -1,\n      -1,    19,    -1,    -1,    -1,    23,    24,    -1,    -1,    -1,\n      28,    -1,    30,    31,    32,    -1,    -1,    64,    -1,    -1,\n      -1,    68,    -1,    -1,    42,    -1,    -1,    -1,    -1,    -1,\n      -1,    -1,    -1,    -1,    -1,    -1,    54,    -1,    -1,    -1,\n      -1,    -1,    60,    61,    62,    -1,    64,    -1,    -1,    67,\n      -1,    69,     4,     5,     6,     7,     8,     9,    -1,    -1,\n      -1,    -1,    -1,    15,    -1,    -1,    -1,    19,    -1,    -1,\n      -1,    23,    24,    -1,    -1,    -1,    28,    -1,    30,    31,\n      32,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,\n      42,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,\n      -1,    -1,    54,    -1,    -1,    -1,    -1,    -1,    60,    61,\n      -1,    -1,    64,    -1,    66,    67,    -1,    69,     4,     5,\n       6,     7,     8,     9,    -1,    -1,    -1,    -1,    -1,    15,\n      -1,    -1,    -1,    19,    -1,    -1,    -1,    23,    24,    -1,\n      -1,    -1,    28,    -1,    30,    31,    32,    -1,    -1,    -1,\n      -1,    -1,    -1,    -1,    -1,    -1,    42,    -1,    -1,    -1,\n      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    54,    -1,\n      -1,    -1,    -1,    -1,    60,    61,    -1,    -1,    64,    -1,\n      66,    67,    -1,    69,     4,     5,     6,     7,     8,     9,\n      -1,    -1,    -1,    -1,    -1,    15,    -1,    -1,    -1,    19,\n      -1,    -1,    -1,    23,    24,    -1,    -1,    -1,    28,    -1,\n      30,    31,    32,    -1,    -1,    -1,    -1,    -1,    -1,    -1,\n      -1,    -1,    42,    -1,    -1,    -1,    -1,    -1,    -1,    -1,\n      -1,    -1,    -1,    -1,    54,    -1,    -1,    -1,    -1,    -1,\n      60,    61,    -1,    -1,    64,    -1,    -1,    67,    -1,    69,\n       4,     5,     6,     7,     8,     9,    -1,    -1,    -1,    -1,\n      -1,    -1,    -1,    -1,    -1,    19,    -1,    -1,    -1,    23,\n      24,    -1,    -1,    -1,    28,    -1,    -1,    31,    32,    -1,\n      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    42,    -1,\n      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,\n      54,    -1,    -1,    -1,    -1,    -1,    60,    61,    -1,     1,\n      64,    -1,     4,    67,     6,    69,     8,    -1,    -1,    -1,\n      -1,    -1,    14,    15,    16,    17,    18,    19,    20,    21,\n      22,    23,    24,    25,    26,    27,    28,    29,    30,    31,\n      10,    11,    12,    13,    14,    -1,    -1,    -1,    -1,    -1,\n      42,    -1,    -1,    -1,    -1,    -1,    26,    27,    -1,    -1,\n      -1,    -1,    -1,    33,    34,    35,    36,    37,    38,    39,\n      40,    -1,    64,    10,    11,    12,    13,    14,    -1,    -1,\n      50,    51,    52,    53,    54,    55,    56,    57,    -1,    26,\n      27,    -1,    -1,    -1,    -1,    -1,    33,    34,    35,    36,\n      37,    38,    39,    40,    -1,    10,    11,    12,    13,    14,\n      -1,    -1,    -1,    50,    51,    52,    53,    54,    55,    56,\n      57,    26,    27,    -1,    -1,    -1,    -1,    -1,    33,    34,\n      35,    36,    37,    38,    39,    40,    -1,    10,    11,    12,\n      13,    -1,    -1,    -1,    -1,    50,    51,    52,    53,    54,\n      55,    56,    57,    26,    27,    -1,    -1,    -1,    -1,    -1,\n      33,    34,    35,    36,    37,    38,    39,    40,    -1,    10,\n      11,    12,    -1,    -1,    -1,    -1,    -1,    50,    51,    52,\n      53,    54,    55,    56,    57,    26,    27,    -1,    -1,    -1,\n      -1,    -1,    33,    34,    35,    36,    37,    38,    39,    40,\n      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    50,\n      51,    52,    53,    54,    55,    56,    57\n};\n\n/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of\n   state STATE-NUM.  */\nstatic const yytype_int8 yystos[] =\n{\n       0,    16,    71,    72,     4,     5,     6,     7,     8,     9,\n      15,    19,    23,    24,    28,    30,    31,    32,    42,    54,\n      60,    61,    64,    67,    69,    75,    76,    80,    83,    84,\n      87,     0,    17,    18,    73,    77,    78,    64,    59,    42,\n       4,    75,    76,    76,    76,     6,     1,     6,    87,     1,\n       4,     8,    84,     1,    66,    75,     1,    75,     1,     4,\n       6,    14,    15,    16,    17,    18,    19,    20,    21,    22,\n      23,    24,    25,    26,    27,    28,    29,    30,    31,    32,\n      64,    84,    96,    97,    98,    69,    48,    49,    62,    10,\n      11,    12,    13,    14,    26,    27,    33,    34,    35,    36,\n      37,    38,    39,    40,    50,    51,    52,    53,    54,    55,\n      56,    57,    75,    85,     5,    59,    60,    61,    79,    84,\n      79,    74,    75,    80,    73,    62,    75,    75,    88,    89,\n      63,    64,    20,    14,    14,    29,    48,     1,    59,    66,\n      66,    65,    65,    63,    68,    63,    63,    75,    63,    63,\n      68,    49,    69,    75,    75,    76,    76,    76,    76,     6,\n      61,    67,    90,    91,    92,    76,    76,    76,    76,    76,\n      76,    76,    76,    76,    76,    76,    76,    76,    76,    76,\n      76,    76,    76,    43,    44,    46,    59,    61,    84,     1,\n      63,    66,    75,    14,    74,    62,    62,    65,    75,     4,\n       6,    81,    82,     1,    75,    91,    91,     1,    76,    75,\n      76,    99,    99,    99,    65,    99,    99,     1,    97,     6,\n      92,    93,     1,     4,     6,    64,    84,    94,    95,    96,\n      41,    48,    75,    66,    75,    59,    66,    75,    59,    63,\n      66,     4,     6,    89,    62,    62,    65,    21,    22,    25,\n      86,    64,    64,    48,    63,    49,    66,    63,    63,    63,\n      75,    63,    49,    68,    63,    92,    75,    45,    59,    66,\n      66,    66,    75,    59,    82,    63,    75,    75,    75,    75,\n      99,    99,    92,    92,    92,    92,    65,    92,    95,    92,\n      59,    59,    59,    66,    75,    25,    20,    62,    62,    63,\n      59,    62,    75,    75,    75,    92,    86,    65,    62,    65,\n      75,    65\n};\n\n/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.  */\nstatic const yytype_int8 yyr1[] =\n{\n       0,    70,    71,    71,    72,    72,    73,    73,    74,    74,\n      75,    75,    75,    75,    75,    75,    76,    76,    76,    76,\n      76,    76,    76,    76,    76,    76,    76,    76,    76,    76,\n      76,    76,    76,    76,    76,    76,    76,    76,    76,    77,\n      77,    78,    78,    78,    79,    80,    80,    81,    81,    82,\n      82,    83,    83,    84,    85,    85,    85,    86,    86,    86,\n      87,    87,    87,    87,    87,    87,    87,    87,    87,    87,\n      87,    87,    87,    87,    87,    87,    87,    87,    87,    87,\n      87,    87,    87,    87,    87,    87,    87,    87,    87,    87,\n      87,    87,    87,    87,    87,    87,    87,    87,    87,    87,\n      87,    87,    87,    87,    87,    87,    87,    87,    87,    87,\n      87,    87,    87,    87,    88,    88,    89,    90,    90,    91,\n      91,    92,    92,    92,    93,    93,    94,    94,    95,    95,\n      95,    95,    95,    95,    95,    96,    96,    96,    96,    96,\n      96,    96,    96,    96,    96,    96,    96,    96,    96,    96,\n      96,    96,    96,    97,    97,    97,    98,    98,    98,    98,\n      98,    98,    98,    98,    98,    98,    98,    99,    99\n};\n\n/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.  */\nstatic const yytype_int8 yyr2[] =\n{\n       0,     2,     3,     3,     0,     3,     0,     2,     0,     2,\n       2,     5,     4,     3,     3,     1,     3,     3,     3,     3,\n       3,     3,     3,     3,     3,     3,     3,     3,     3,     3,\n       3,     3,     3,     3,     3,     3,     3,     3,     1,     2,\n       3,     4,     4,     2,     1,     5,     8,     1,     3,     1,\n       1,     2,     1,     3,     0,     2,     4,     5,     3,     1,\n       1,     1,     2,     2,     3,     2,     4,     3,     2,     1,\n       3,     2,     2,     3,     5,     4,     6,     5,     4,     3,\n       5,     4,     7,     6,     6,     6,     5,     5,     2,     1,\n       1,     1,     2,     3,     3,     2,     3,     9,    11,     9,\n       5,     4,     4,     4,     2,     4,     1,     1,     1,     4,\n       3,     3,     4,     3,     1,     3,     1,     3,     1,     3,\n       1,     1,     3,     3,     1,     3,     1,     3,     1,     3,\n       3,     3,     3,     5,     3,     1,     1,     1,     1,     1,\n       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,\n       1,     1,     1,     0,     1,     3,     3,     3,     3,     1,\n       3,     1,     1,     1,     1,     5,     3,     3,     1\n};\n\n\nenum { YYENOMEM = -2 };\n\n#define yyerrok         (yyerrstatus = 0)\n#define yyclearin       (yychar = YYEMPTY)\n\n#define YYACCEPT        goto yyacceptlab\n#define YYABORT         goto yyabortlab\n#define YYERROR         goto yyerrorlab\n#define YYNOMEM         goto yyexhaustedlab\n\n\n#define YYRECOVERING()  (!!yyerrstatus)\n\n#define YYBACKUP(Token, Value)                                    \\\n  do                                                              \\\n    if (yychar == YYEMPTY)                                        \\\n      {                                                           \\\n        yychar = (Token);                                         \\\n        yylval = (Value);                                         \\\n        YYPOPSTACK (yylen);                                       \\\n        yystate = *yyssp;                                         \\\n        goto yybackup;                                            \\\n      }                                                           \\\n    else                                                          \\\n      {                                                           \\\n        yyerror (&yylloc, answer, errors, locations, lexer_param_ptr, YY_(\"syntax error: cannot back up\")); \\\n        YYERROR;                                                  \\\n      }                                                           \\\n  while (0)\n\n/* Backward compatibility with an undocumented macro.\n   Use YYerror or YYUNDEF. */\n#define YYERRCODE YYUNDEF\n\n/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].\n   If N is 0, then set CURRENT to the empty location which ends\n   the previous symbol: RHS[0] (always defined).  */\n\n#ifndef YYLLOC_DEFAULT\n# define YYLLOC_DEFAULT(Current, Rhs, N)                                \\\n    do                                                                  \\\n      if (N)                                                            \\\n        {                                                               \\\n          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \\\n          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \\\n          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \\\n          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \\\n        }                                                               \\\n      else                                                              \\\n        {                                                               \\\n          (Current).first_line   = (Current).last_line   =              \\\n            YYRHSLOC (Rhs, 0).last_line;                                \\\n          (Current).first_column = (Current).last_column =              \\\n            YYRHSLOC (Rhs, 0).last_column;                              \\\n        }                                                               \\\n    while (0)\n#endif\n\n#define YYRHSLOC(Rhs, K) ((Rhs)[K])\n\n\n/* Enable debugging if requested.  */\n#if YYDEBUG\n\n# ifndef YYFPRINTF\n#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */\n#  define YYFPRINTF fprintf\n# endif\n\n# define YYDPRINTF(Args)                        \\\ndo {                                            \\\n  if (yydebug)                                  \\\n    YYFPRINTF Args;                             \\\n} while (0)\n\n\n/* YYLOCATION_PRINT -- Print the location on the stream.\n   This macro was not mandated originally: define only if we know\n   we won't break user code: when these are the locations we know.  */\n\n# ifndef YYLOCATION_PRINT\n\n#  if defined YY_LOCATION_PRINT\n\n   /* Temporary convenience wrapper in case some people defined the\n      undocumented and private YY_LOCATION_PRINT macros.  */\n#   define YYLOCATION_PRINT(File, Loc)  YY_LOCATION_PRINT(File, *(Loc))\n\n#  elif defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL\n\n/* Print *YYLOCP on YYO.  Private, do not rely on its existence. */\n\nYY_ATTRIBUTE_UNUSED\nstatic int\nyy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)\n{\n  int res = 0;\n  int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;\n  if (0 <= yylocp->first_line)\n    {\n      res += YYFPRINTF (yyo, \"%d\", yylocp->first_line);\n      if (0 <= yylocp->first_column)\n        res += YYFPRINTF (yyo, \".%d\", yylocp->first_column);\n    }\n  if (0 <= yylocp->last_line)\n    {\n      if (yylocp->first_line < yylocp->last_line)\n        {\n          res += YYFPRINTF (yyo, \"-%d\", yylocp->last_line);\n          if (0 <= end_col)\n            res += YYFPRINTF (yyo, \".%d\", end_col);\n        }\n      else if (0 <= end_col && yylocp->first_column < end_col)\n        res += YYFPRINTF (yyo, \"-%d\", end_col);\n    }\n  return res;\n}\n\n#   define YYLOCATION_PRINT  yy_location_print_\n\n    /* Temporary convenience wrapper in case some people defined the\n       undocumented and private YY_LOCATION_PRINT macros.  */\n#   define YY_LOCATION_PRINT(File, Loc)  YYLOCATION_PRINT(File, &(Loc))\n\n#  else\n\n#   define YYLOCATION_PRINT(File, Loc) ((void) 0)\n    /* Temporary convenience wrapper in case some people defined the\n       undocumented and private YY_LOCATION_PRINT macros.  */\n#   define YY_LOCATION_PRINT  YYLOCATION_PRINT\n\n#  endif\n# endif /* !defined YYLOCATION_PRINT */\n\n\n# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \\\ndo {                                                                      \\\n  if (yydebug)                                                            \\\n    {                                                                     \\\n      YYFPRINTF (stderr, \"%s \", Title);                                   \\\n      yy_symbol_print (stderr,                                            \\\n                  Kind, Value, Location, answer, errors, locations, lexer_param_ptr); \\\n      YYFPRINTF (stderr, \"\\n\");                                           \\\n    }                                                                     \\\n} while (0)\n\n\n/*-----------------------------------.\n| Print this symbol's value on YYO.  |\n`-----------------------------------*/\n\nstatic void\nyy_symbol_value_print (FILE *yyo,\n                       yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr)\n{\n  FILE *yyoutput = yyo;\n  YY_USE (yyoutput);\n  YY_USE (yylocationp);\n  YY_USE (answer);\n  YY_USE (errors);\n  YY_USE (locations);\n  YY_USE (lexer_param_ptr);\n  if (!yyvaluep)\n    return;\n  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN\n  YY_USE (yykind);\n  YY_IGNORE_MAYBE_UNINITIALIZED_END\n}\n\n\n/*---------------------------.\n| Print this symbol on YYO.  |\n`---------------------------*/\n\nstatic void\nyy_symbol_print (FILE *yyo,\n                 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr)\n{\n  YYFPRINTF (yyo, \"%s %s (\",\n             yykind < YYNTOKENS ? \"token\" : \"nterm\", yysymbol_name (yykind));\n\n  YYLOCATION_PRINT (yyo, yylocationp);\n  YYFPRINTF (yyo, \": \");\n  yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp, answer, errors, locations, lexer_param_ptr);\n  YYFPRINTF (yyo, \")\");\n}\n\n/*------------------------------------------------------------------.\n| yy_stack_print -- Print the state stack from its BOTTOM up to its |\n| TOP (included).                                                   |\n`------------------------------------------------------------------*/\n\nstatic void\nyy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)\n{\n  YYFPRINTF (stderr, \"Stack now\");\n  for (; yybottom <= yytop; yybottom++)\n    {\n      int yybot = *yybottom;\n      YYFPRINTF (stderr, \" %d\", yybot);\n    }\n  YYFPRINTF (stderr, \"\\n\");\n}\n\n# define YY_STACK_PRINT(Bottom, Top)                            \\\ndo {                                                            \\\n  if (yydebug)                                                  \\\n    yy_stack_print ((Bottom), (Top));                           \\\n} while (0)\n\n\n/*------------------------------------------------.\n| Report that the YYRULE is going to be reduced.  |\n`------------------------------------------------*/\n\nstatic void\nyy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp,\n                 int yyrule, block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr)\n{\n  int yylno = yyrline[yyrule];\n  int yynrhs = yyr2[yyrule];\n  int yyi;\n  YYFPRINTF (stderr, \"Reducing stack by rule %d (line %d):\\n\",\n             yyrule - 1, yylno);\n  /* The symbols being reduced.  */\n  for (yyi = 0; yyi < yynrhs; yyi++)\n    {\n      YYFPRINTF (stderr, \"   $%d = \", yyi + 1);\n      yy_symbol_print (stderr,\n                       YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),\n                       &yyvsp[(yyi + 1) - (yynrhs)],\n                       &(yylsp[(yyi + 1) - (yynrhs)]), answer, errors, locations, lexer_param_ptr);\n      YYFPRINTF (stderr, \"\\n\");\n    }\n}\n\n# define YY_REDUCE_PRINT(Rule)          \\\ndo {                                    \\\n  if (yydebug)                          \\\n    yy_reduce_print (yyssp, yyvsp, yylsp, Rule, answer, errors, locations, lexer_param_ptr); \\\n} while (0)\n\n/* Nonzero means print parse trace.  It is left uninitialized so that\n   multiple parsers can coexist.  */\nint yydebug;\n#else /* !YYDEBUG */\n# define YYDPRINTF(Args) ((void) 0)\n# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)\n# define YY_STACK_PRINT(Bottom, Top)\n# define YY_REDUCE_PRINT(Rule)\n#endif /* !YYDEBUG */\n\n\n/* YYINITDEPTH -- initial size of the parser's stacks.  */\n#ifndef YYINITDEPTH\n# define YYINITDEPTH 200\n#endif\n\n/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only\n   if the built-in stack extension method is used).\n\n   Do not make this value too large; the results are undefined if\n   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)\n   evaluated with infinite-precision integer arithmetic.  */\n\n#ifndef YYMAXDEPTH\n# define YYMAXDEPTH 10000\n#endif\n\n\n/* Context of a parse error.  */\ntypedef struct\n{\n  yy_state_t *yyssp;\n  yysymbol_kind_t yytoken;\n  YYLTYPE *yylloc;\n} yypcontext_t;\n\n/* Put in YYARG at most YYARGN of the expected tokens given the\n   current YYCTX, and return the number of tokens stored in YYARG.  If\n   YYARG is null, return the number of expected tokens (guaranteed to\n   be less than YYNTOKENS).  Return YYENOMEM on memory exhaustion.\n   Return 0 if there are more than YYARGN expected tokens, yet fill\n   YYARG up to YYARGN. */\nstatic int\nyypcontext_expected_tokens (const yypcontext_t *yyctx,\n                            yysymbol_kind_t yyarg[], int yyargn)\n{\n  /* Actual size of YYARG. */\n  int yycount = 0;\n  int yyn = yypact[+*yyctx->yyssp];\n  if (!yypact_value_is_default (yyn))\n    {\n      /* Start YYX at -YYN if negative to avoid negative indexes in\n         YYCHECK.  In other words, skip the first -YYN actions for\n         this state because they are default actions.  */\n      int yyxbegin = yyn < 0 ? -yyn : 0;\n      /* Stay within bounds of both yycheck and yytname.  */\n      int yychecklim = YYLAST - yyn + 1;\n      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;\n      int yyx;\n      for (yyx = yyxbegin; yyx < yyxend; ++yyx)\n        if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror\n            && !yytable_value_is_error (yytable[yyx + yyn]))\n          {\n            if (!yyarg)\n              ++yycount;\n            else if (yycount == yyargn)\n              return 0;\n            else\n              yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);\n          }\n    }\n  if (yyarg && yycount == 0 && 0 < yyargn)\n    yyarg[0] = YYSYMBOL_YYEMPTY;\n  return yycount;\n}\n\n\n\n\n#ifndef yystrlen\n# if defined __GLIBC__ && defined _STRING_H\n#  define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))\n# else\n/* Return the length of YYSTR.  */\nstatic YYPTRDIFF_T\nyystrlen (const char *yystr)\n{\n  YYPTRDIFF_T yylen;\n  for (yylen = 0; yystr[yylen]; yylen++)\n    continue;\n  return yylen;\n}\n# endif\n#endif\n\n#ifndef yystpcpy\n# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE\n#  define yystpcpy stpcpy\n# else\n/* Copy YYSRC to YYDEST, returning the address of the terminating '\\0' in\n   YYDEST.  */\nstatic char *\nyystpcpy (char *yydest, const char *yysrc)\n{\n  char *yyd = yydest;\n  const char *yys = yysrc;\n\n  while ((*yyd++ = *yys++) != '\\0')\n    continue;\n\n  return yyd - 1;\n}\n# endif\n#endif\n\n#ifndef yytnamerr\n/* Copy to YYRES the contents of YYSTR after stripping away unnecessary\n   quotes and backslashes, so that it's suitable for yyerror.  The\n   heuristic is that double-quoting is unnecessary unless the string\n   contains an apostrophe, a comma, or backslash (other than\n   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is\n   null, do not copy; instead, return the length of what the result\n   would have been.  */\nstatic YYPTRDIFF_T\nyytnamerr (char *yyres, const char *yystr)\n{\n  if (*yystr == '\"')\n    {\n      YYPTRDIFF_T yyn = 0;\n      char const *yyp = yystr;\n      for (;;)\n        switch (*++yyp)\n          {\n          case '\\'':\n          case ',':\n            goto do_not_strip_quotes;\n\n          case '\\\\':\n            if (*++yyp != '\\\\')\n              goto do_not_strip_quotes;\n            else\n              goto append;\n\n          append:\n          default:\n            if (yyres)\n              yyres[yyn] = *yyp;\n            yyn++;\n            break;\n\n          case '\"':\n            if (yyres)\n              yyres[yyn] = '\\0';\n            return yyn;\n          }\n    do_not_strip_quotes: ;\n    }\n\n  if (yyres)\n    return yystpcpy (yyres, yystr) - yyres;\n  else\n    return yystrlen (yystr);\n}\n#endif\n\n\nstatic int\nyy_syntax_error_arguments (const yypcontext_t *yyctx,\n                           yysymbol_kind_t yyarg[], int yyargn)\n{\n  /* Actual size of YYARG. */\n  int yycount = 0;\n  /* There are many possibilities here to consider:\n     - If this state is a consistent state with a default action, then\n       the only way this function was invoked is if the default action\n       is an error action.  In that case, don't check for expected\n       tokens because there are none.\n     - The only way there can be no lookahead present (in yychar) is if\n       this state is a consistent state with a default action.  Thus,\n       detecting the absence of a lookahead is sufficient to determine\n       that there is no unexpected or expected token to report.  In that\n       case, just report a simple \"syntax error\".\n     - Don't assume there isn't a lookahead just because this state is a\n       consistent state with a default action.  There might have been a\n       previous inconsistent state, consistent state with a non-default\n       action, or user semantic action that manipulated yychar.\n     - Of course, the expected token list depends on states to have\n       correct lookahead information, and it depends on the parser not\n       to perform extra reductions after fetching a lookahead from the\n       scanner and before detecting a syntax error.  Thus, state merging\n       (from LALR or IELR) and default reductions corrupt the expected\n       token list.  However, the list is correct for canonical LR with\n       one exception: it will still contain any token that will not be\n       accepted due to an error action in a later state.\n  */\n  if (yyctx->yytoken != YYSYMBOL_YYEMPTY)\n    {\n      int yyn;\n      if (yyarg)\n        yyarg[yycount] = yyctx->yytoken;\n      ++yycount;\n      yyn = yypcontext_expected_tokens (yyctx,\n                                        yyarg ? yyarg + 1 : yyarg, yyargn - 1);\n      if (yyn == YYENOMEM)\n        return YYENOMEM;\n      else\n        yycount += yyn;\n    }\n  return yycount;\n}\n\n/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message\n   about the unexpected token YYTOKEN for the state stack whose top is\n   YYSSP.\n\n   Return 0 if *YYMSG was successfully written.  Return -1 if *YYMSG is\n   not large enough to hold the message.  In that case, also set\n   *YYMSG_ALLOC to the required number of bytes.  Return YYENOMEM if the\n   required number of bytes is too large to store.  */\nstatic int\nyysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,\n                const yypcontext_t *yyctx)\n{\n  enum { YYARGS_MAX = 5 };\n  /* Internationalized format string. */\n  const char *yyformat = YY_NULLPTR;\n  /* Arguments of yyformat: reported tokens (one for the \"unexpected\",\n     one per \"expected\"). */\n  yysymbol_kind_t yyarg[YYARGS_MAX];\n  /* Cumulated lengths of YYARG.  */\n  YYPTRDIFF_T yysize = 0;\n\n  /* Actual size of YYARG. */\n  int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);\n  if (yycount == YYENOMEM)\n    return YYENOMEM;\n\n  switch (yycount)\n    {\n#define YYCASE_(N, S)                       \\\n      case N:                               \\\n        yyformat = S;                       \\\n        break\n    default: /* Avoid compiler warnings. */\n      YYCASE_(0, YY_(\"syntax error\"));\n      YYCASE_(1, YY_(\"syntax error, unexpected %s\"));\n      YYCASE_(2, YY_(\"syntax error, unexpected %s, expecting %s\"));\n      YYCASE_(3, YY_(\"syntax error, unexpected %s, expecting %s or %s\"));\n      YYCASE_(4, YY_(\"syntax error, unexpected %s, expecting %s or %s or %s\"));\n      YYCASE_(5, YY_(\"syntax error, unexpected %s, expecting %s or %s or %s or %s\"));\n#undef YYCASE_\n    }\n\n  /* Compute error message size.  Don't count the \"%s\"s, but reserve\n     room for the terminator.  */\n  yysize = yystrlen (yyformat) - 2 * yycount + 1;\n  {\n    int yyi;\n    for (yyi = 0; yyi < yycount; ++yyi)\n      {\n        YYPTRDIFF_T yysize1\n          = yysize + yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]]);\n        if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)\n          yysize = yysize1;\n        else\n          return YYENOMEM;\n      }\n  }\n\n  if (*yymsg_alloc < yysize)\n    {\n      *yymsg_alloc = 2 * yysize;\n      if (! (yysize <= *yymsg_alloc\n             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))\n        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;\n      return -1;\n    }\n\n  /* Avoid sprintf, as that infringes on the user's name space.\n     Don't have undefined behavior even if the translation\n     produced a string with the wrong number of \"%s\"s.  */\n  {\n    char *yyp = *yymsg;\n    int yyi = 0;\n    while ((*yyp = *yyformat) != '\\0')\n      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)\n        {\n          yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);\n          yyformat += 2;\n        }\n      else\n        {\n          ++yyp;\n          ++yyformat;\n        }\n  }\n  return 0;\n}\n\n\n/*-----------------------------------------------.\n| Release the memory associated to this symbol.  |\n`-----------------------------------------------*/\n\nstatic void\nyydestruct (const char *yymsg,\n            yysymbol_kind_t yykind, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr)\n{\n  YY_USE (yyvaluep);\n  YY_USE (yylocationp);\n  YY_USE (answer);\n  YY_USE (errors);\n  YY_USE (locations);\n  YY_USE (lexer_param_ptr);\n  if (!yymsg)\n    yymsg = \"Deleting\";\n  YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);\n\n  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN\n  switch (yykind)\n    {\n    case YYSYMBOL_IDENT: /* IDENT  */\n#line 37 \"src/parser.y\"\n            { jv_free(((*yyvaluep).literal)); }\n#line 2004 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_FIELD: /* FIELD  */\n#line 37 \"src/parser.y\"\n            { jv_free(((*yyvaluep).literal)); }\n#line 2010 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_BINDING: /* BINDING  */\n#line 37 \"src/parser.y\"\n            { jv_free(((*yyvaluep).literal)); }\n#line 2016 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_LITERAL: /* LITERAL  */\n#line 37 \"src/parser.y\"\n            { jv_free(((*yyvaluep).literal)); }\n#line 2022 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_FORMAT: /* FORMAT  */\n#line 37 \"src/parser.y\"\n            { jv_free(((*yyvaluep).literal)); }\n#line 2028 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_QQSTRING_TEXT: /* QQSTRING_TEXT  */\n#line 37 \"src/parser.y\"\n            { jv_free(((*yyvaluep).literal)); }\n#line 2034 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Module: /* Module  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2040 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Imports: /* Imports  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2046 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_FuncDefs: /* FuncDefs  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2052 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Query: /* Query  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2058 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Expr: /* Expr  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2064 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Import: /* Import  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2070 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_ImportWhat: /* ImportWhat  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2076 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_ImportFrom: /* ImportFrom  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2082 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_FuncDef: /* FuncDef  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2088 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Params: /* Params  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2094 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Param: /* Param  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2100 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_StringStart: /* StringStart  */\n#line 37 \"src/parser.y\"\n            { jv_free(((*yyvaluep).literal)); }\n#line 2106 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_String: /* String  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2112 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_QQString: /* QQString  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2118 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_ElseBody: /* ElseBody  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2124 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Term: /* Term  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2130 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Args: /* Args  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2136 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Arg: /* Arg  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2142 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_RepPatterns: /* RepPatterns  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2148 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Patterns: /* Patterns  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2154 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Pattern: /* Pattern  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2160 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_ArrayPats: /* ArrayPats  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2166 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_ObjPats: /* ObjPats  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2172 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_ObjPat: /* ObjPat  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2178 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_Keyword: /* Keyword  */\n#line 37 \"src/parser.y\"\n            { jv_free(((*yyvaluep).literal)); }\n#line 2184 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_DictPairs: /* DictPairs  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2190 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_DictPair: /* DictPair  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2196 \"src/parser.c\"\n        break;\n\n    case YYSYMBOL_DictExpr: /* DictExpr  */\n#line 38 \"src/parser.y\"\n            { block_free(((*yyvaluep).blk)); }\n#line 2202 \"src/parser.c\"\n        break;\n\n      default:\n        break;\n    }\n  YY_IGNORE_MAYBE_UNINITIALIZED_END\n}\n\n\n\n\n\n\n/*----------.\n| yyparse.  |\n`----------*/\n\nint\nyyparse (block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr)\n{\n/* Lookahead token kind.  */\nint yychar;\n\n\n/* The semantic value of the lookahead symbol.  */\n/* Default value used for initialization, for pacifying older GCCs\n   or non-GCC compilers.  */\nYY_INITIAL_VALUE (static YYSTYPE yyval_default;)\nYYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);\n\n/* Location data for the lookahead symbol.  */\nstatic YYLTYPE yyloc_default\n# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL\n  = { 1, 1, 1, 1 }\n# endif\n;\nYYLTYPE yylloc = yyloc_default;\n\n    /* Number of syntax errors so far.  */\n    int yynerrs = 0;\n\n    yy_state_fast_t yystate = 0;\n    /* Number of tokens to shift before error messages enabled.  */\n    int yyerrstatus = 0;\n\n    /* Refer to the stacks through separate pointers, to allow yyoverflow\n       to reallocate them elsewhere.  */\n\n    /* Their size.  */\n    YYPTRDIFF_T yystacksize = YYINITDEPTH;\n\n    /* The state stack: array, bottom, top.  */\n    yy_state_t yyssa[YYINITDEPTH];\n    yy_state_t *yyss = yyssa;\n    yy_state_t *yyssp = yyss;\n\n    /* The semantic value stack: array, bottom, top.  */\n    YYSTYPE yyvsa[YYINITDEPTH];\n    YYSTYPE *yyvs = yyvsa;\n    YYSTYPE *yyvsp = yyvs;\n\n    /* The location stack: array, bottom, top.  */\n    YYLTYPE yylsa[YYINITDEPTH];\n    YYLTYPE *yyls = yylsa;\n    YYLTYPE *yylsp = yyls;\n\n  int yyn;\n  /* The return value of yyparse.  */\n  int yyresult;\n  /* Lookahead symbol kind.  */\n  yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;\n  /* The variables used to return semantic value and location from the\n     action routines.  */\n  YYSTYPE yyval;\n  YYLTYPE yyloc;\n\n  /* The locations where the error started and ended.  */\n  YYLTYPE yyerror_range[3];\n\n  /* Buffer for error messages, and its allocated size.  */\n  char yymsgbuf[128];\n  char *yymsg = yymsgbuf;\n  YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;\n\n#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))\n\n  /* The number of symbols on the RHS of the reduced rule.\n     Keep to zero when no symbol should be popped.  */\n  int yylen = 0;\n\n  YYDPRINTF ((stderr, \"Starting parse\\n\"));\n\n  yychar = YYEMPTY; /* Cause a token to be read.  */\n\n  yylsp[0] = yylloc;\n  goto yysetstate;\n\n\n/*------------------------------------------------------------.\n| yynewstate -- push a new state, which is found in yystate.  |\n`------------------------------------------------------------*/\nyynewstate:\n  /* In all cases, when you get here, the value and location stacks\n     have just been pushed.  So pushing a state here evens the stacks.  */\n  yyssp++;\n\n\n/*--------------------------------------------------------------------.\n| yysetstate -- set current state (the top of the stack) to yystate.  |\n`--------------------------------------------------------------------*/\nyysetstate:\n  YYDPRINTF ((stderr, \"Entering state %d\\n\", yystate));\n  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);\n  YY_IGNORE_USELESS_CAST_BEGIN\n  *yyssp = YY_CAST (yy_state_t, yystate);\n  YY_IGNORE_USELESS_CAST_END\n  YY_STACK_PRINT (yyss, yyssp);\n\n  if (yyss + yystacksize - 1 <= yyssp)\n#if !defined yyoverflow && !defined YYSTACK_RELOCATE\n    YYNOMEM;\n#else\n    {\n      /* Get the current used size of the three stacks, in elements.  */\n      YYPTRDIFF_T yysize = yyssp - yyss + 1;\n\n# if defined yyoverflow\n      {\n        /* Give user a chance to reallocate the stack.  Use copies of\n           these so that the &'s don't force the real ones into\n           memory.  */\n        yy_state_t *yyss1 = yyss;\n        YYSTYPE *yyvs1 = yyvs;\n        YYLTYPE *yyls1 = yyls;\n\n        /* Each stack pointer address is followed by the size of the\n           data in use in that stack, in bytes.  This used to be a\n           conditional around just the two extra args, but that might\n           be undefined if yyoverflow is a macro.  */\n        yyoverflow (YY_(\"memory exhausted\"),\n                    &yyss1, yysize * YYSIZEOF (*yyssp),\n                    &yyvs1, yysize * YYSIZEOF (*yyvsp),\n                    &yyls1, yysize * YYSIZEOF (*yylsp),\n                    &yystacksize);\n        yyss = yyss1;\n        yyvs = yyvs1;\n        yyls = yyls1;\n      }\n# else /* defined YYSTACK_RELOCATE */\n      /* Extend the stack our own way.  */\n      if (YYMAXDEPTH <= yystacksize)\n        YYNOMEM;\n      yystacksize *= 2;\n      if (YYMAXDEPTH < yystacksize)\n        yystacksize = YYMAXDEPTH;\n\n      {\n        yy_state_t *yyss1 = yyss;\n        union yyalloc *yyptr =\n          YY_CAST (union yyalloc *,\n                   YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));\n        if (! yyptr)\n          YYNOMEM;\n        YYSTACK_RELOCATE (yyss_alloc, yyss);\n        YYSTACK_RELOCATE (yyvs_alloc, yyvs);\n        YYSTACK_RELOCATE (yyls_alloc, yyls);\n#  undef YYSTACK_RELOCATE\n        if (yyss1 != yyssa)\n          YYSTACK_FREE (yyss1);\n      }\n# endif\n\n      yyssp = yyss + yysize - 1;\n      yyvsp = yyvs + yysize - 1;\n      yylsp = yyls + yysize - 1;\n\n      YY_IGNORE_USELESS_CAST_BEGIN\n      YYDPRINTF ((stderr, \"Stack size increased to %ld\\n\",\n                  YY_CAST (long, yystacksize)));\n      YY_IGNORE_USELESS_CAST_END\n\n      if (yyss + yystacksize - 1 <= yyssp)\n        YYABORT;\n    }\n#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */\n\n\n  if (yystate == YYFINAL)\n    YYACCEPT;\n\n  goto yybackup;\n\n\n/*-----------.\n| yybackup.  |\n`-----------*/\nyybackup:\n  /* Do appropriate processing given the current state.  Read a\n     lookahead token if we need one and don't already have one.  */\n\n  /* First try to decide what to do without reference to lookahead token.  */\n  yyn = yypact[yystate];\n  if (yypact_value_is_default (yyn))\n    goto yydefault;\n\n  /* Not known => get a lookahead token if don't already have one.  */\n\n  /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */\n  if (yychar == YYEMPTY)\n    {\n      YYDPRINTF ((stderr, \"Reading a token\\n\"));\n      yychar = yylex (&yylval, &yylloc, answer, errors, locations, lexer_param_ptr);\n    }\n\n  if (yychar <= YYEOF)\n    {\n      yychar = YYEOF;\n      yytoken = YYSYMBOL_YYEOF;\n      YYDPRINTF ((stderr, \"Now at end of input.\\n\"));\n    }\n  else if (yychar == YYerror)\n    {\n      /* The scanner already issued an error message, process directly\n         to error recovery.  But do not keep the error token as\n         lookahead, it is too special and may lead us to an endless\n         loop in error recovery. */\n      yychar = YYUNDEF;\n      yytoken = YYSYMBOL_YYerror;\n      yyerror_range[1] = yylloc;\n      goto yyerrlab1;\n    }\n  else\n    {\n      yytoken = YYTRANSLATE (yychar);\n      YY_SYMBOL_PRINT (\"Next token is\", yytoken, &yylval, &yylloc);\n    }\n\n  /* If the proper action on seeing token YYTOKEN is to reduce or to\n     detect an error, take that action.  */\n  yyn += yytoken;\n  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)\n    goto yydefault;\n  yyn = yytable[yyn];\n  if (yyn <= 0)\n    {\n      if (yytable_value_is_error (yyn))\n        goto yyerrlab;\n      yyn = -yyn;\n      goto yyreduce;\n    }\n\n  /* Count tokens shifted since error; after three, turn off error\n     status.  */\n  if (yyerrstatus)\n    yyerrstatus--;\n\n  /* Shift the lookahead token.  */\n  YY_SYMBOL_PRINT (\"Shifting\", yytoken, &yylval, &yylloc);\n  yystate = yyn;\n  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN\n  *++yyvsp = yylval;\n  YY_IGNORE_MAYBE_UNINITIALIZED_END\n  *++yylsp = yylloc;\n\n  /* Discard the shifted token.  */\n  yychar = YYEMPTY;\n  goto yynewstate;\n\n\n/*-----------------------------------------------------------.\n| yydefault -- do the default action for the current state.  |\n`-----------------------------------------------------------*/\nyydefault:\n  yyn = yydefact[yystate];\n  if (yyn == 0)\n    goto yyerrlab;\n  goto yyreduce;\n\n\n/*-----------------------------.\n| yyreduce -- do a reduction.  |\n`-----------------------------*/\nyyreduce:\n  /* yyn is the number of a rule to reduce with.  */\n  yylen = yyr2[yyn];\n\n  /* If YYLEN is nonzero, implement the default value of the action:\n     '$$ = $1'.\n\n     Otherwise, the following line sets YYVAL to garbage.\n     This behavior is undocumented and Bison\n     users should not rely upon it.  Assigning to YYVAL\n     unconditionally makes the parser a bit smaller, and it avoids a\n     GCC warning that YYVAL may be used uninitialized.  */\n  yyval = yyvsp[1-yylen];\n\n  /* Default location. */\n  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);\n  yyerror_range[1] = yyloc;\n  YY_REDUCE_PRINT (yyn);\n  switch (yyn)\n    {\n  case 2: /* TopLevel: Module Imports Query  */\n#line 282 \"src/parser.y\"\n                     {\n  *answer = BLOCK((yyvsp[-2].blk), (yyvsp[-1].blk), gen_op_simple(TOP), (yyvsp[0].blk));\n}\n#line 2510 \"src/parser.c\"\n    break;\n\n  case 3: /* TopLevel: Module Imports FuncDefs  */\n#line 285 \"src/parser.y\"\n                        {\n  *answer = BLOCK((yyvsp[-2].blk), (yyvsp[-1].blk), (yyvsp[0].blk));\n}\n#line 2518 \"src/parser.c\"\n    break;\n\n  case 4: /* Module: %empty  */\n#line 290 \"src/parser.y\"\n       {\n  (yyval.blk) = gen_noop();\n}\n#line 2526 \"src/parser.c\"\n    break;\n\n  case 5: /* Module: \"module\" Query ';'  */\n#line 293 \"src/parser.y\"\n                   {\n  if (!block_is_const((yyvsp[-1].blk))) {\n    FAIL((yylsp[-1]), \"Module metadata must be constant\");\n    (yyval.blk) = gen_noop();\n    block_free((yyvsp[-1].blk));\n  } else if (block_const_kind((yyvsp[-1].blk)) != JV_KIND_OBJECT) {\n    FAIL((yylsp[-1]), \"Module metadata must be an object\");\n    (yyval.blk) = gen_noop();\n    block_free((yyvsp[-1].blk));\n  } else {\n    (yyval.blk) = gen_module((yyvsp[-1].blk));\n  }\n}\n#line 2544 \"src/parser.c\"\n    break;\n\n  case 6: /* Imports: %empty  */\n#line 308 \"src/parser.y\"\n       {\n  (yyval.blk) = gen_noop();\n}\n#line 2552 \"src/parser.c\"\n    break;\n\n  case 7: /* Imports: Import Imports  */\n#line 311 \"src/parser.y\"\n               {\n  (yyval.blk) = BLOCK((yyvsp[-1].blk), (yyvsp[0].blk));\n}\n#line 2560 \"src/parser.c\"\n    break;\n\n  case 8: /* FuncDefs: %empty  */\n#line 316 \"src/parser.y\"\n       {\n  (yyval.blk) = gen_noop();\n}\n#line 2568 \"src/parser.c\"\n    break;\n\n  case 9: /* FuncDefs: FuncDef FuncDefs  */\n#line 319 \"src/parser.y\"\n                 {\n  (yyval.blk) = block_join((yyvsp[-1].blk), (yyvsp[0].blk));\n}\n#line 2576 \"src/parser.c\"\n    break;\n\n  case 10: /* Query: FuncDef Query  */\n#line 325 \"src/parser.y\"\n                            {\n  (yyval.blk) = block_bind_referenced((yyvsp[-1].blk), (yyvsp[0].blk), OP_IS_CALL_PSEUDO);\n}\n#line 2584 \"src/parser.c\"\n    break;\n\n  case 11: /* Query: Expr \"as\" Patterns '|' Query  */\n#line 328 \"src/parser.y\"\n                             {\n  (yyval.blk) = gen_destructure((yyvsp[-4].blk), (yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 2592 \"src/parser.c\"\n    break;\n\n  case 12: /* Query: \"label\" BINDING '|' Query  */\n#line 331 \"src/parser.y\"\n                          {\n  jv v = jv_string_fmt(\"*label-%s\", jv_string_value((yyvsp[-2].literal)));\n  (yyval.blk) = gen_location((yyloc), locations, gen_label(jv_string_value(v), (yyvsp[0].blk)));\n  jv_free((yyvsp[-2].literal));\n  jv_free(v);\n}\n#line 2603 \"src/parser.c\"\n    break;\n\n  case 13: /* Query: Query '|' Query  */\n#line 337 \"src/parser.y\"\n                {\n  (yyval.blk) = block_join((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 2611 \"src/parser.c\"\n    break;\n\n  case 14: /* Query: Query ',' Query  */\n#line 340 \"src/parser.y\"\n                {\n  (yyval.blk) = gen_both((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 2619 \"src/parser.c\"\n    break;\n\n  case 15: /* Query: Expr  */\n#line 343 \"src/parser.y\"\n     {\n  (yyval.blk) = (yyvsp[0].blk);\n}\n#line 2627 \"src/parser.c\"\n    break;\n\n  case 16: /* Expr: Expr \"//\" Expr  */\n#line 349 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_definedor((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 2635 \"src/parser.c\"\n    break;\n\n  case 17: /* Expr: Expr '=' Expr  */\n#line 352 \"src/parser.y\"\n              {\n  (yyval.blk) = gen_call(\"_assign\", BLOCK(gen_lambda((yyvsp[-2].blk)), gen_lambda((yyvsp[0].blk))));\n}\n#line 2643 \"src/parser.c\"\n    break;\n\n  case 18: /* Expr: Expr \"or\" Expr  */\n#line 355 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_or((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 2651 \"src/parser.c\"\n    break;\n\n  case 19: /* Expr: Expr \"and\" Expr  */\n#line 358 \"src/parser.y\"\n                {\n  (yyval.blk) = gen_and((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 2659 \"src/parser.c\"\n    break;\n\n  case 20: /* Expr: Expr \"//=\" Expr  */\n#line 361 \"src/parser.y\"\n                {\n  (yyval.blk) = gen_definedor_assign((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 2667 \"src/parser.c\"\n    break;\n\n  case 21: /* Expr: Expr \"|=\" Expr  */\n#line 364 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_call(\"_modify\", BLOCK(gen_lambda((yyvsp[-2].blk)), gen_lambda((yyvsp[0].blk))));\n}\n#line 2675 \"src/parser.c\"\n    break;\n\n  case 22: /* Expr: Expr '+' Expr  */\n#line 367 \"src/parser.y\"\n              {\n  (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '+');\n}\n#line 2683 \"src/parser.c\"\n    break;\n\n  case 23: /* Expr: Expr \"+=\" Expr  */\n#line 370 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_update((yyvsp[-2].blk), (yyvsp[0].blk), '+');\n}\n#line 2691 \"src/parser.c\"\n    break;\n\n  case 24: /* Expr: Expr '-' Expr  */\n#line 373 \"src/parser.y\"\n              {\n  (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '-');\n}\n#line 2699 \"src/parser.c\"\n    break;\n\n  case 25: /* Expr: Expr \"-=\" Expr  */\n#line 376 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_update((yyvsp[-2].blk), (yyvsp[0].blk), '-');\n}\n#line 2707 \"src/parser.c\"\n    break;\n\n  case 26: /* Expr: Expr '*' Expr  */\n#line 379 \"src/parser.y\"\n              {\n  (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '*');\n}\n#line 2715 \"src/parser.c\"\n    break;\n\n  case 27: /* Expr: Expr \"*=\" Expr  */\n#line 382 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_update((yyvsp[-2].blk), (yyvsp[0].blk), '*');\n}\n#line 2723 \"src/parser.c\"\n    break;\n\n  case 28: /* Expr: Expr '/' Expr  */\n#line 385 \"src/parser.y\"\n              {\n  (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '/');\n}\n#line 2731 \"src/parser.c\"\n    break;\n\n  case 29: /* Expr: Expr '%' Expr  */\n#line 388 \"src/parser.y\"\n              {\n  (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '%');\n}\n#line 2739 \"src/parser.c\"\n    break;\n\n  case 30: /* Expr: Expr \"/=\" Expr  */\n#line 391 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_update((yyvsp[-2].blk), (yyvsp[0].blk), '/');\n}\n#line 2747 \"src/parser.c\"\n    break;\n\n  case 31: /* Expr: Expr \"%=\" Expr  */\n#line 394 \"src/parser.y\"\n                 {\n  (yyval.blk) = gen_update((yyvsp[-2].blk), (yyvsp[0].blk), '%');\n}\n#line 2755 \"src/parser.c\"\n    break;\n\n  case 32: /* Expr: Expr \"==\" Expr  */\n#line 397 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), EQ);\n}\n#line 2763 \"src/parser.c\"\n    break;\n\n  case 33: /* Expr: Expr \"!=\" Expr  */\n#line 400 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), NEQ);\n}\n#line 2771 \"src/parser.c\"\n    break;\n\n  case 34: /* Expr: Expr '<' Expr  */\n#line 403 \"src/parser.y\"\n              {\n  (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '<');\n}\n#line 2779 \"src/parser.c\"\n    break;\n\n  case 35: /* Expr: Expr '>' Expr  */\n#line 406 \"src/parser.y\"\n              {\n  (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '>');\n}\n#line 2787 \"src/parser.c\"\n    break;\n\n  case 36: /* Expr: Expr \"<=\" Expr  */\n#line 409 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), LESSEQ);\n}\n#line 2795 \"src/parser.c\"\n    break;\n\n  case 37: /* Expr: Expr \">=\" Expr  */\n#line 412 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), GREATEREQ);\n}\n#line 2803 \"src/parser.c\"\n    break;\n\n  case 38: /* Expr: Term  */\n#line 415 \"src/parser.y\"\n                  {\n  (yyval.blk) = (yyvsp[0].blk);\n}\n#line 2811 \"src/parser.c\"\n    break;\n\n  case 39: /* Import: ImportWhat ';'  */\n#line 421 \"src/parser.y\"\n               {\n  (yyval.blk) = (yyvsp[-1].blk);\n}\n#line 2819 \"src/parser.c\"\n    break;\n\n  case 40: /* Import: ImportWhat Query ';'  */\n#line 424 \"src/parser.y\"\n                     {\n  if (!block_is_const((yyvsp[-1].blk))) {\n    FAIL((yylsp[-1]), \"Module metadata must be constant\");\n    (yyval.blk) = gen_noop();\n    block_free((yyvsp[-2].blk));\n    block_free((yyvsp[-1].blk));\n  } else if (block_const_kind((yyvsp[-1].blk)) != JV_KIND_OBJECT) {\n    FAIL((yylsp[-1]), \"Module metadata must be an object\");\n    (yyval.blk) = gen_noop();\n    block_free((yyvsp[-2].blk));\n    block_free((yyvsp[-1].blk));\n  } else {\n    (yyval.blk) = gen_import_meta((yyvsp[-2].blk), (yyvsp[-1].blk));\n  }\n}\n#line 2839 \"src/parser.c\"\n    break;\n\n  case 41: /* ImportWhat: \"import\" ImportFrom \"as\" BINDING  */\n#line 441 \"src/parser.y\"\n                                 {\n  jv v = block_const((yyvsp[-2].blk));\n  // XXX Make gen_import take only blocks and the int is_data so we\n  // don't have to free so much stuff here\n  (yyval.blk) = gen_import(jv_string_value(v), jv_string_value((yyvsp[0].literal)), 1);\n  block_free((yyvsp[-2].blk));\n  jv_free((yyvsp[0].literal));\n  jv_free(v);\n}\n#line 2853 \"src/parser.c\"\n    break;\n\n  case 42: /* ImportWhat: \"import\" ImportFrom \"as\" IDENT  */\n#line 450 \"src/parser.y\"\n                               {\n  jv v = block_const((yyvsp[-2].blk));\n  (yyval.blk) = gen_import(jv_string_value(v), jv_string_value((yyvsp[0].literal)), 0);\n  block_free((yyvsp[-2].blk));\n  jv_free((yyvsp[0].literal));\n  jv_free(v);\n}\n#line 2865 \"src/parser.c\"\n    break;\n\n  case 43: /* ImportWhat: \"include\" ImportFrom  */\n#line 457 \"src/parser.y\"\n                     {\n  jv v = block_const((yyvsp[0].blk));\n  (yyval.blk) = gen_import(jv_string_value(v), NULL, 0);\n  block_free((yyvsp[0].blk));\n  jv_free(v);\n}\n#line 2876 \"src/parser.c\"\n    break;\n\n  case 44: /* ImportFrom: String  */\n#line 465 \"src/parser.y\"\n       {\n  if (!block_is_const((yyvsp[0].blk))) {\n    FAIL((yylsp[0]), \"Import path must be constant\");\n    (yyval.blk) = gen_const(jv_string(\"\"));\n    block_free((yyvsp[0].blk));\n  } else {\n    (yyval.blk) = (yyvsp[0].blk);\n  }\n}\n#line 2890 \"src/parser.c\"\n    break;\n\n  case 45: /* FuncDef: \"def\" IDENT ':' Query ';'  */\n#line 476 \"src/parser.y\"\n                          {\n  (yyval.blk) = gen_function(jv_string_value((yyvsp[-3].literal)), gen_noop(), (yyvsp[-1].blk));\n  jv_free((yyvsp[-3].literal));\n}\n#line 2899 \"src/parser.c\"\n    break;\n\n  case 46: /* FuncDef: \"def\" IDENT '(' Params ')' ':' Query ';'  */\n#line 481 \"src/parser.y\"\n                                         {\n  (yyval.blk) = gen_function(jv_string_value((yyvsp[-6].literal)), (yyvsp[-4].blk), (yyvsp[-1].blk));\n  jv_free((yyvsp[-6].literal));\n}\n#line 2908 \"src/parser.c\"\n    break;\n\n  case 47: /* Params: Param  */\n#line 487 \"src/parser.y\"\n      {\n  (yyval.blk) = (yyvsp[0].blk);\n}\n#line 2916 \"src/parser.c\"\n    break;\n\n  case 48: /* Params: Params ';' Param  */\n#line 490 \"src/parser.y\"\n                 {\n  (yyval.blk) = BLOCK((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 2924 \"src/parser.c\"\n    break;\n\n  case 49: /* Param: BINDING  */\n#line 495 \"src/parser.y\"\n        {\n  (yyval.blk) = gen_param_regular(jv_string_value((yyvsp[0].literal)));\n  jv_free((yyvsp[0].literal));\n}\n#line 2933 \"src/parser.c\"\n    break;\n\n  case 50: /* Param: IDENT  */\n#line 499 \"src/parser.y\"\n      {\n  (yyval.blk) = gen_param(jv_string_value((yyvsp[0].literal)));\n  jv_free((yyvsp[0].literal));\n}\n#line 2942 \"src/parser.c\"\n    break;\n\n  case 51: /* StringStart: FORMAT QQSTRING_START  */\n#line 506 \"src/parser.y\"\n                      {\n  (yyval.literal) = (yyvsp[-1].literal);\n}\n#line 2950 \"src/parser.c\"\n    break;\n\n  case 52: /* StringStart: QQSTRING_START  */\n#line 509 \"src/parser.y\"\n               {\n  (yyval.literal) = jv_string(\"text\");\n}\n#line 2958 \"src/parser.c\"\n    break;\n\n  case 53: /* String: StringStart QQString QQSTRING_END  */\n#line 515 \"src/parser.y\"\n                                  {\n  (yyval.blk) = (yyvsp[-1].blk);\n  jv_free((yyvsp[-2].literal));\n}\n#line 2967 \"src/parser.c\"\n    break;\n\n  case 54: /* QQString: %empty  */\n#line 522 \"src/parser.y\"\n       {\n  (yyval.blk) = gen_const(jv_string(\"\"));\n}\n#line 2975 \"src/parser.c\"\n    break;\n\n  case 55: /* QQString: QQString QQSTRING_TEXT  */\n#line 525 \"src/parser.y\"\n                       {\n  (yyval.blk) = gen_binop((yyvsp[-1].blk), gen_const((yyvsp[0].literal)), '+');\n}\n#line 2983 \"src/parser.c\"\n    break;\n\n  case 56: /* QQString: QQString QQSTRING_INTERP_START Query QQSTRING_INTERP_END  */\n#line 528 \"src/parser.y\"\n                                                         {\n  (yyval.blk) = gen_binop((yyvsp[-3].blk), gen_format((yyvsp[-1].blk), jv_copy((yyvsp[-4].literal))), '+');\n}\n#line 2991 \"src/parser.c\"\n    break;\n\n  case 57: /* ElseBody: \"elif\" Query \"then\" Query ElseBody  */\n#line 534 \"src/parser.y\"\n                                   {\n  (yyval.blk) = gen_cond((yyvsp[-3].blk), (yyvsp[-1].blk), (yyvsp[0].blk));\n}\n#line 2999 \"src/parser.c\"\n    break;\n\n  case 58: /* ElseBody: \"else\" Query \"end\"  */\n#line 537 \"src/parser.y\"\n                   {\n  (yyval.blk) = (yyvsp[-1].blk);\n}\n#line 3007 \"src/parser.c\"\n    break;\n\n  case 59: /* ElseBody: \"end\"  */\n#line 540 \"src/parser.y\"\n      {\n  (yyval.blk) = gen_noop();\n}\n#line 3015 \"src/parser.c\"\n    break;\n\n  case 60: /* Term: '.'  */\n#line 546 \"src/parser.y\"\n    {\n  (yyval.blk) = gen_noop();\n}\n#line 3023 \"src/parser.c\"\n    break;\n\n  case 61: /* Term: \"..\"  */\n#line 549 \"src/parser.y\"\n    {\n  (yyval.blk) = gen_call(\"recurse\", gen_noop());\n}\n#line 3031 \"src/parser.c\"\n    break;\n\n  case 62: /* Term: \"break\" BINDING  */\n#line 552 \"src/parser.y\"\n              {\n  jv v = jv_string_fmt(\"*label-%s\", jv_string_value((yyvsp[0].literal)));     // impossible symbol\n  (yyval.blk) = gen_location((yyloc), locations,\n                    BLOCK(gen_op_unbound(LOADV, jv_string_value(v)),\n                    gen_call(\"error\", gen_noop())));\n  jv_free(v);\n  jv_free((yyvsp[0].literal));\n}\n#line 3044 \"src/parser.c\"\n    break;\n\n  case 63: /* Term: \"break\" error  */\n#line 560 \"src/parser.y\"\n            {\n  FAIL((yyloc), \"break requires a label to break to\");\n  (yyval.blk) = gen_noop();\n}\n#line 3053 \"src/parser.c\"\n    break;\n\n  case 64: /* Term: Term FIELD '?'  */\n#line 564 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_index_opt((yyvsp[-2].blk), gen_const((yyvsp[-1].literal)));\n}\n#line 3061 \"src/parser.c\"\n    break;\n\n  case 65: /* Term: FIELD '?'  */\n#line 567 \"src/parser.y\"\n          {\n  (yyval.blk) = gen_index_opt(gen_noop(), gen_const((yyvsp[-1].literal)));\n}\n#line 3069 \"src/parser.c\"\n    break;\n\n  case 66: /* Term: Term '.' String '?'  */\n#line 570 \"src/parser.y\"\n                    {\n  (yyval.blk) = gen_index_opt((yyvsp[-3].blk), (yyvsp[-1].blk));\n}\n#line 3077 \"src/parser.c\"\n    break;\n\n  case 67: /* Term: '.' String '?'  */\n#line 573 \"src/parser.y\"\n               {\n  (yyval.blk) = gen_index_opt(gen_noop(), (yyvsp[-1].blk));\n}\n#line 3085 \"src/parser.c\"\n    break;\n\n  case 68: /* Term: Term FIELD  */\n#line 576 \"src/parser.y\"\n                        {\n  (yyval.blk) = gen_index((yyvsp[-1].blk), gen_const((yyvsp[0].literal)));\n}\n#line 3093 \"src/parser.c\"\n    break;\n\n  case 69: /* Term: FIELD  */\n#line 579 \"src/parser.y\"\n                   {\n  (yyval.blk) = gen_index(gen_noop(), gen_const((yyvsp[0].literal)));\n}\n#line 3101 \"src/parser.c\"\n    break;\n\n  case 70: /* Term: Term '.' String  */\n#line 582 \"src/parser.y\"\n                             {\n  (yyval.blk) = gen_index((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 3109 \"src/parser.c\"\n    break;\n\n  case 71: /* Term: '.' String  */\n#line 585 \"src/parser.y\"\n                        {\n  (yyval.blk) = gen_index(gen_noop(), (yyvsp[0].blk));\n}\n#line 3117 \"src/parser.c\"\n    break;\n\n  case 72: /* Term: '.' error  */\n#line 588 \"src/parser.y\"\n          {\n  FAIL((yyloc), \"try .[\\\"field\\\"] instead of .field for unusually named fields\");\n  (yyval.blk) = gen_noop();\n}\n#line 3126 \"src/parser.c\"\n    break;\n\n  case 73: /* Term: '.' IDENT error  */\n#line 592 \"src/parser.y\"\n                {\n  jv_free((yyvsp[-1].literal));\n  FAIL((yyloc), \"try .[\\\"field\\\"] instead of .field for unusually named fields\");\n  (yyval.blk) = gen_noop();\n}\n#line 3136 \"src/parser.c\"\n    break;\n\n  case 74: /* Term: Term '[' Query ']' '?'  */\n#line 598 \"src/parser.y\"\n                       {\n  (yyval.blk) = gen_index_opt((yyvsp[-4].blk), (yyvsp[-2].blk));\n}\n#line 3144 \"src/parser.c\"\n    break;\n\n  case 75: /* Term: Term '[' Query ']'  */\n#line 601 \"src/parser.y\"\n                                {\n  (yyval.blk) = gen_index((yyvsp[-3].blk), (yyvsp[-1].blk));\n}\n#line 3152 \"src/parser.c\"\n    break;\n\n  case 76: /* Term: Term '.' '[' Query ']' '?'  */\n#line 604 \"src/parser.y\"\n                           {\n  (yyval.blk) = gen_index_opt((yyvsp[-5].blk), (yyvsp[-2].blk));\n}\n#line 3160 \"src/parser.c\"\n    break;\n\n  case 77: /* Term: Term '.' '[' Query ']'  */\n#line 607 \"src/parser.y\"\n                                    {\n  (yyval.blk) = gen_index((yyvsp[-4].blk), (yyvsp[-1].blk));\n}\n#line 3168 \"src/parser.c\"\n    break;\n\n  case 78: /* Term: Term '[' ']' '?'  */\n#line 610 \"src/parser.y\"\n                 {\n  (yyval.blk) = block_join((yyvsp[-3].blk), gen_op_simple(EACH_OPT));\n}\n#line 3176 \"src/parser.c\"\n    break;\n\n  case 79: /* Term: Term '[' ']'  */\n#line 613 \"src/parser.y\"\n                          {\n  (yyval.blk) = block_join((yyvsp[-2].blk), gen_op_simple(EACH));\n}\n#line 3184 \"src/parser.c\"\n    break;\n\n  case 80: /* Term: Term '.' '[' ']' '?'  */\n#line 616 \"src/parser.y\"\n                     {\n  (yyval.blk) = block_join((yyvsp[-4].blk), gen_op_simple(EACH_OPT));\n}\n#line 3192 \"src/parser.c\"\n    break;\n\n  case 81: /* Term: Term '.' '[' ']'  */\n#line 619 \"src/parser.y\"\n                              {\n  (yyval.blk) = block_join((yyvsp[-3].blk), gen_op_simple(EACH));\n}\n#line 3200 \"src/parser.c\"\n    break;\n\n  case 82: /* Term: Term '[' Query ':' Query ']' '?'  */\n#line 622 \"src/parser.y\"\n                                 {\n  (yyval.blk) = gen_slice_index((yyvsp[-6].blk), (yyvsp[-4].blk), (yyvsp[-2].blk), INDEX_OPT);\n}\n#line 3208 \"src/parser.c\"\n    break;\n\n  case 83: /* Term: Term '[' Query ':' ']' '?'  */\n#line 625 \"src/parser.y\"\n                           {\n  (yyval.blk) = gen_slice_index((yyvsp[-5].blk), (yyvsp[-3].blk), gen_const(jv_null()), INDEX_OPT);\n}\n#line 3216 \"src/parser.c\"\n    break;\n\n  case 84: /* Term: Term '[' ':' Query ']' '?'  */\n#line 628 \"src/parser.y\"\n                           {\n  (yyval.blk) = gen_slice_index((yyvsp[-5].blk), gen_const(jv_null()), (yyvsp[-2].blk), INDEX_OPT);\n}\n#line 3224 \"src/parser.c\"\n    break;\n\n  case 85: /* Term: Term '[' Query ':' Query ']'  */\n#line 631 \"src/parser.y\"\n                                          {\n  (yyval.blk) = gen_slice_index((yyvsp[-5].blk), (yyvsp[-3].blk), (yyvsp[-1].blk), INDEX);\n}\n#line 3232 \"src/parser.c\"\n    break;\n\n  case 86: /* Term: Term '[' Query ':' ']'  */\n#line 634 \"src/parser.y\"\n                                    {\n  (yyval.blk) = gen_slice_index((yyvsp[-4].blk), (yyvsp[-2].blk), gen_const(jv_null()), INDEX);\n}\n#line 3240 \"src/parser.c\"\n    break;\n\n  case 87: /* Term: Term '[' ':' Query ']'  */\n#line 637 \"src/parser.y\"\n                                    {\n  (yyval.blk) = gen_slice_index((yyvsp[-4].blk), gen_const(jv_null()), (yyvsp[-1].blk), INDEX);\n}\n#line 3248 \"src/parser.c\"\n    break;\n\n  case 88: /* Term: Term '?'  */\n#line 640 \"src/parser.y\"\n         {\n  (yyval.blk) = gen_try((yyvsp[-1].blk), gen_op_simple(BACKTRACK));\n}\n#line 3256 \"src/parser.c\"\n    break;\n\n  case 89: /* Term: LITERAL  */\n#line 643 \"src/parser.y\"\n        {\n  (yyval.blk) = gen_const((yyvsp[0].literal));\n}\n#line 3264 \"src/parser.c\"\n    break;\n\n  case 90: /* Term: String  */\n#line 646 \"src/parser.y\"\n       {\n  (yyval.blk) = (yyvsp[0].blk);\n}\n#line 3272 \"src/parser.c\"\n    break;\n\n  case 91: /* Term: FORMAT  */\n#line 649 \"src/parser.y\"\n       {\n  (yyval.blk) = gen_format(gen_noop(), (yyvsp[0].literal));\n}\n#line 3280 \"src/parser.c\"\n    break;\n\n  case 92: /* Term: '-' Term  */\n#line 652 \"src/parser.y\"\n         {\n  (yyval.blk) = BLOCK((yyvsp[0].blk), gen_call(\"_negate\", gen_noop()));\n}\n#line 3288 \"src/parser.c\"\n    break;\n\n  case 93: /* Term: '(' Query ')'  */\n#line 655 \"src/parser.y\"\n              {\n  (yyval.blk) = (yyvsp[-1].blk);\n}\n#line 3296 \"src/parser.c\"\n    break;\n\n  case 94: /* Term: '[' Query ']'  */\n#line 658 \"src/parser.y\"\n              {\n  (yyval.blk) = gen_collect((yyvsp[-1].blk));\n}\n#line 3304 \"src/parser.c\"\n    break;\n\n  case 95: /* Term: '[' ']'  */\n#line 661 \"src/parser.y\"\n        {\n  (yyval.blk) = gen_const(jv_array());\n}\n#line 3312 \"src/parser.c\"\n    break;\n\n  case 96: /* Term: '{' DictPairs '}'  */\n#line 664 \"src/parser.y\"\n                  {\n  block o = gen_const_object((yyvsp[-1].blk));\n  if (o.first != NULL)\n    (yyval.blk) = o;\n  else\n    (yyval.blk) = BLOCK(gen_subexp(gen_const(jv_object())), (yyvsp[-1].blk), gen_op_simple(POP));\n}\n#line 3324 \"src/parser.c\"\n    break;\n\n  case 97: /* Term: \"reduce\" Expr \"as\" Patterns '(' Query ';' Query ')'  */\n#line 671 \"src/parser.y\"\n                                                    {\n  (yyval.blk) = gen_reduce((yyvsp[-7].blk), (yyvsp[-5].blk), (yyvsp[-3].blk), (yyvsp[-1].blk));\n}\n#line 3332 \"src/parser.c\"\n    break;\n\n  case 98: /* Term: \"foreach\" Expr \"as\" Patterns '(' Query ';' Query ';' Query ')'  */\n#line 674 \"src/parser.y\"\n                                                               {\n  (yyval.blk) = gen_foreach((yyvsp[-9].blk), (yyvsp[-7].blk), (yyvsp[-5].blk), (yyvsp[-3].blk), (yyvsp[-1].blk));\n}\n#line 3340 \"src/parser.c\"\n    break;\n\n  case 99: /* Term: \"foreach\" Expr \"as\" Patterns '(' Query ';' Query ')'  */\n#line 677 \"src/parser.y\"\n                                                     {\n  (yyval.blk) = gen_foreach((yyvsp[-7].blk), (yyvsp[-5].blk), (yyvsp[-3].blk), (yyvsp[-1].blk), gen_noop());\n}\n#line 3348 \"src/parser.c\"\n    break;\n\n  case 100: /* Term: \"if\" Query \"then\" Query ElseBody  */\n#line 680 \"src/parser.y\"\n                                 {\n  (yyval.blk) = gen_cond((yyvsp[-3].blk), (yyvsp[-1].blk), (yyvsp[0].blk));\n}\n#line 3356 \"src/parser.c\"\n    break;\n\n  case 101: /* Term: \"if\" Query \"then\" error  */\n#line 683 \"src/parser.y\"\n                        {\n  FAIL((yyloc), \"Possibly unterminated 'if' statement\");\n  (yyval.blk) = (yyvsp[-2].blk);\n}\n#line 3365 \"src/parser.c\"\n    break;\n\n  case 102: /* Term: \"try\" Expr \"catch\" Expr  */\n#line 687 \"src/parser.y\"\n                        {\n  (yyval.blk) = gen_try((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 3373 \"src/parser.c\"\n    break;\n\n  case 103: /* Term: \"try\" Expr \"catch\" error  */\n#line 690 \"src/parser.y\"\n                         {\n  FAIL((yyloc), \"Possibly unterminated 'try' statement\");\n  (yyval.blk) = (yyvsp[-2].blk);\n}\n#line 3382 \"src/parser.c\"\n    break;\n\n  case 104: /* Term: \"try\" Expr  */\n#line 694 \"src/parser.y\"\n           {\n  (yyval.blk) = gen_try((yyvsp[0].blk), gen_op_simple(BACKTRACK));\n}\n#line 3390 \"src/parser.c\"\n    break;\n\n  case 105: /* Term: '$' '$' '$' BINDING  */\n#line 712 \"src/parser.y\"\n                    {\n  (yyval.blk) = gen_location((yyloc), locations, gen_op_unbound(LOADVN, jv_string_value((yyvsp[0].literal))));\n  jv_free((yyvsp[0].literal));\n}\n#line 3399 \"src/parser.c\"\n    break;\n\n  case 106: /* Term: BINDING  */\n#line 716 \"src/parser.y\"\n        {\n  (yyval.blk) = gen_location((yyloc), locations, gen_op_unbound(LOADV, jv_string_value((yyvsp[0].literal))));\n  jv_free((yyvsp[0].literal));\n}\n#line 3408 \"src/parser.c\"\n    break;\n\n  case 107: /* Term: \"$__loc__\"  */\n#line 720 \"src/parser.y\"\n           {\n  (yyval.blk) = gen_loc_object(&(yyloc), locations);\n}\n#line 3416 \"src/parser.c\"\n    break;\n\n  case 108: /* Term: IDENT  */\n#line 723 \"src/parser.y\"\n      {\n  const char *s = jv_string_value((yyvsp[0].literal));\n  if (strcmp(s, \"false\") == 0)\n    (yyval.blk) = gen_const(jv_false());\n  else if (strcmp(s, \"true\") == 0)\n    (yyval.blk) = gen_const(jv_true());\n  else if (strcmp(s, \"null\") == 0)\n    (yyval.blk) = gen_const(jv_null());\n  else\n    (yyval.blk) = gen_location((yyloc), locations, gen_call(s, gen_noop()));\n  jv_free((yyvsp[0].literal));\n}\n#line 3433 \"src/parser.c\"\n    break;\n\n  case 109: /* Term: IDENT '(' Args ')'  */\n#line 735 \"src/parser.y\"\n                   {\n  (yyval.blk) = gen_call(jv_string_value((yyvsp[-3].literal)), (yyvsp[-1].blk));\n  (yyval.blk) = gen_location((yylsp[-3]), locations, (yyval.blk));\n  jv_free((yyvsp[-3].literal));\n}\n#line 3443 \"src/parser.c\"\n    break;\n\n  case 110: /* Term: '(' error ')'  */\n#line 740 \"src/parser.y\"\n              { (yyval.blk) = gen_noop(); }\n#line 3449 \"src/parser.c\"\n    break;\n\n  case 111: /* Term: '[' error ']'  */\n#line 741 \"src/parser.y\"\n              { (yyval.blk) = gen_noop(); }\n#line 3455 \"src/parser.c\"\n    break;\n\n  case 112: /* Term: Term '[' error ']'  */\n#line 742 \"src/parser.y\"\n                   { (yyval.blk) = (yyvsp[-3].blk); }\n#line 3461 \"src/parser.c\"\n    break;\n\n  case 113: /* Term: '{' error '}'  */\n#line 743 \"src/parser.y\"\n              { (yyval.blk) = gen_noop(); }\n#line 3467 \"src/parser.c\"\n    break;\n\n  case 114: /* Args: Arg  */\n#line 746 \"src/parser.y\"\n    {\n  (yyval.blk) = (yyvsp[0].blk);\n}\n#line 3475 \"src/parser.c\"\n    break;\n\n  case 115: /* Args: Args ';' Arg  */\n#line 749 \"src/parser.y\"\n             {\n  (yyval.blk) = BLOCK((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 3483 \"src/parser.c\"\n    break;\n\n  case 116: /* Arg: Query  */\n#line 754 \"src/parser.y\"\n      {\n  (yyval.blk) = gen_lambda((yyvsp[0].blk));\n}\n#line 3491 \"src/parser.c\"\n    break;\n\n  case 117: /* RepPatterns: RepPatterns \"?//\" Pattern  */\n#line 759 \"src/parser.y\"\n                          {\n  (yyval.blk) = BLOCK((yyvsp[-2].blk), gen_destructure_alt((yyvsp[0].blk)));\n}\n#line 3499 \"src/parser.c\"\n    break;\n\n  case 118: /* RepPatterns: Pattern  */\n#line 762 \"src/parser.y\"\n        {\n  (yyval.blk) = gen_destructure_alt((yyvsp[0].blk));\n}\n#line 3507 \"src/parser.c\"\n    break;\n\n  case 119: /* Patterns: RepPatterns \"?//\" Pattern  */\n#line 767 \"src/parser.y\"\n                          {\n  (yyval.blk) = BLOCK((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 3515 \"src/parser.c\"\n    break;\n\n  case 120: /* Patterns: Pattern  */\n#line 770 \"src/parser.y\"\n        {\n  (yyval.blk) = (yyvsp[0].blk);\n}\n#line 3523 \"src/parser.c\"\n    break;\n\n  case 121: /* Pattern: BINDING  */\n#line 775 \"src/parser.y\"\n        {\n  (yyval.blk) = gen_op_unbound(STOREV, jv_string_value((yyvsp[0].literal)));\n  jv_free((yyvsp[0].literal));\n}\n#line 3532 \"src/parser.c\"\n    break;\n\n  case 122: /* Pattern: '[' ArrayPats ']'  */\n#line 779 \"src/parser.y\"\n                  {\n  (yyval.blk) = BLOCK((yyvsp[-1].blk), gen_op_simple(POP));\n}\n#line 3540 \"src/parser.c\"\n    break;\n\n  case 123: /* Pattern: '{' ObjPats '}'  */\n#line 782 \"src/parser.y\"\n                {\n  (yyval.blk) = BLOCK((yyvsp[-1].blk), gen_op_simple(POP));\n}\n#line 3548 \"src/parser.c\"\n    break;\n\n  case 124: /* ArrayPats: Pattern  */\n#line 787 \"src/parser.y\"\n        {\n  (yyval.blk) = gen_array_matcher(gen_noop(), (yyvsp[0].blk));\n}\n#line 3556 \"src/parser.c\"\n    break;\n\n  case 125: /* ArrayPats: ArrayPats ',' Pattern  */\n#line 790 \"src/parser.y\"\n                      {\n  (yyval.blk) = gen_array_matcher((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 3564 \"src/parser.c\"\n    break;\n\n  case 126: /* ObjPats: ObjPat  */\n#line 795 \"src/parser.y\"\n       {\n  (yyval.blk) = (yyvsp[0].blk);\n}\n#line 3572 \"src/parser.c\"\n    break;\n\n  case 127: /* ObjPats: ObjPats ',' ObjPat  */\n#line 798 \"src/parser.y\"\n                   {\n  (yyval.blk) = BLOCK((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 3580 \"src/parser.c\"\n    break;\n\n  case 128: /* ObjPat: BINDING  */\n#line 803 \"src/parser.y\"\n        {\n  (yyval.blk) = gen_object_matcher(gen_const((yyvsp[0].literal)), gen_op_unbound(STOREV, jv_string_value((yyvsp[0].literal))));\n}\n#line 3588 \"src/parser.c\"\n    break;\n\n  case 129: /* ObjPat: BINDING ':' Pattern  */\n#line 806 \"src/parser.y\"\n                    {\n  (yyval.blk) = gen_object_matcher(gen_const((yyvsp[-2].literal)), BLOCK(gen_op_simple(DUP), gen_op_unbound(STOREV, jv_string_value((yyvsp[-2].literal))), (yyvsp[0].blk)));\n}\n#line 3596 \"src/parser.c\"\n    break;\n\n  case 130: /* ObjPat: IDENT ':' Pattern  */\n#line 809 \"src/parser.y\"\n                  {\n  (yyval.blk) = gen_object_matcher(gen_const((yyvsp[-2].literal)), (yyvsp[0].blk));\n}\n#line 3604 \"src/parser.c\"\n    break;\n\n  case 131: /* ObjPat: Keyword ':' Pattern  */\n#line 812 \"src/parser.y\"\n                    {\n  (yyval.blk) = gen_object_matcher(gen_const((yyvsp[-2].literal)), (yyvsp[0].blk));\n}\n#line 3612 \"src/parser.c\"\n    break;\n\n  case 132: /* ObjPat: String ':' Pattern  */\n#line 815 \"src/parser.y\"\n                   {\n  (yyval.blk) = gen_object_matcher((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 3620 \"src/parser.c\"\n    break;\n\n  case 133: /* ObjPat: '(' Query ')' ':' Pattern  */\n#line 818 \"src/parser.y\"\n                          {\n  jv msg = check_object_key((yyvsp[-3].blk));\n  if (jv_is_valid(msg)) {\n    FAIL((yylsp[-3]), jv_string_value(msg));\n  }\n  jv_free(msg);\n  (yyval.blk) = gen_object_matcher((yyvsp[-3].blk), (yyvsp[0].blk));\n}\n#line 3633 \"src/parser.c\"\n    break;\n\n  case 134: /* ObjPat: error ':' Pattern  */\n#line 826 \"src/parser.y\"\n                  {\n  FAIL((yyloc), \"May need parentheses around object key expression\");\n  (yyval.blk) = (yyvsp[0].blk);\n}\n#line 3642 \"src/parser.c\"\n    break;\n\n  case 135: /* Keyword: \"as\"  */\n#line 832 \"src/parser.y\"\n     {\n  (yyval.literal) = jv_string(\"as\");\n}\n#line 3650 \"src/parser.c\"\n    break;\n\n  case 136: /* Keyword: \"def\"  */\n#line 835 \"src/parser.y\"\n      {\n  (yyval.literal) = jv_string(\"def\");\n}\n#line 3658 \"src/parser.c\"\n    break;\n\n  case 137: /* Keyword: \"module\"  */\n#line 838 \"src/parser.y\"\n         {\n  (yyval.literal) = jv_string(\"module\");\n}\n#line 3666 \"src/parser.c\"\n    break;\n\n  case 138: /* Keyword: \"import\"  */\n#line 841 \"src/parser.y\"\n         {\n  (yyval.literal) = jv_string(\"import\");\n}\n#line 3674 \"src/parser.c\"\n    break;\n\n  case 139: /* Keyword: \"include\"  */\n#line 844 \"src/parser.y\"\n          {\n  (yyval.literal) = jv_string(\"include\");\n}\n#line 3682 \"src/parser.c\"\n    break;\n\n  case 140: /* Keyword: \"if\"  */\n#line 847 \"src/parser.y\"\n     {\n  (yyval.literal) = jv_string(\"if\");\n}\n#line 3690 \"src/parser.c\"\n    break;\n\n  case 141: /* Keyword: \"then\"  */\n#line 850 \"src/parser.y\"\n       {\n  (yyval.literal) = jv_string(\"then\");\n}\n#line 3698 \"src/parser.c\"\n    break;\n\n  case 142: /* Keyword: \"else\"  */\n#line 853 \"src/parser.y\"\n       {\n  (yyval.literal) = jv_string(\"else\");\n}\n#line 3706 \"src/parser.c\"\n    break;\n\n  case 143: /* Keyword: \"elif\"  */\n#line 856 \"src/parser.y\"\n       {\n  (yyval.literal) = jv_string(\"elif\");\n}\n#line 3714 \"src/parser.c\"\n    break;\n\n  case 144: /* Keyword: \"reduce\"  */\n#line 859 \"src/parser.y\"\n         {\n  (yyval.literal) = jv_string(\"reduce\");\n}\n#line 3722 \"src/parser.c\"\n    break;\n\n  case 145: /* Keyword: \"foreach\"  */\n#line 862 \"src/parser.y\"\n          {\n  (yyval.literal) = jv_string(\"foreach\");\n}\n#line 3730 \"src/parser.c\"\n    break;\n\n  case 146: /* Keyword: \"end\"  */\n#line 865 \"src/parser.y\"\n      {\n  (yyval.literal) = jv_string(\"end\");\n}\n#line 3738 \"src/parser.c\"\n    break;\n\n  case 147: /* Keyword: \"and\"  */\n#line 868 \"src/parser.y\"\n      {\n  (yyval.literal) = jv_string(\"and\");\n}\n#line 3746 \"src/parser.c\"\n    break;\n\n  case 148: /* Keyword: \"or\"  */\n#line 871 \"src/parser.y\"\n     {\n  (yyval.literal) = jv_string(\"or\");\n}\n#line 3754 \"src/parser.c\"\n    break;\n\n  case 149: /* Keyword: \"try\"  */\n#line 874 \"src/parser.y\"\n      {\n  (yyval.literal) = jv_string(\"try\");\n}\n#line 3762 \"src/parser.c\"\n    break;\n\n  case 150: /* Keyword: \"catch\"  */\n#line 877 \"src/parser.y\"\n        {\n  (yyval.literal) = jv_string(\"catch\");\n}\n#line 3770 \"src/parser.c\"\n    break;\n\n  case 151: /* Keyword: \"label\"  */\n#line 880 \"src/parser.y\"\n        {\n  (yyval.literal) = jv_string(\"label\");\n}\n#line 3778 \"src/parser.c\"\n    break;\n\n  case 152: /* Keyword: \"break\"  */\n#line 883 \"src/parser.y\"\n        {\n  (yyval.literal) = jv_string(\"break\");\n}\n#line 3786 \"src/parser.c\"\n    break;\n\n  case 153: /* DictPairs: %empty  */\n#line 889 \"src/parser.y\"\n       {\n  (yyval.blk) = gen_noop();\n}\n#line 3794 \"src/parser.c\"\n    break;\n\n  case 154: /* DictPairs: DictPair  */\n#line 892 \"src/parser.y\"\n         {\n  (yyval.blk) = (yyvsp[0].blk);\n}\n#line 3802 \"src/parser.c\"\n    break;\n\n  case 155: /* DictPairs: DictPair ',' DictPairs  */\n#line 895 \"src/parser.y\"\n                       {\n  (yyval.blk) = block_join((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 3810 \"src/parser.c\"\n    break;\n\n  case 156: /* DictPair: IDENT ':' DictExpr  */\n#line 900 \"src/parser.y\"\n                   {\n  (yyval.blk) = gen_dictpair(gen_const((yyvsp[-2].literal)), (yyvsp[0].blk));\n}\n#line 3818 \"src/parser.c\"\n    break;\n\n  case 157: /* DictPair: Keyword ':' DictExpr  */\n#line 903 \"src/parser.y\"\n                     {\n  (yyval.blk) = gen_dictpair(gen_const((yyvsp[-2].literal)), (yyvsp[0].blk));\n}\n#line 3826 \"src/parser.c\"\n    break;\n\n  case 158: /* DictPair: String ':' DictExpr  */\n#line 906 \"src/parser.y\"\n                    {\n  (yyval.blk) = gen_dictpair((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 3834 \"src/parser.c\"\n    break;\n\n  case 159: /* DictPair: String  */\n#line 909 \"src/parser.y\"\n       {\n  (yyval.blk) = gen_dictpair((yyvsp[0].blk), BLOCK(gen_op_simple(POP), gen_op_simple(DUP2),\n                              gen_op_simple(DUP2), gen_op_simple(INDEX)));\n}\n#line 3843 \"src/parser.c\"\n    break;\n\n  case 160: /* DictPair: BINDING ':' DictExpr  */\n#line 913 \"src/parser.y\"\n                     {\n  (yyval.blk) = gen_dictpair(gen_location((yyloc), locations, gen_op_unbound(LOADV, jv_string_value((yyvsp[-2].literal)))),\n                    (yyvsp[0].blk));\n  jv_free((yyvsp[-2].literal));\n}\n#line 3853 \"src/parser.c\"\n    break;\n\n  case 161: /* DictPair: BINDING  */\n#line 918 \"src/parser.y\"\n        {\n  (yyval.blk) = gen_dictpair(gen_const((yyvsp[0].literal)),\n                    gen_location((yyloc), locations, gen_op_unbound(LOADV, jv_string_value((yyvsp[0].literal)))));\n}\n#line 3862 \"src/parser.c\"\n    break;\n\n  case 162: /* DictPair: IDENT  */\n#line 922 \"src/parser.y\"\n      {\n  (yyval.blk) = gen_dictpair(gen_const(jv_copy((yyvsp[0].literal))),\n                    gen_index(gen_noop(), gen_const((yyvsp[0].literal))));\n}\n#line 3871 \"src/parser.c\"\n    break;\n\n  case 163: /* DictPair: \"$__loc__\"  */\n#line 926 \"src/parser.y\"\n           {\n  (yyval.blk) = gen_dictpair(gen_const(jv_string(\"__loc__\")),\n                    gen_loc_object(&(yyloc), locations));\n}\n#line 3880 \"src/parser.c\"\n    break;\n\n  case 164: /* DictPair: Keyword  */\n#line 930 \"src/parser.y\"\n        {\n  (yyval.blk) = gen_dictpair(gen_const(jv_copy((yyvsp[0].literal))),\n                    gen_index(gen_noop(), gen_const((yyvsp[0].literal))));\n}\n#line 3889 \"src/parser.c\"\n    break;\n\n  case 165: /* DictPair: '(' Query ')' ':' DictExpr  */\n#line 934 \"src/parser.y\"\n                           {\n  jv msg = check_object_key((yyvsp[-3].blk));\n  if (jv_is_valid(msg)) {\n    FAIL((yylsp[-3]), jv_string_value(msg));\n  }\n  jv_free(msg);\n  (yyval.blk) = gen_dictpair((yyvsp[-3].blk), (yyvsp[0].blk));\n}\n#line 3902 \"src/parser.c\"\n    break;\n\n  case 166: /* DictPair: error ':' DictExpr  */\n#line 942 \"src/parser.y\"\n                   {\n  FAIL((yylsp[-2]), \"May need parentheses around object key expression\");\n  (yyval.blk) = (yyvsp[0].blk);\n}\n#line 3911 \"src/parser.c\"\n    break;\n\n  case 167: /* DictExpr: DictExpr '|' DictExpr  */\n#line 948 \"src/parser.y\"\n                      {\n  (yyval.blk) = block_join((yyvsp[-2].blk), (yyvsp[0].blk));\n}\n#line 3919 \"src/parser.c\"\n    break;\n\n  case 168: /* DictExpr: Expr  */\n#line 951 \"src/parser.y\"\n     {\n  (yyval.blk) = (yyvsp[0].blk);\n}\n#line 3927 \"src/parser.c\"\n    break;\n\n\n#line 3931 \"src/parser.c\"\n\n      default: break;\n    }\n  /* User semantic actions sometimes alter yychar, and that requires\n     that yytoken be updated with the new translation.  We take the\n     approach of translating immediately before every use of yytoken.\n     One alternative is translating here after every semantic action,\n     but that translation would be missed if the semantic action invokes\n     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or\n     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an\n     incorrect destructor might then be invoked immediately.  In the\n     case of YYERROR or YYBACKUP, subsequent parser actions might lead\n     to an incorrect destructor call or verbose syntax error message\n     before the lookahead is translated.  */\n  YY_SYMBOL_PRINT (\"-> $$ =\", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);\n\n  YYPOPSTACK (yylen);\n  yylen = 0;\n\n  *++yyvsp = yyval;\n  *++yylsp = yyloc;\n\n  /* Now 'shift' the result of the reduction.  Determine what state\n     that goes to, based on the state we popped back to and the rule\n     number reduced by.  */\n  {\n    const int yylhs = yyr1[yyn] - YYNTOKENS;\n    const int yyi = yypgoto[yylhs] + *yyssp;\n    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp\n               ? yytable[yyi]\n               : yydefgoto[yylhs]);\n  }\n\n  goto yynewstate;\n\n\n/*--------------------------------------.\n| yyerrlab -- here on detecting error.  |\n`--------------------------------------*/\nyyerrlab:\n  /* Make sure we have latest lookahead translation.  See comments at\n     user semantic actions for why this is necessary.  */\n  yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);\n  /* If not already recovering from an error, report this error.  */\n  if (!yyerrstatus)\n    {\n      ++yynerrs;\n      {\n        yypcontext_t yyctx\n          = {yyssp, yytoken, &yylloc};\n        char const *yymsgp = YY_(\"syntax error\");\n        int yysyntax_error_status;\n        yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);\n        if (yysyntax_error_status == 0)\n          yymsgp = yymsg;\n        else if (yysyntax_error_status == -1)\n          {\n            if (yymsg != yymsgbuf)\n              YYSTACK_FREE (yymsg);\n            yymsg = YY_CAST (char *,\n                             YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));\n            if (yymsg)\n              {\n                yysyntax_error_status\n                  = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);\n                yymsgp = yymsg;\n              }\n            else\n              {\n                yymsg = yymsgbuf;\n                yymsg_alloc = sizeof yymsgbuf;\n                yysyntax_error_status = YYENOMEM;\n              }\n          }\n        yyerror (&yylloc, answer, errors, locations, lexer_param_ptr, yymsgp);\n        if (yysyntax_error_status == YYENOMEM)\n          YYNOMEM;\n      }\n    }\n\n  yyerror_range[1] = yylloc;\n  if (yyerrstatus == 3)\n    {\n      /* If just tried and failed to reuse lookahead token after an\n         error, discard it.  */\n\n      if (yychar <= YYEOF)\n        {\n          /* Return failure if at end of input.  */\n          if (yychar == YYEOF)\n            YYABORT;\n        }\n      else\n        {\n          yydestruct (\"Error: discarding\",\n                      yytoken, &yylval, &yylloc, answer, errors, locations, lexer_param_ptr);\n          yychar = YYEMPTY;\n        }\n    }\n\n  /* Else will try to reuse lookahead token after shifting the error\n     token.  */\n  goto yyerrlab1;\n\n\n/*---------------------------------------------------.\n| yyerrorlab -- error raised explicitly by YYERROR.  |\n`---------------------------------------------------*/\nyyerrorlab:\n  /* Pacify compilers when the user code never invokes YYERROR and the\n     label yyerrorlab therefore never appears in user code.  */\n  if (0)\n    YYERROR;\n  ++yynerrs;\n\n  /* Do not reclaim the symbols of the rule whose action triggered\n     this YYERROR.  */\n  YYPOPSTACK (yylen);\n  yylen = 0;\n  YY_STACK_PRINT (yyss, yyssp);\n  yystate = *yyssp;\n  goto yyerrlab1;\n\n\n/*-------------------------------------------------------------.\n| yyerrlab1 -- common code for both syntax error and YYERROR.  |\n`-------------------------------------------------------------*/\nyyerrlab1:\n  yyerrstatus = 3;      /* Each real token shifted decrements this.  */\n\n  /* Pop stack until we find a state that shifts the error token.  */\n  for (;;)\n    {\n      yyn = yypact[yystate];\n      if (!yypact_value_is_default (yyn))\n        {\n          yyn += YYSYMBOL_YYerror;\n          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)\n            {\n              yyn = yytable[yyn];\n              if (0 < yyn)\n                break;\n            }\n        }\n\n      /* Pop the current state because it cannot handle the error token.  */\n      if (yyssp == yyss)\n        YYABORT;\n\n      yyerror_range[1] = *yylsp;\n      yydestruct (\"Error: popping\",\n                  YY_ACCESSING_SYMBOL (yystate), yyvsp, yylsp, answer, errors, locations, lexer_param_ptr);\n      YYPOPSTACK (1);\n      yystate = *yyssp;\n      YY_STACK_PRINT (yyss, yyssp);\n    }\n\n  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN\n  *++yyvsp = yylval;\n  YY_IGNORE_MAYBE_UNINITIALIZED_END\n\n  yyerror_range[2] = yylloc;\n  ++yylsp;\n  YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);\n\n  /* Shift the error token.  */\n  YY_SYMBOL_PRINT (\"Shifting\", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);\n\n  yystate = yyn;\n  goto yynewstate;\n\n\n/*-------------------------------------.\n| yyacceptlab -- YYACCEPT comes here.  |\n`-------------------------------------*/\nyyacceptlab:\n  yyresult = 0;\n  goto yyreturnlab;\n\n\n/*-----------------------------------.\n| yyabortlab -- YYABORT comes here.  |\n`-----------------------------------*/\nyyabortlab:\n  yyresult = 1;\n  goto yyreturnlab;\n\n\n/*-----------------------------------------------------------.\n| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here.  |\n`-----------------------------------------------------------*/\nyyexhaustedlab:\n  yyerror (&yylloc, answer, errors, locations, lexer_param_ptr, YY_(\"memory exhausted\"));\n  yyresult = 2;\n  goto yyreturnlab;\n\n\n/*----------------------------------------------------------.\n| yyreturnlab -- parsing is finished, clean up and return.  |\n`----------------------------------------------------------*/\nyyreturnlab:\n  if (yychar != YYEMPTY)\n    {\n      /* Make sure we have latest lookahead translation.  See comments at\n         user semantic actions for why this is necessary.  */\n      yytoken = YYTRANSLATE (yychar);\n      yydestruct (\"Cleanup: discarding lookahead\",\n                  yytoken, &yylval, &yylloc, answer, errors, locations, lexer_param_ptr);\n    }\n  /* Do not reclaim the symbols of the rule whose action triggered\n     this YYABORT or YYACCEPT.  */\n  YYPOPSTACK (yylen);\n  YY_STACK_PRINT (yyss, yyssp);\n  while (yyssp != yyss)\n    {\n      yydestruct (\"Cleanup: popping\",\n                  YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yylsp, answer, errors, locations, lexer_param_ptr);\n      YYPOPSTACK (1);\n    }\n#ifndef yyoverflow\n  if (yyss != yyssa)\n    YYSTACK_FREE (yyss);\n#endif\n  if (yymsg != yymsgbuf)\n    YYSTACK_FREE (yymsg);\n  return yyresult;\n}\n\n#line 954 \"src/parser.y\"\n\n\nint jq_parse(struct locfile* locations, block* answer) {\n  struct lexer_param scanner;\n  YY_BUFFER_STATE buf;\n  jq_yylex_init_extra(0, &scanner.lexer);\n  buf = jq_yy_scan_bytes(locations->data, locations->length, scanner.lexer);\n  int errors = 0;\n  *answer = gen_noop();\n  yyparse(answer, &errors, locations, &scanner);\n  jq_yy_delete_buffer(buf, scanner.lexer);\n  jq_yylex_destroy(scanner.lexer);\n  if (errors > 0) {\n    block_free(*answer);\n    *answer = gen_noop();\n  }\n  return errors;\n}\n\nint jq_parse_library(struct locfile* locations, block* answer) {\n  int errs = jq_parse(locations, answer);\n  if (errs) return errs;\n  if (block_has_main(*answer)) {\n    locfile_locate(locations, UNKNOWN_LOCATION, \"jq: error: library should only have function definitions, not a main expression\");\n    return 1;\n  }\n  assert(block_has_only_binders_and_imports(*answer, OP_IS_CALL_PSEUDO));\n  return 0;\n}\n"
  },
  {
    "path": "src/parser.h",
    "content": "/* A Bison parser, made by GNU Bison 3.8.2.  */\n\n/* Bison interface for Yacc-like parsers in C\n\n   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,\n   Inc.\n\n   This program is free software: you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */\n\n/* As a special exception, you may create a larger work that contains\n   part or all of the Bison parser skeleton and distribute that work\n   under terms of your choice, so long as that work isn't itself a\n   parser generator using the skeleton or a modified version thereof\n   as a parser skeleton.  Alternatively, if you modify or redistribute\n   the parser skeleton itself, you may (at your option) remove this\n   special exception, which will cause the skeleton and the resulting\n   Bison output files to be licensed under the GNU General Public\n   License without this special exception.\n\n   This special exception was added by the Free Software Foundation in\n   version 2.2 of Bison.  */\n\n/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,\n   especially those whose name start with YY_ or yy_.  They are\n   private implementation details that can be changed or removed.  */\n\n#ifndef YY_YY_SRC_PARSER_H_INCLUDED\n# define YY_YY_SRC_PARSER_H_INCLUDED\n/* Debug traces.  */\n#ifndef YYDEBUG\n# define YYDEBUG 0\n#endif\n#if YYDEBUG\nextern int yydebug;\n#endif\n/* \"%code requires\" blocks.  */\n#line 12 \"src/parser.y\"\n\n#include \"locfile.h\"\nstruct lexer_param;\n\n#define YYLTYPE location\n#define YYLLOC_DEFAULT(Loc, Rhs, N)             \\\n  do {                                          \\\n    if (N) {                                    \\\n      (Loc).start = YYRHSLOC(Rhs, 1).start;     \\\n      (Loc).end = YYRHSLOC(Rhs, N).end;         \\\n    } else {                                    \\\n      (Loc).start = YYRHSLOC(Rhs, 0).end;       \\\n      (Loc).end = YYRHSLOC(Rhs, 0).end;         \\\n    }                                           \\\n  } while (0)\n\n#line 66 \"src/parser.h\"\n\n/* Token kinds.  */\n#ifndef YYTOKENTYPE\n# define YYTOKENTYPE\n  enum yytokentype\n  {\n    YYEMPTY = -2,\n    YYEOF = 0,                     /* \"end of file\"  */\n    YYerror = 256,                 /* error  */\n    YYUNDEF = 257,                 /* \"invalid token\"  */\n    INVALID_CHARACTER = 258,       /* INVALID_CHARACTER  */\n    IDENT = 259,                   /* IDENT  */\n    FIELD = 260,                   /* FIELD  */\n    BINDING = 261,                 /* BINDING  */\n    LITERAL = 262,                 /* LITERAL  */\n    FORMAT = 263,                  /* FORMAT  */\n    REC = 264,                     /* \"..\"  */\n    SETMOD = 265,                  /* \"%=\"  */\n    EQ = 266,                      /* \"==\"  */\n    NEQ = 267,                     /* \"!=\"  */\n    DEFINEDOR = 268,               /* \"//\"  */\n    AS = 269,                      /* \"as\"  */\n    DEF = 270,                     /* \"def\"  */\n    MODULE = 271,                  /* \"module\"  */\n    IMPORT = 272,                  /* \"import\"  */\n    INCLUDE = 273,                 /* \"include\"  */\n    IF = 274,                      /* \"if\"  */\n    THEN = 275,                    /* \"then\"  */\n    ELSE = 276,                    /* \"else\"  */\n    ELSE_IF = 277,                 /* \"elif\"  */\n    REDUCE = 278,                  /* \"reduce\"  */\n    FOREACH = 279,                 /* \"foreach\"  */\n    END = 280,                     /* \"end\"  */\n    AND = 281,                     /* \"and\"  */\n    OR = 282,                      /* \"or\"  */\n    TRY = 283,                     /* \"try\"  */\n    CATCH = 284,                   /* \"catch\"  */\n    LABEL = 285,                   /* \"label\"  */\n    BREAK = 286,                   /* \"break\"  */\n    LOC = 287,                     /* \"$__loc__\"  */\n    SETPIPE = 288,                 /* \"|=\"  */\n    SETPLUS = 289,                 /* \"+=\"  */\n    SETMINUS = 290,                /* \"-=\"  */\n    SETMULT = 291,                 /* \"*=\"  */\n    SETDIV = 292,                  /* \"/=\"  */\n    SETDEFINEDOR = 293,            /* \"//=\"  */\n    LESSEQ = 294,                  /* \"<=\"  */\n    GREATEREQ = 295,               /* \">=\"  */\n    ALTERNATION = 296,             /* \"?//\"  */\n    QQSTRING_START = 297,          /* QQSTRING_START  */\n    QQSTRING_TEXT = 298,           /* QQSTRING_TEXT  */\n    QQSTRING_INTERP_START = 299,   /* QQSTRING_INTERP_START  */\n    QQSTRING_INTERP_END = 300,     /* QQSTRING_INTERP_END  */\n    QQSTRING_END = 301,            /* QQSTRING_END  */\n    FUNCDEF = 302,                 /* FUNCDEF  */\n    NONOPT = 303                   /* NONOPT  */\n  };\n  typedef enum yytokentype yytoken_kind_t;\n#endif\n/* Token kinds.  */\n#define YYEMPTY -2\n#define YYEOF 0\n#define YYerror 256\n#define YYUNDEF 257\n#define INVALID_CHARACTER 258\n#define IDENT 259\n#define FIELD 260\n#define BINDING 261\n#define LITERAL 262\n#define FORMAT 263\n#define REC 264\n#define SETMOD 265\n#define EQ 266\n#define NEQ 267\n#define DEFINEDOR 268\n#define AS 269\n#define DEF 270\n#define MODULE 271\n#define IMPORT 272\n#define INCLUDE 273\n#define IF 274\n#define THEN 275\n#define ELSE 276\n#define ELSE_IF 277\n#define REDUCE 278\n#define FOREACH 279\n#define END 280\n#define AND 281\n#define OR 282\n#define TRY 283\n#define CATCH 284\n#define LABEL 285\n#define BREAK 286\n#define LOC 287\n#define SETPIPE 288\n#define SETPLUS 289\n#define SETMINUS 290\n#define SETMULT 291\n#define SETDIV 292\n#define SETDEFINEDOR 293\n#define LESSEQ 294\n#define GREATEREQ 295\n#define ALTERNATION 296\n#define QQSTRING_START 297\n#define QQSTRING_TEXT 298\n#define QQSTRING_INTERP_START 299\n#define QQSTRING_INTERP_END 300\n#define QQSTRING_END 301\n#define FUNCDEF 302\n#define NONOPT 303\n\n/* Value type.  */\n#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED\nunion YYSTYPE\n{\n#line 32 \"src/parser.y\"\n\n  jv literal;\n  block blk;\n\n#line 187 \"src/parser.h\"\n\n};\ntypedef union YYSTYPE YYSTYPE;\n# define YYSTYPE_IS_TRIVIAL 1\n# define YYSTYPE_IS_DECLARED 1\n#endif\n\n/* Location type.  */\n#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED\ntypedef struct YYLTYPE YYLTYPE;\nstruct YYLTYPE\n{\n  int first_line;\n  int first_column;\n  int last_line;\n  int last_column;\n};\n# define YYLTYPE_IS_DECLARED 1\n# define YYLTYPE_IS_TRIVIAL 1\n#endif\n\n\n\n\nint yyparse (block* answer, int* errors, struct locfile* locations, struct lexer_param* lexer_param_ptr);\n\n\n#endif /* !YY_YY_SRC_PARSER_H_INCLUDED  */\n"
  },
  {
    "path": "src/parser.y",
    "content": "%{\n#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n#include <string.h>\n#include \"compile.h\"\n#include \"jv_alloc.h\"\n#include \"builtin.h\"\n#define YYMALLOC jv_mem_alloc\n#define YYFREE jv_mem_free\n%}\n%code requires {\n#include \"locfile.h\"\nstruct lexer_param;\n\n#define YYLTYPE location\n#define YYLLOC_DEFAULT(Loc, Rhs, N)             \\\n  do {                                          \\\n    if (N) {                                    \\\n      (Loc).start = YYRHSLOC(Rhs, 1).start;     \\\n      (Loc).end = YYRHSLOC(Rhs, N).end;         \\\n    } else {                                    \\\n      (Loc).start = YYRHSLOC(Rhs, 0).end;       \\\n      (Loc).end = YYRHSLOC(Rhs, 0).end;         \\\n    }                                           \\\n  } while (0)\n}\n\n%locations\n%define parse.error verbose\n%define api.pure\n%union {\n  jv literal;\n  block blk;\n}\n\n%destructor { jv_free($$); } <literal>\n%destructor { block_free($$); } <blk>\n\n%parse-param {block* answer}\n%parse-param {int* errors}\n%parse-param {struct locfile* locations}\n%parse-param {struct lexer_param* lexer_param_ptr}\n%lex-param {block* answer}\n%lex-param {int* errors}\n%lex-param {struct locfile* locations}\n%lex-param {struct lexer_param* lexer_param_ptr}\n\n\n%token INVALID_CHARACTER\n%token <literal> IDENT\n%token <literal> FIELD\n%token <literal> BINDING\n%token <literal> LITERAL\n%token <literal> FORMAT\n%token REC \"..\"\n%token SETMOD \"%=\"\n%token EQ \"==\"\n%token NEQ \"!=\"\n%token DEFINEDOR \"//\"\n%token AS \"as\"\n%token DEF \"def\"\n%token MODULE \"module\"\n%token IMPORT \"import\"\n%token INCLUDE \"include\"\n%token IF \"if\"\n%token THEN \"then\"\n%token ELSE \"else\"\n%token ELSE_IF \"elif\"\n%token REDUCE \"reduce\"\n%token FOREACH \"foreach\"\n%token END \"end\"\n%token AND \"and\"\n%token OR \"or\"\n%token TRY \"try\"\n%token CATCH \"catch\"\n%token LABEL \"label\"\n%token BREAK \"break\"\n%token LOC \"$__loc__\"\n%token SETPIPE \"|=\"\n%token SETPLUS \"+=\"\n%token SETMINUS \"-=\"\n%token SETMULT \"*=\"\n%token SETDIV \"/=\"\n%token SETDEFINEDOR \"//=\"\n%token LESSEQ \"<=\"\n%token GREATEREQ \">=\"\n%token ALTERNATION \"?//\"\n\n%token QQSTRING_START\n%token <literal> QQSTRING_TEXT\n%token QQSTRING_INTERP_START\n%token QQSTRING_INTERP_END\n%token QQSTRING_END\n\n/* Instead of raising this, find a way to use precedence to resolve\n * shift-reduce conflicts. */\n%expect 0\n\n%precedence FUNCDEF\n%right '|'\n%left ','\n%right \"//\"\n%nonassoc '=' SETPIPE SETPLUS SETMINUS SETMULT SETDIV SETMOD SETDEFINEDOR\n%left OR\n%left AND\n%nonassoc NEQ EQ '<' '>' LESSEQ GREATEREQ\n%left '+' '-'\n%left '*' '/' '%'\n%precedence NONOPT /* non-optional; rules for which a specialized\n                      '?' rule should be preferred over Expr '?' */\n%precedence '?' '.' '[' FIELD\n%precedence \"try\"\n%precedence \"catch\"\n\n\n%type <blk> Query Expr Term\n%type <blk> DictPairs DictPair DictExpr\n%type <blk> ElseBody\n%type <blk> String QQString\n%type <blk> FuncDef FuncDefs\n%type <blk> Module Import Imports ImportWhat ImportFrom\n%type <blk> Param Params Arg Args\n%type <blk> Patterns RepPatterns Pattern ArrayPats ObjPats ObjPat\n%type <literal> Keyword\n%type <literal> StringStart\n%{\n#include \"lexer.h\"\nstruct lexer_param {\n  yyscan_t lexer;\n};\n#define FAIL(loc, msg)                                             \\\n  do {                                                             \\\n    location l = loc;                                              \\\n    yyerror(&l, answer, errors, locations, lexer_param_ptr, msg);  \\\n    /*YYERROR*/;                                                   \\\n  } while (0)\n\nvoid yyerror(YYLTYPE* loc, block* answer, int* errors,\n             struct locfile* locations, struct lexer_param* lexer_param_ptr, const char *s){\n  (*errors)++;\n  locfile_locate(locations, *loc, \"jq: error: %s\", s);\n}\n\nint yylex(YYSTYPE* yylval, YYLTYPE* yylloc, block* answer, int* errors,\n          struct locfile* locations, struct lexer_param* lexer_param_ptr) {\n  yyscan_t lexer = lexer_param_ptr->lexer;\n  int tok = jq_yylex(yylval, yylloc, lexer);\n  if ((tok == LITERAL || tok == QQSTRING_TEXT) && !jv_is_valid(yylval->literal)) {\n    jv msg = jv_invalid_get_msg(jv_copy(yylval->literal));\n    if (jv_get_kind(msg) == JV_KIND_STRING) {\n      FAIL(*yylloc, jv_string_value(msg));\n    } else {\n      FAIL(*yylloc, \"Invalid literal\");\n    }\n    jv_free(msg);\n    jv_free(yylval->literal);\n    yylval->literal = jv_null();\n  }\n  return tok;\n}\n\n/* Returns string message if the block is a constant that is not valid as an\n * object key. */\nstatic jv check_object_key(block k) {\n  if (block_is_const(k) && block_const_kind(k) != JV_KIND_STRING) {\n    char errbuf[30];\n    return jv_string_fmt(\"Cannot use %s (%s) as object key\",\n        jv_kind_name(block_const_kind(k)),\n        jv_dump_string_trunc(block_const(k), errbuf, sizeof(errbuf)));\n  }\n  return jv_invalid();\n}\n\nstatic block gen_index(block obj, block key) {\n  return BLOCK(gen_subexp(key), obj, gen_op_simple(INDEX));\n}\n\nstatic block gen_index_opt(block obj, block key) {\n  return BLOCK(gen_subexp(key), obj, gen_op_simple(INDEX_OPT));\n}\n\nstatic block gen_slice_index(block obj, block start, block end, opcode idx_op) {\n  block key = BLOCK(gen_subexp(gen_const(jv_object())),\n                    gen_subexp(gen_const(jv_string(\"start\"))),\n                    gen_subexp(start),\n                    gen_op_simple(INSERT),\n                    gen_subexp(gen_const(jv_string(\"end\"))),\n                    gen_subexp(end),\n                    gen_op_simple(INSERT));\n  return BLOCK(key, obj, gen_op_simple(idx_op));\n}\n\nstatic block constant_fold(block a, block b, int op) {\n  if (!block_is_single(a) || !block_is_const(a) ||\n      !block_is_single(b) || !block_is_const(b))\n    return gen_noop();\n\n  jv jv_a = block_const(a);\n  block_free(a);\n  jv jv_b = block_const(b);\n  block_free(b);\n\n  jv res = jv_invalid();\n  switch (op) {\n  case '+': res = binop_plus(jv_a, jv_b); break;\n  case '-': res = binop_minus(jv_a, jv_b); break;\n  case '*': res = binop_multiply(jv_a, jv_b); break;\n  case '/': res = binop_divide(jv_a, jv_b); break;\n  case '%': res = binop_mod(jv_a, jv_b); break;\n  case EQ: res = binop_equal(jv_a, jv_b); break;\n  case NEQ: res = binop_notequal(jv_a, jv_b); break;\n  case '<': res = binop_less(jv_a, jv_b); break;\n  case '>': res = binop_greater(jv_a, jv_b); break;\n  case LESSEQ: res = binop_lesseq(jv_a, jv_b); break;\n  case GREATEREQ: res = binop_greatereq(jv_a, jv_b); break;\n  }\n\n  if (jv_is_valid(res))\n    return gen_const(res);\n\n  return gen_error(jv_invalid_get_msg(res));\n}\n\nstatic block gen_binop(block a, block b, int op) {\n  block folded = constant_fold(a, b, op);\n  if (!block_is_noop(folded))\n    return folded;\n\n  const char* funcname = 0;\n  switch (op) {\n  case '+': funcname = \"_plus\"; break;\n  case '-': funcname = \"_minus\"; break;\n  case '*': funcname = \"_multiply\"; break;\n  case '/': funcname = \"_divide\"; break;\n  case '%': funcname = \"_mod\"; break;\n  case EQ: funcname = \"_equal\"; break;\n  case NEQ: funcname = \"_notequal\"; break;\n  case '<': funcname = \"_less\"; break;\n  case '>': funcname = \"_greater\"; break;\n  case LESSEQ: funcname = \"_lesseq\"; break;\n  case GREATEREQ: funcname = \"_greatereq\"; break;\n  }\n  assert(funcname);\n\n  return gen_call(funcname, BLOCK(gen_lambda(a), gen_lambda(b)));\n}\n\nstatic block gen_format(block a, jv fmt) {\n  return BLOCK(a, gen_call(\"format\", gen_lambda(gen_const(fmt))));\n}\n\nstatic block gen_definedor_assign(block object, block val) {\n  block tmp = gen_op_var_fresh(STOREV, \"tmp\");\n  return BLOCK(gen_op_simple(DUP),\n               val, tmp,\n               gen_call(\"_modify\", BLOCK(gen_lambda(object),\n                                         gen_lambda(gen_definedor(gen_noop(),\n                                                                  gen_op_bound(LOADV, tmp))))));\n}\n\nstatic block gen_update(block object, block val, int optype) {\n  block tmp = gen_op_var_fresh(STOREV, \"tmp\");\n  return BLOCK(gen_op_simple(DUP),\n               val,\n               tmp,\n               gen_call(\"_modify\", BLOCK(gen_lambda(object),\n                                         gen_lambda(gen_binop(gen_noop(),\n                                                              gen_op_bound(LOADV, tmp),\n                                                              optype)))));\n}\n\nstatic block gen_loc_object(location *loc, struct locfile *locations) {\n  return gen_const(JV_OBJECT(jv_string(\"file\"), jv_copy(locations->fname),\n                             jv_string(\"line\"), jv_number(locfile_get_line(locations, loc->start) + 1)));\n}\n\n%}\n\n%%\nTopLevel:\nModule Imports Query {\n  *answer = BLOCK($1, $2, gen_op_simple(TOP), $3);\n} |\nModule Imports FuncDefs {\n  *answer = BLOCK($1, $2, $3);\n}\n\nModule:\n%empty {\n  $$ = gen_noop();\n} |\n\"module\" Query ';' {\n  if (!block_is_const($2)) {\n    FAIL(@2, \"Module metadata must be constant\");\n    $$ = gen_noop();\n    block_free($2);\n  } else if (block_const_kind($2) != JV_KIND_OBJECT) {\n    FAIL(@2, \"Module metadata must be an object\");\n    $$ = gen_noop();\n    block_free($2);\n  } else {\n    $$ = gen_module($2);\n  }\n}\n\nImports:\n%empty {\n  $$ = gen_noop();\n} |\nImport Imports {\n  $$ = BLOCK($1, $2);\n}\n\nFuncDefs:\n%empty {\n  $$ = gen_noop();\n} |\nFuncDef FuncDefs {\n  $$ = block_join($1, $2);\n}\n\n\nQuery:\nFuncDef Query %prec FUNCDEF {\n  $$ = block_bind_referenced($1, $2, OP_IS_CALL_PSEUDO);\n} |\nExpr \"as\" Patterns '|' Query {\n  $$ = gen_destructure($1, $3, $5);\n} |\n\"label\" BINDING '|' Query {\n  jv v = jv_string_fmt(\"*label-%s\", jv_string_value($2));\n  $$ = gen_location(@$, locations, gen_label(jv_string_value(v), $4));\n  jv_free($2);\n  jv_free(v);\n} |\nQuery '|' Query {\n  $$ = block_join($1, $3);\n} |\nQuery ',' Query {\n  $$ = gen_both($1, $3);\n} |\nExpr {\n  $$ = $1;\n}\n\n\nExpr:\nExpr \"//\" Expr {\n  $$ = gen_definedor($1, $3);\n} |\nExpr '=' Expr {\n  $$ = gen_call(\"_assign\", BLOCK(gen_lambda($1), gen_lambda($3)));\n} |\nExpr \"or\" Expr {\n  $$ = gen_or($1, $3);\n} |\nExpr \"and\" Expr {\n  $$ = gen_and($1, $3);\n} |\nExpr \"//=\" Expr {\n  $$ = gen_definedor_assign($1, $3);\n} |\nExpr \"|=\" Expr {\n  $$ = gen_call(\"_modify\", BLOCK(gen_lambda($1), gen_lambda($3)));\n} |\nExpr '+' Expr {\n  $$ = gen_binop($1, $3, '+');\n} |\nExpr \"+=\" Expr {\n  $$ = gen_update($1, $3, '+');\n} |\nExpr '-' Expr {\n  $$ = gen_binop($1, $3, '-');\n} |\nExpr \"-=\" Expr {\n  $$ = gen_update($1, $3, '-');\n} |\nExpr '*' Expr {\n  $$ = gen_binop($1, $3, '*');\n} |\nExpr \"*=\" Expr {\n  $$ = gen_update($1, $3, '*');\n} |\nExpr '/' Expr {\n  $$ = gen_binop($1, $3, '/');\n} |\nExpr '%' Expr {\n  $$ = gen_binop($1, $3, '%');\n} |\nExpr \"/=\" Expr {\n  $$ = gen_update($1, $3, '/');\n} |\nExpr SETMOD Expr {\n  $$ = gen_update($1, $3, '%');\n} |\nExpr \"==\" Expr {\n  $$ = gen_binop($1, $3, EQ);\n} |\nExpr \"!=\" Expr {\n  $$ = gen_binop($1, $3, NEQ);\n} |\nExpr '<' Expr {\n  $$ = gen_binop($1, $3, '<');\n} |\nExpr '>' Expr {\n  $$ = gen_binop($1, $3, '>');\n} |\nExpr \"<=\" Expr {\n  $$ = gen_binop($1, $3, LESSEQ);\n} |\nExpr \">=\" Expr {\n  $$ = gen_binop($1, $3, GREATEREQ);\n} |\nTerm %prec NONOPT {\n  $$ = $1;\n}\n\n\nImport:\nImportWhat ';' {\n  $$ = $1;\n} |\nImportWhat Query ';' {\n  if (!block_is_const($2)) {\n    FAIL(@2, \"Module metadata must be constant\");\n    $$ = gen_noop();\n    block_free($1);\n    block_free($2);\n  } else if (block_const_kind($2) != JV_KIND_OBJECT) {\n    FAIL(@2, \"Module metadata must be an object\");\n    $$ = gen_noop();\n    block_free($1);\n    block_free($2);\n  } else {\n    $$ = gen_import_meta($1, $2);\n  }\n}\n\nImportWhat:\n\"import\" ImportFrom \"as\" BINDING {\n  jv v = block_const($2);\n  // XXX Make gen_import take only blocks and the int is_data so we\n  // don't have to free so much stuff here\n  $$ = gen_import(jv_string_value(v), jv_string_value($4), 1);\n  block_free($2);\n  jv_free($4);\n  jv_free(v);\n} |\n\"import\" ImportFrom \"as\" IDENT {\n  jv v = block_const($2);\n  $$ = gen_import(jv_string_value(v), jv_string_value($4), 0);\n  block_free($2);\n  jv_free($4);\n  jv_free(v);\n} |\n\"include\" ImportFrom {\n  jv v = block_const($2);\n  $$ = gen_import(jv_string_value(v), NULL, 0);\n  block_free($2);\n  jv_free(v);\n}\n\nImportFrom:\nString {\n  if (!block_is_const($1)) {\n    FAIL(@1, \"Import path must be constant\");\n    $$ = gen_const(jv_string(\"\"));\n    block_free($1);\n  } else {\n    $$ = $1;\n  }\n}\n\nFuncDef:\n\"def\" IDENT ':' Query ';' {\n  $$ = gen_function(jv_string_value($2), gen_noop(), $4);\n  jv_free($2);\n} |\n\n\"def\" IDENT '(' Params ')' ':' Query ';' {\n  $$ = gen_function(jv_string_value($2), $4, $7);\n  jv_free($2);\n}\n\nParams:\nParam {\n  $$ = $1;\n} |\nParams ';' Param {\n  $$ = BLOCK($1, $3);\n}\n\nParam:\nBINDING {\n  $$ = gen_param_regular(jv_string_value($1));\n  jv_free($1);\n} |\nIDENT {\n  $$ = gen_param(jv_string_value($1));\n  jv_free($1);\n}\n\n\nStringStart:\nFORMAT QQSTRING_START {\n  $$ = $1;\n} |\nQQSTRING_START {\n  $$ = jv_string(\"text\");\n}\n\n\nString:\nStringStart QQString QQSTRING_END {\n  $$ = $2;\n  jv_free($1);\n};\n\n\nQQString:\n%empty {\n  $$ = gen_const(jv_string(\"\"));\n} |\nQQString QQSTRING_TEXT {\n  $$ = gen_binop($1, gen_const($2), '+');\n} |\nQQString QQSTRING_INTERP_START Query QQSTRING_INTERP_END {\n  $$ = gen_binop($1, gen_format($3, jv_copy($<literal>0)), '+');\n}\n\n\nElseBody:\n\"elif\" Query \"then\" Query ElseBody {\n  $$ = gen_cond($2, $4, $5);\n} |\n\"else\" Query \"end\" {\n  $$ = $2;\n} |\n\"end\" {\n  $$ = gen_noop();\n}\n\n\nTerm:\n'.' {\n  $$ = gen_noop();\n} |\nREC {\n  $$ = gen_call(\"recurse\", gen_noop());\n} |\nBREAK BINDING {\n  jv v = jv_string_fmt(\"*label-%s\", jv_string_value($2));     // impossible symbol\n  $$ = gen_location(@$, locations,\n                    BLOCK(gen_op_unbound(LOADV, jv_string_value(v)),\n                    gen_call(\"error\", gen_noop())));\n  jv_free(v);\n  jv_free($2);\n} |\nBREAK error {\n  FAIL(@$, \"break requires a label to break to\");\n  $$ = gen_noop();\n} |\nTerm FIELD '?' {\n  $$ = gen_index_opt($1, gen_const($2));\n} |\nFIELD '?' {\n  $$ = gen_index_opt(gen_noop(), gen_const($1));\n} |\nTerm '.' String '?' {\n  $$ = gen_index_opt($1, $3);\n} |\n'.' String '?' {\n  $$ = gen_index_opt(gen_noop(), $2);\n} |\nTerm FIELD %prec NONOPT {\n  $$ = gen_index($1, gen_const($2));\n} |\nFIELD %prec NONOPT {\n  $$ = gen_index(gen_noop(), gen_const($1));\n} |\nTerm '.' String %prec NONOPT {\n  $$ = gen_index($1, $3);\n} |\n'.' String %prec NONOPT {\n  $$ = gen_index(gen_noop(), $2);\n} |\n'.' error {\n  FAIL(@$, \"try .[\\\"field\\\"] instead of .field for unusually named fields\");\n  $$ = gen_noop();\n} |\n'.' IDENT error {\n  jv_free($2);\n  FAIL(@$, \"try .[\\\"field\\\"] instead of .field for unusually named fields\");\n  $$ = gen_noop();\n} |\n/* FIXME: string literals */\nTerm '[' Query ']' '?' {\n  $$ = gen_index_opt($1, $3);\n} |\nTerm '[' Query ']' %prec NONOPT {\n  $$ = gen_index($1, $3);\n} |\nTerm '.' '[' Query ']' '?' {\n  $$ = gen_index_opt($1, $4);\n} |\nTerm '.' '[' Query ']' %prec NONOPT {\n  $$ = gen_index($1, $4);\n} |\nTerm '[' ']' '?' {\n  $$ = block_join($1, gen_op_simple(EACH_OPT));\n} |\nTerm '[' ']' %prec NONOPT {\n  $$ = block_join($1, gen_op_simple(EACH));\n} |\nTerm '.' '[' ']' '?' {\n  $$ = block_join($1, gen_op_simple(EACH_OPT));\n} |\nTerm '.' '[' ']' %prec NONOPT {\n  $$ = block_join($1, gen_op_simple(EACH));\n} |\nTerm '[' Query ':' Query ']' '?' {\n  $$ = gen_slice_index($1, $3, $5, INDEX_OPT);\n} |\nTerm '[' Query ':' ']' '?' {\n  $$ = gen_slice_index($1, $3, gen_const(jv_null()), INDEX_OPT);\n} |\nTerm '[' ':' Query ']' '?' {\n  $$ = gen_slice_index($1, gen_const(jv_null()), $4, INDEX_OPT);\n} |\nTerm '[' Query ':' Query ']' %prec NONOPT {\n  $$ = gen_slice_index($1, $3, $5, INDEX);\n} |\nTerm '[' Query ':' ']' %prec NONOPT {\n  $$ = gen_slice_index($1, $3, gen_const(jv_null()), INDEX);\n} |\nTerm '[' ':' Query ']' %prec NONOPT {\n  $$ = gen_slice_index($1, gen_const(jv_null()), $4, INDEX);\n} |\nTerm '?' {\n  $$ = gen_try($1, gen_op_simple(BACKTRACK));\n} |\nLITERAL {\n  $$ = gen_const($1);\n} |\nString {\n  $$ = $1;\n} |\nFORMAT {\n  $$ = gen_format(gen_noop(), $1);\n} |\n'-' Term {\n  $$ = BLOCK($2, gen_call(\"_negate\", gen_noop()));\n} |\n'(' Query ')' {\n  $$ = $2;\n} |\n'[' Query ']' {\n  $$ = gen_collect($2);\n} |\n'[' ']' {\n  $$ = gen_const(jv_array());\n} |\n'{' DictPairs '}' {\n  block o = gen_const_object($2);\n  if (o.first != NULL)\n    $$ = o;\n  else\n    $$ = BLOCK(gen_subexp(gen_const(jv_object())), $2, gen_op_simple(POP));\n} |\n\"reduce\" Expr \"as\" Patterns '(' Query ';' Query ')' {\n  $$ = gen_reduce($2, $4, $6, $8);\n} |\n\"foreach\" Expr \"as\" Patterns '(' Query ';' Query ';' Query ')' {\n  $$ = gen_foreach($2, $4, $6, $8, $10);\n} |\n\"foreach\" Expr \"as\" Patterns '(' Query ';' Query ')' {\n  $$ = gen_foreach($2, $4, $6, $8, gen_noop());\n} |\n\"if\" Query \"then\" Query ElseBody {\n  $$ = gen_cond($2, $4, $5);\n} |\n\"if\" Query \"then\" error {\n  FAIL(@$, \"Possibly unterminated 'if' statement\");\n  $$ = $2;\n} |\n\"try\" Expr \"catch\" Expr {\n  $$ = gen_try($2, $4);\n} |\n\"try\" Expr \"catch\" error {\n  FAIL(@$, \"Possibly unterminated 'try' statement\");\n  $$ = $2;\n} |\n\"try\" Expr {\n  $$ = gen_try($2, gen_op_simple(BACKTRACK));\n} |\n/*\n * This `$$$$varname` hack is strictly private to jq builtins.  DO NOT USE!!\n *\n * This is used in `_modify`, in src/builtin.jq, to avoid holding on to a\n * reference to `.`.\n *\n * We could just have the compiler emit bytecode for `_modify` so it can use\n * LOADVN w/o needing jq syntax for LOADVN.\n *\n * This syntax, `$$$$varname`, violates referential transparency: it has\n * side-effects that are surprising.\n *\n * DO NOT USE!!  I will break your jq code if you do use this outside\n * src/builtin.jq.\n */\n'$' '$' '$' BINDING {\n  $$ = gen_location(@$, locations, gen_op_unbound(LOADVN, jv_string_value($4)));\n  jv_free($4);\n} |\nBINDING {\n  $$ = gen_location(@$, locations, gen_op_unbound(LOADV, jv_string_value($1)));\n  jv_free($1);\n} |\n\"$__loc__\" {\n  $$ = gen_loc_object(&@$, locations);\n} |\nIDENT {\n  const char *s = jv_string_value($1);\n  if (strcmp(s, \"false\") == 0)\n    $$ = gen_const(jv_false());\n  else if (strcmp(s, \"true\") == 0)\n    $$ = gen_const(jv_true());\n  else if (strcmp(s, \"null\") == 0)\n    $$ = gen_const(jv_null());\n  else\n    $$ = gen_location(@$, locations, gen_call(s, gen_noop()));\n  jv_free($1);\n} |\nIDENT '(' Args ')' {\n  $$ = gen_call(jv_string_value($1), $3);\n  $$ = gen_location(@1, locations, $$);\n  jv_free($1);\n} |\n'(' error ')' { $$ = gen_noop(); } |\n'[' error ']' { $$ = gen_noop(); } |\nTerm '[' error ']' { $$ = $1; } |\n'{' error '}' { $$ = gen_noop(); }\n\nArgs:\nArg {\n  $$ = $1;\n} |\nArgs ';' Arg {\n  $$ = BLOCK($1, $3);\n}\n\nArg:\nQuery {\n  $$ = gen_lambda($1);\n}\n\nRepPatterns:\nRepPatterns \"?//\" Pattern {\n  $$ = BLOCK($1, gen_destructure_alt($3));\n} |\nPattern {\n  $$ = gen_destructure_alt($1);\n}\n\nPatterns:\nRepPatterns \"?//\" Pattern {\n  $$ = BLOCK($1, $3);\n} |\nPattern {\n  $$ = $1;\n}\n\nPattern:\nBINDING {\n  $$ = gen_op_unbound(STOREV, jv_string_value($1));\n  jv_free($1);\n} |\n'[' ArrayPats ']' {\n  $$ = BLOCK($2, gen_op_simple(POP));\n} |\n'{' ObjPats '}' {\n  $$ = BLOCK($2, gen_op_simple(POP));\n}\n\nArrayPats:\nPattern {\n  $$ = gen_array_matcher(gen_noop(), $1);\n} |\nArrayPats ',' Pattern {\n  $$ = gen_array_matcher($1, $3);\n}\n\nObjPats:\nObjPat {\n  $$ = $1;\n} |\nObjPats ',' ObjPat {\n  $$ = BLOCK($1, $3);\n}\n\nObjPat:\nBINDING {\n  $$ = gen_object_matcher(gen_const($1), gen_op_unbound(STOREV, jv_string_value($1)));\n} |\nBINDING ':' Pattern {\n  $$ = gen_object_matcher(gen_const($1), BLOCK(gen_op_simple(DUP), gen_op_unbound(STOREV, jv_string_value($1)), $3));\n} |\nIDENT ':' Pattern {\n  $$ = gen_object_matcher(gen_const($1), $3);\n} |\nKeyword ':' Pattern {\n  $$ = gen_object_matcher(gen_const($1), $3);\n} |\nString ':' Pattern {\n  $$ = gen_object_matcher($1, $3);\n} |\n'(' Query ')' ':' Pattern {\n  jv msg = check_object_key($2);\n  if (jv_is_valid(msg)) {\n    FAIL(@2, jv_string_value(msg));\n  }\n  jv_free(msg);\n  $$ = gen_object_matcher($2, $5);\n} |\nerror ':' Pattern {\n  FAIL(@$, \"May need parentheses around object key expression\");\n  $$ = $3;\n}\n\nKeyword:\n\"as\" {\n  $$ = jv_string(\"as\");\n} |\n\"def\" {\n  $$ = jv_string(\"def\");\n} |\n\"module\" {\n  $$ = jv_string(\"module\");\n} |\n\"import\" {\n  $$ = jv_string(\"import\");\n} |\n\"include\" {\n  $$ = jv_string(\"include\");\n} |\n\"if\" {\n  $$ = jv_string(\"if\");\n} |\n\"then\" {\n  $$ = jv_string(\"then\");\n} |\n\"else\" {\n  $$ = jv_string(\"else\");\n} |\n\"elif\" {\n  $$ = jv_string(\"elif\");\n} |\n\"reduce\" {\n  $$ = jv_string(\"reduce\");\n} |\n\"foreach\" {\n  $$ = jv_string(\"foreach\");\n} |\n\"end\" {\n  $$ = jv_string(\"end\");\n} |\n\"and\" {\n  $$ = jv_string(\"and\");\n} |\n\"or\" {\n  $$ = jv_string(\"or\");\n} |\n\"try\" {\n  $$ = jv_string(\"try\");\n} |\n\"catch\" {\n  $$ = jv_string(\"catch\");\n} |\n\"label\" {\n  $$ = jv_string(\"label\");\n} |\n\"break\" {\n  $$ = jv_string(\"break\");\n}\n\n\nDictPairs:\n%empty {\n  $$ = gen_noop();\n} |\nDictPair {\n  $$ = $1;\n} |\nDictPair ',' DictPairs {\n  $$ = block_join($1, $3);\n}\n\nDictPair:\nIDENT ':' DictExpr {\n  $$ = gen_dictpair(gen_const($1), $3);\n} |\nKeyword ':' DictExpr {\n  $$ = gen_dictpair(gen_const($1), $3);\n} |\nString ':' DictExpr {\n  $$ = gen_dictpair($1, $3);\n} |\nString {\n  $$ = gen_dictpair($1, BLOCK(gen_op_simple(POP), gen_op_simple(DUP2),\n                              gen_op_simple(DUP2), gen_op_simple(INDEX)));\n} |\nBINDING ':' DictExpr {\n  $$ = gen_dictpair(gen_location(@$, locations, gen_op_unbound(LOADV, jv_string_value($1))),\n                    $3);\n  jv_free($1);\n} |\nBINDING {\n  $$ = gen_dictpair(gen_const($1),\n                    gen_location(@$, locations, gen_op_unbound(LOADV, jv_string_value($1))));\n} |\nIDENT {\n  $$ = gen_dictpair(gen_const(jv_copy($1)),\n                    gen_index(gen_noop(), gen_const($1)));\n} |\n\"$__loc__\" {\n  $$ = gen_dictpair(gen_const(jv_string(\"__loc__\")),\n                    gen_loc_object(&@$, locations));\n} |\nKeyword {\n  $$ = gen_dictpair(gen_const(jv_copy($1)),\n                    gen_index(gen_noop(), gen_const($1)));\n} |\n'(' Query ')' ':' DictExpr {\n  jv msg = check_object_key($2);\n  if (jv_is_valid(msg)) {\n    FAIL(@2, jv_string_value(msg));\n  }\n  jv_free(msg);\n  $$ = gen_dictpair($2, $5);\n} |\nerror ':' DictExpr {\n  FAIL(@1, \"May need parentheses around object key expression\");\n  $$ = $3;\n}\n\nDictExpr:\nDictExpr '|' DictExpr {\n  $$ = block_join($1, $3);\n} |\nExpr {\n  $$ = $1;\n}\n%%\n\nint jq_parse(struct locfile* locations, block* answer) {\n  struct lexer_param scanner;\n  YY_BUFFER_STATE buf;\n  jq_yylex_init_extra(0, &scanner.lexer);\n  buf = jq_yy_scan_bytes(locations->data, locations->length, scanner.lexer);\n  int errors = 0;\n  *answer = gen_noop();\n  yyparse(answer, &errors, locations, &scanner);\n  jq_yy_delete_buffer(buf, scanner.lexer);\n  jq_yylex_destroy(scanner.lexer);\n  if (errors > 0) {\n    block_free(*answer);\n    *answer = gen_noop();\n  }\n  return errors;\n}\n\nint jq_parse_library(struct locfile* locations, block* answer) {\n  int errs = jq_parse(locations, answer);\n  if (errs) return errs;\n  if (block_has_main(*answer)) {\n    locfile_locate(locations, UNKNOWN_LOCATION, \"jq: error: library should only have function definitions, not a main expression\");\n    return 1;\n  }\n  assert(block_has_only_binders_and_imports(*answer, OP_IS_CALL_PSEUDO));\n  return 0;\n}\n"
  },
  {
    "path": "src/util.c",
    "content": "/*-\n * Parts (strptime()) Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.\n * All rights reserved.\n *\n * This code was contributed to The NetBSD Foundation by Klaus Klein.\n * Heavily optimised by David Laight\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS\n * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\n * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS\n * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <assert.h>\n#include <errno.h>\n#include <fcntl.h>\n#include <limits.h>\n#include <string.h>\n#include <unistd.h>\n#include <stdlib.h>\n#include <stddef.h>\n#ifdef HAVE_ALLOCA_H\n# include <alloca.h>\n#elif !defined alloca\n# ifdef __GNUC__\n#  define alloca __builtin_alloca\n# elif defined _MSC_VER\n#  include <malloc.h>\n#  define alloca _alloca\n# elif !defined HAVE_ALLOCA\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nvoid *alloca (size_t);\n# endif\n#endif\n\n#ifdef WIN32\n#include <windows.h>\n#include <processenv.h>\n#include <shellapi.h>\n#include <wchar.h>\n#include <wtypes.h>\n#endif\n\n\n#include \"util.h\"\n#include \"jq.h\"\n#include \"jv_alloc.h\"\n#include \"jv_unicode.h\"\n\n#ifdef WIN32\nFILE *fopen(const char *fname, const char *mode) {\n  size_t sz = sizeof(wchar_t) * MultiByteToWideChar(CP_UTF8, 0, fname, -1, NULL, 0);\n  wchar_t *wfname = alloca(sz + 2); // +2 is not needed, but just in case\n  MultiByteToWideChar(CP_UTF8, 0, fname, -1, wfname, sz);\n\n  sz = sizeof(wchar_t) * MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0);\n  wchar_t *wmode = alloca(sz + 2); // +2 is not needed, but just in case\n  MultiByteToWideChar(CP_UTF8, 0, mode, -1, wmode, sz);\n  return _wfopen(wfname, wmode);\n}\n#endif\n\njv expand_path(jv path) {\n  assert(jv_get_kind(path) == JV_KIND_STRING);\n  const char *pstr = jv_string_value(path);\n  jv ret = path;\n  if (jv_string_length_bytes(jv_copy(path)) > 1 && pstr[0] == '~' && pstr[1] == '/') {\n    jv home = get_home();\n    if (jv_is_valid(home)) {\n      ret = jv_string_fmt(\"%s/%s\",jv_string_value(home),pstr+2);\n      jv_free(home);\n    } else {\n      jv emsg = jv_invalid_get_msg(home);\n      ret = jv_invalid_with_msg(jv_string_fmt(\"Could not expand %s. (%s)\", pstr, jv_string_value(emsg)));\n      jv_free(emsg);\n    }\n    jv_free(path);\n  }\n  return ret;\n}\n\njv get_home(void) {\n  jv ret;\n  char *home = getenv(\"HOME\");\n  if (!home) {\n#ifndef WIN32\n    ret = jv_invalid_with_msg(jv_string(\"Could not find home directory.\"));\n#else\n    home = getenv(\"USERPROFILE\");\n    if (!home) {\n      home = getenv(\"HOMEPATH\");\n      if (!home) {\n        ret = jv_invalid_with_msg(jv_string(\"Could not find home directory.\"));\n      } else {\n        const char *hd = getenv(\"HOMEDRIVE\");\n        if (!hd) hd = \"\";\n        ret = jv_string_fmt(\"%s%s\",hd,home);\n      }\n    } else {\n      ret = jv_string(home);\n    }\n#endif\n  } else {\n    ret = jv_string(home);\n  }\n  return ret;\n}\n\n\njv jq_realpath(jv path) {\n  int path_max;\n  char *buf = NULL;\n#ifdef _PC_PATH_MAX\n  path_max = pathconf(jv_string_value(path),_PC_PATH_MAX);\n#else\n  path_max = PATH_MAX;\n#endif\n  if (path_max > 0) {\n     buf = jv_mem_alloc(path_max);\n  }\n#ifdef WIN32\n  char *tmp = _fullpath(buf, jv_string_value(path), path_max);\n#else\n  char *tmp = realpath(jv_string_value(path), buf);\n#endif\n  if (tmp == NULL) {\n    free(buf);\n    return path;\n  }\n  jv_free(path);\n  path = jv_string(tmp);\n  free(tmp);\n  return path;\n}\n\nconst void *_jq_memmem(const void *haystack, size_t haystacklen,\n                       const void *needle, size_t needlelen) {\n#ifdef HAVE_MEMMEM\n  return (const void*)memmem(haystack, haystacklen, needle, needlelen);\n#else\n  const char *h = haystack;\n  const char *n = needle;\n  size_t hi, hi2, ni;\n\n  if (haystacklen < needlelen || haystacklen == 0)\n    return NULL;\n  for (hi = 0; hi < (haystacklen - needlelen + 1); hi++) {\n    for (ni = 0, hi2 = hi; ni < needlelen; ni++, hi2++) {\n      if (h[hi2] != n[ni])\n        goto not_this;\n    }\n\n    return &h[hi];\n\nnot_this:\n    continue;\n  }\n  return NULL;\n#endif /* !HAVE_MEMMEM */\n}\n\nstruct jq_util_input_state {\n  jq_util_msg_cb err_cb;\n  void *err_cb_data;\n  jv_parser *parser;\n  FILE* current_input;\n  char **files;\n  int nfiles;\n  int curr_file;\n  int failures;\n  jv slurped;\n  char buf[4096];\n  size_t buf_valid_len;\n  jv current_filename;\n  size_t current_line;\n};\n\nstatic void fprinter(void *data, const char *fname) {\n  fprintf((FILE *)data, \"jq: error: Could not open file %s: %s\\n\", fname, strerror(errno));\n}\n\n// If parser == NULL -> RAW\njq_util_input_state *jq_util_input_init(jq_util_msg_cb err_cb, void *err_cb_data) {\n  if (err_cb == NULL) {\n    err_cb = fprinter;\n    err_cb_data = stderr;\n  }\n  jq_util_input_state *new_state = jv_mem_calloc(1, sizeof(*new_state));\n  new_state->err_cb = err_cb;\n  new_state->err_cb_data = err_cb_data;\n  new_state->slurped = jv_invalid();\n  new_state->current_filename = jv_invalid();\n\n  return new_state;\n}\n\nvoid jq_util_input_set_parser(jq_util_input_state *state, jv_parser *parser, int slurp) {\n  assert(!jv_is_valid(state->slurped));\n  state->parser = parser;\n\n  if (parser == NULL && slurp)\n    state->slurped = jv_string(\"\");\n  else if (slurp)\n    state->slurped = jv_array();\n  else\n    state->slurped = jv_invalid();\n}\n\nvoid jq_util_input_free(jq_util_input_state **state) {\n  jq_util_input_state *old_state = *state;\n  *state = NULL;\n  if (old_state == NULL)\n    return;\n\n  if (old_state->parser != NULL)\n    jv_parser_free(old_state->parser);\n  for (int i = 0; i < old_state->nfiles; i++)\n    free(old_state->files[i]);\n  free(old_state->files);\n  jv_free(old_state->slurped);\n  jv_free(old_state->current_filename);\n  jv_mem_free(old_state);\n}\n\nvoid jq_util_input_add_input(jq_util_input_state *state, const char *fname) {\n  state->files = jv_mem_realloc(state->files, (state->nfiles + 1) * sizeof(state->files[0]));\n  state->files[state->nfiles++] = jv_mem_strdup(fname);\n}\n\nint jq_util_input_errors(jq_util_input_state *state) {\n  return state->failures;\n}\n\nstatic const char *next_file(jq_util_input_state *state) {\n  if (state->curr_file < state->nfiles)\n    return state->files[state->curr_file++];\n  return NULL;\n}\n\nstatic int jq_util_input_read_more(jq_util_input_state *state) {\n  if (!state->current_input || feof(state->current_input) || ferror(state->current_input)) {\n    if (state->current_input && ferror(state->current_input)) {\n      // System-level input error on the stream. It will be closed (below).\n      // TODO: report it. Can't use 'state->err_cb()' as it is hard-coded for\n      //       'open' related problems.\n      fprintf(stderr,\"jq: error: %s\\n\", strerror(errno));\n    }\n    if (state->current_input) {\n      if (state->current_input == stdin) {\n        clearerr(stdin); // perhaps we can read again; anyways, we don't fclose(stdin)\n      } else {\n        fclose(state->current_input);\n      }\n      state->current_input = NULL;\n    }\n    const char *f = next_file(state);\n    if (f != NULL) {\n      jv_free(state->current_filename);\n      state->current_line = 0;\n      if (!strcmp(f, \"-\")) {\n        state->current_input = stdin;\n        state->current_filename = jv_string(\"<stdin>\");\n      } else {\n        state->current_input = fopen(f, \"r\");\n        state->current_filename = jv_string(f);\n        if (!state->current_input) {\n          state->err_cb(state->err_cb_data, f);\n          state->failures++;\n        }\n      }\n    }\n  }\n\n  state->buf[0] = 0;\n  state->buf_valid_len = 0;\n  if (state->current_input) {\n    char *res;\n    memset(state->buf, 0xff, sizeof(state->buf));\n\n    const int max_utf8_len = 4;\n    const int max_gets_len = sizeof(state->buf) - max_utf8_len;\n    while (!(res = fgets(state->buf, max_gets_len, state->current_input)) &&\n           ferror(state->current_input) && errno == EINTR)\n      clearerr(state->current_input);\n    if (res == NULL) {\n      state->buf[0] = 0;\n      if (ferror(state->current_input))\n        state->failures++;\n    } else {\n      const char *p = memchr(state->buf, '\\n', max_gets_len);\n\n      if (p != NULL)\n        state->current_line++;\n\n      if (p == NULL && state->parser != NULL) {\n        /*\n         * There should be no NULs in JSON texts (but JSON text\n         * sequences are another story).\n         */\n        state->buf_valid_len = strlen(state->buf);\n      } else if (p == NULL && feof(state->current_input)) {\n        size_t i;\n\n        /*\n         * XXX We don't know how many bytes we've read!\n         *\n         * We can't use getline() because there need not be any newlines\n         * in the input.  The only entirely correct choices are: use\n         * fgetc() or fread().  Using fread() will complicate buffer\n         * management here.\n         *\n         * For now we check how much fgets() read by scanning backwards for the\n         * terminating '\\0'. This only works because we previously memset our\n         * buffer with something nonzero.\n         */\n        for (i = max_gets_len - 1; i > 0; i--) {\n          if (state->buf[i] == '\\0')\n            break;\n        }\n        state->buf_valid_len = i;\n      } else if (p == NULL) {\n        state->buf_valid_len = max_gets_len - 1;\n        char *end = state->buf + state->buf_valid_len;\n        int len = 0;\n        if (jvp_utf8_backtrack(end - 1, state->buf, &len) && len > 0) {\n          state->buf_valid_len += fread(end, 1, len, state->current_input);\n        }\n      } else {\n        state->buf_valid_len = (p - state->buf) + 1;\n      }\n    }\n  }\n  return state->curr_file == state->nfiles && !state->current_input;\n}\n\njv jq_util_input_next_input_cb(jq_state *jq, void *data) {\n  return jq_util_input_next_input((jq_util_input_state *)data);\n}\n\n// Return the current_filename:current_line\njv jq_util_input_get_position(jq_state *jq) {\n  jq_input_cb cb = NULL;\n  void *cb_data = NULL;\n  jq_get_input_cb(jq, &cb, &cb_data);\n  assert(cb == jq_util_input_next_input_cb);\n  if (cb != jq_util_input_next_input_cb)\n    return jv_invalid_with_msg(jv_string(\"Invalid jq_util_input API usage\"));\n  jq_util_input_state *s = (jq_util_input_state *)cb_data;\n\n  // We can't assert that current_filename is a string because if\n  // the error was a JSON parser error then we may not have set\n  // current_filename yet.\n  if (jv_get_kind(s->current_filename) != JV_KIND_STRING)\n    return jv_string(\"<unknown>\");\n\n  jv v = jv_string_fmt(\"%s:%lu\", jv_string_value(s->current_filename), (unsigned long)s->current_line);\n  return v;\n}\n\njv jq_util_input_get_current_filename(jq_state* jq) {\n  jq_input_cb cb=NULL;\n  void *cb_data=NULL;\n  jq_get_input_cb(jq, &cb, &cb_data);\n  if (cb != jq_util_input_next_input_cb)\n    return jv_invalid_with_msg(jv_string(\"Unknown input filename\"));\n  jq_util_input_state *s = (jq_util_input_state *)cb_data;\n  jv v = jv_copy(s->current_filename);\n  return v;\n}\n\njv jq_util_input_get_current_line(jq_state* jq) {\n  jq_input_cb cb=NULL;\n  void *cb_data=NULL;\n  jq_get_input_cb(jq, &cb, &cb_data);\n  if (cb != jq_util_input_next_input_cb)\n    return jv_invalid_with_msg(jv_string(\"Unknown input line number\"));\n  jq_util_input_state *s = (jq_util_input_state *)cb_data;\n  jv v = jv_number(s->current_line);\n  return v;\n}\n\n\n// Blocks to read one more input from stdin and/or given files\n// When slurping, it returns just one value\njv jq_util_input_next_input(jq_util_input_state *state) {\n  int is_last = 0;\n  jv value = jv_invalid(); // need more input\n  do {\n    if (state->parser == NULL) {\n      // Raw input\n      is_last = jq_util_input_read_more(state);\n      if (state->buf_valid_len == 0)\n        continue;\n      if (jv_is_valid(state->slurped)) {\n        // Slurped raw input\n        state->slurped = jv_string_concat(state->slurped, jv_string_sized(state->buf, state->buf_valid_len));\n      } else {\n        if (!jv_is_valid(value))\n          value = jv_string(\"\");\n        if (state->buf[state->buf_valid_len-1] == '\\n') {\n          // whole line\n          state->buf[state->buf_valid_len-1] = 0;\n          return jv_string_concat(value, jv_string_sized(state->buf, state->buf_valid_len-1));\n        }\n        value = jv_string_concat(value, jv_string_sized(state->buf, state->buf_valid_len));\n        state->buf[0] = '\\0';\n        state->buf_valid_len = 0;\n      }\n    } else {\n      if (jv_parser_remaining(state->parser) == 0) {\n        is_last = jq_util_input_read_more(state);\n        jv_parser_set_buf(state->parser, state->buf, state->buf_valid_len, !is_last);\n      }\n      value = jv_parser_next(state->parser);\n      if (jv_is_valid(state->slurped)) {\n        if (jv_is_valid(value)) {\n          state->slurped = jv_array_append(state->slurped, value);\n          value = jv_invalid();\n        } else if (jv_invalid_has_msg(jv_copy(value)))\n          return value; // Not slurped parsed input\n      } else if (jv_is_valid(value) || jv_invalid_has_msg(jv_copy(value))) {\n        return value;\n      }\n    }\n  } while (!is_last);\n\n  if (jv_is_valid(state->slurped)) {\n    value = state->slurped;\n    state->slurped = jv_invalid();\n  }\n  return value;\n}\n\n#ifndef HAVE_STRPTIME\n/* http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/lib/libc/time/strptime.c?only_with_tag=HEAD\n * NetBSD implementation strptime().\n * Format description: https://netbsd.gw.com/cgi-bin/man-cgi?strptime+3+NetBSD-current\n * Adapted by https://github.com/res2001 (https://github.com/res2001/strptime).\n*/\n\n#include <ctype.h>\n#include <string.h>\n#include <time.h>\n#include <stdint.h>\n\nstatic const unsigned char *conv_num(const unsigned char *, int *, unsigned int, unsigned int);\nstatic const unsigned char *find_string(const unsigned char *, int *, const char * const *, const char * const *, int);\n\n/*\n * We do not implement alternate representations. However, we always\n * check whether a given modifier is allowed for a certain conversion.\n */\n#define ALT_E\t\t\t0x01\n#define ALT_O\t\t\t0x02\n#define LEGAL_ALT(x)\t{ if (alt_format & ~(x)) return NULL; }\n\n#define TM_YEAR_BASE\t1900\n\n#define TM_SUNDAY       0\n#define TM_MONDAY       1\n#define TM_TUESDAY      2\n#define TM_WEDNESDAY    3\n#define TM_THURSDAY     4\n#define TM_FRIDAY       5\n#define TM_SATURDAY     6\n\n#define S_YEAR\t\t\t(1 << 0)\n#define S_MON\t\t\t(1 << 1)\n#define S_YDAY\t\t\t(1 << 2)\n#define S_MDAY\t\t\t(1 << 3)\n#define S_WDAY\t\t\t(1 << 4)\n#define S_HOUR\t\t\t(1 << 5)\n\n#define HAVE_MDAY(s)\t(s & S_MDAY)\n#define HAVE_MON(s)\t\t(s & S_MON)\n#define HAVE_WDAY(s)\t(s & S_WDAY)\n#define HAVE_YDAY(s)\t(s & S_YDAY)\n#define HAVE_YEAR(s)\t(s & S_YEAR)\n#define HAVE_HOUR(s)\t(s & S_HOUR)\n\n#define SECSPERMIN      60\n#define MINSPERHOUR     60\n#define SECSPERHOUR     (SECSPERMIN * MINSPERHOUR)\n#define HOURSPERDAY     24\n\n#define HERE_D_T_FMT    \"%a %b %e %H:%M:%S %Y\"\n#define HERE_D_FMT      \"%y/%m/%d\"\n#define HERE_T_FMT_AMPM \"%I:%M:%S %p\"\n#define HERE_T_FMT      \"%H:%M:%S\"\n\n#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))\n\n/*\n** Since everything in isleap is modulo 400 (or a factor of 400), we know that\n**\tisleap(y) == isleap(y % 400)\n** and so\n**\tisleap(a + b) == isleap((a + b) % 400)\n** or\n**\tisleap(a + b) == isleap(a % 400 + b % 400)\n** This is true even if % means modulo rather than Fortran remainder\n** (which is allowed by C89 but not by C99 or later).\n** We use this to avoid addition overflow problems.\n*/\n\n#define isleap_sum(a, b)\tisleap((a) % 400 + (b) % 400)\n\n#ifdef _MSC_VER\n#define tzname              _tzname\n#define strncasecmp         _strnicmp\n#endif\n\n#ifdef TM_ZONE\nstatic char* utc = \"UTC\";\n#endif\n/* RFC-822/RFC-2822 */\nstatic const char *const nast[] = {\n       \"EST\",    \"CST\",    \"MST\",    \"PST\",    \"\\0\\0\\0\"\n};\nstatic const char *const nadt[] = {\n       \"EDT\",    \"CDT\",    \"MDT\",    \"PDT\",    \"\\0\\0\\0\"\n};\nstatic const char *const weekday_name[] =\n{\n    \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\",\n    \"Thursday\", \"Friday\", \"Saturday\"\n};\nstatic const char *const ab_weekday_name[] =\n{\n    \"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"\n};\nstatic const char *const month_name[] =\n{\n    \"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n    \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"\n};\nstatic const char *const ab_month_name[] =\n{\n    \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n    \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"\n};\nstatic const char *const am_pm[] = {\"AM\", \"PM\"};\n\n\n/*\n * Table to determine the ordinal date for the start of a month.\n * Ref: http://en.wikipedia.org/wiki/ISO_week_date\n */\nstatic const int start_of_month[2][13] = {\n    /* non-leap year */\n    { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },\n    /* leap year */\n    { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }\n};\n\n/*\n * Calculate the week day of the first day of a year. Valid for\n * the Gregorian calendar, which began Sept 14, 1752 in the UK\n * and its colonies. Ref:\n * http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week\n */\n\nstatic int\nfirst_wday_of(int yr)\n{\n    return ((2 * (3 - (yr / 100) % 4)) + (yr % 100) + ((yr % 100) /  4) +\n        (isleap(yr) ? 6 : 0) + 1) % 7;\n}\n\n#define delim(p)\t((p) == '\\0' || isspace((unsigned char)(p)))\n\nstatic int\nfromzone(const unsigned char **bp, struct tm *tm, int mandatory)\n{\n//    timezone_t tz;\n    char buf[512], *p;\n    const unsigned char *rp;\n\n    for (p = buf, rp = *bp; !delim(*rp) && p < &buf[sizeof(buf) - 1]; rp++)\n        *p++ = *rp;\n    *p = '\\0';\n\n    if (mandatory)\n        *bp = rp;\n    if (!isalnum((unsigned char)*buf))\n        return 0;\n//    tz = tzalloc(buf);\n//    if (tz == NULL)\n//        return 0;\n\n    *bp = rp;\n    tm->tm_isdst = 0;\t/* XXX */\n#ifdef TM_GMTOFF\n    tm->TM_GMTOFF = tzgetgmtoff(tz, tm->tm_isdst);\n#endif\n#ifdef TM_ZONE\n    // Can't use tzgetname() here because we are going to free()\n    tm->TM_ZONE = NULL; /* XXX */\n#endif\n//    tzfree(tz);\n    return 1;\n}\n\nchar* strptime(const char *buf, const char *fmt, struct tm *tm)\n{\n    unsigned char c;\n    const unsigned char *bp, *ep, *zname;\n    int alt_format, i, split_year = 0, neg = 0, state = 0,\n        day_offset = -1, week_offset = 0, offs, mandatory;\n    const char *new_fmt;\n\n    bp = (const unsigned char *)buf;\n\n    while (bp != NULL && (c = *fmt++) != '\\0') {\n        /* Clear `alternate' modifier prior to new conversion. */\n        alt_format = 0;\n        i = 0;\n\n        /* Eat up white-space. */\n        if (isspace(c)) {\n            while (isspace(*bp))\n                bp++;\n            continue;\n        }\n\n        if (c != '%')\n            goto literal;\n\n\nagain:\t\tswitch (c = *fmt++) {\n        case '%':\t/* \"%%\" is converted to \"%\". */\nliteral:\n            if (c != *bp++)\n                return NULL;\n            LEGAL_ALT(0);\n            continue;\n\n        /*\n         * \"Alternative\" modifiers. Just set the appropriate flag\n         * and start over again.\n         */\n        case 'E':\t/* \"%E?\" alternative conversion modifier. */\n            LEGAL_ALT(0);\n            alt_format |= ALT_E;\n            goto again;\n\n        case 'O':\t/* \"%O?\" alternative conversion modifier. */\n            LEGAL_ALT(0);\n            alt_format |= ALT_O;\n            goto again;\n\n        /*\n         * \"Complex\" conversion rules, implemented through recursion.\n         */\n        case 'c':\t/* Date and time, using the locale's format. */\n//            new_fmt = _TIME_LOCALE(loc)->d_t_fmt;\n            new_fmt = HERE_D_T_FMT;\n            state |= S_WDAY | S_MON | S_MDAY | S_YEAR;\n            goto recurse;\n\n        case 'F':\t/* The date as \"%Y-%m-%d\". */\n            new_fmt = \"%Y-%m-%d\";\n            LEGAL_ALT(0);\n            state |= S_MON | S_MDAY | S_YEAR;\n            goto recurse;\n\n        case 'R':\t/* The time as \"%H:%M\". */\n            new_fmt = \"%H:%M\";\n            LEGAL_ALT(0);\n            goto recurse;\n\n        case 'r':\t/* The time in 12-hour clock representation. */\n//            new_fmt = _TIME_LOCALE(loc)->t_fmt_ampm;\n            new_fmt = HERE_T_FMT_AMPM;\n            LEGAL_ALT(0);\n            goto recurse;\n\n        case 'X':\t/* The time, using the locale's format. */\n            /* fall through */\n\n        case 'T':\t/* The time as \"%H:%M:%S\". */\n            new_fmt = HERE_T_FMT;\n            LEGAL_ALT(0);\n\nrecurse:\n            bp = (const unsigned char *)strptime((const char *)bp,\n                                new_fmt, tm);\n            LEGAL_ALT(ALT_E);\n            continue;\n\n        case 'x':\t/* The date, using the locale's format. */\n            /* fall through */\n\n        case 'D':\t/* The date as \"%y/%m/%d\". */\n        {\n            new_fmt = HERE_D_FMT;\n            LEGAL_ALT(0);\n            state |= S_MON | S_MDAY | S_YEAR;\n            const int year = split_year ? tm->tm_year : 0;\n\n            bp = (const unsigned char *)strptime((const char *)bp,\n                                new_fmt, tm);\n            LEGAL_ALT(ALT_E);\n            tm->tm_year += year;\n            if (split_year && tm->tm_year % (2000 - TM_YEAR_BASE) <= 68)\n                tm->tm_year -= 2000 - TM_YEAR_BASE;\n            split_year = 1;\n            continue;\n        }\n        /*\n         * \"Elementary\" conversion rules.\n         */\n        case 'A':\t/* The day of week, using the locale's form. */\n        case 'a':\n            bp = find_string(bp, &tm->tm_wday, weekday_name, ab_weekday_name, 7);\n            LEGAL_ALT(0);\n            state |= S_WDAY;\n            continue;\n\n        case 'B':\t/* The month, using the locale's form. */\n        case 'b':\n        case 'h':\n            bp = find_string(bp, &tm->tm_mon, month_name, ab_month_name, 12);\n            LEGAL_ALT(0);\n            state |= S_MON;\n            continue;\n\n        case 'C':\t/* The century number. */\n            i = 20;\n            bp = conv_num(bp, &i, 0, 99);\n\n            i = i * 100 - TM_YEAR_BASE;\n            if (split_year)\n                i += tm->tm_year % 100;\n            split_year = 1;\n            tm->tm_year = i;\n            LEGAL_ALT(ALT_E);\n            state |= S_YEAR;\n            continue;\n\n        case 'd':\t/* The day of month. */\n        case 'e':\n            bp = conv_num(bp, &tm->tm_mday, 1, 31);\n            LEGAL_ALT(ALT_O);\n            state |= S_MDAY;\n            continue;\n\n        case 'k':\t/* The hour (24-hour clock representation). */\n            LEGAL_ALT(0);\n            /* FALLTHROUGH */\n        case 'H':\n            bp = conv_num(bp, &tm->tm_hour, 0, 23);\n            LEGAL_ALT(ALT_O);\n            state |= S_HOUR;\n            continue;\n\n        case 'l':\t/* The hour (12-hour clock representation). */\n            LEGAL_ALT(0);\n            /* FALLTHROUGH */\n        case 'I':\n            bp = conv_num(bp, &tm->tm_hour, 1, 12);\n            if (tm->tm_hour == 12)\n                tm->tm_hour = 0;\n            LEGAL_ALT(ALT_O);\n            state |= S_HOUR;\n            continue;\n\n        case 'j':\t/* The day of year. */\n            i = 1;\n            bp = conv_num(bp, &i, 1, 366);\n            tm->tm_yday = i - 1;\n            LEGAL_ALT(0);\n            state |= S_YDAY;\n            continue;\n\n        case 'M':\t/* The minute. */\n            bp = conv_num(bp, &tm->tm_min, 0, 59);\n            LEGAL_ALT(ALT_O);\n            continue;\n\n        case 'm':\t/* The month. */\n            i = 1;\n            bp = conv_num(bp, &i, 1, 12);\n            tm->tm_mon = i - 1;\n            LEGAL_ALT(ALT_O);\n            state |= S_MON;\n            continue;\n\n        case 'p':\t/* The locale's equivalent of AM/PM. */\n            bp = find_string(bp, &i, am_pm, NULL, 2);\n            if (HAVE_HOUR(state) && tm->tm_hour > 11)\n                return NULL;\n            tm->tm_hour += i * 12;\n            LEGAL_ALT(0);\n            continue;\n\n        case 'S':\t/* The seconds. */\n            bp = conv_num(bp, &tm->tm_sec, 0, 61);\n            LEGAL_ALT(ALT_O);\n            continue;\n\n        case 's': {     /* seconds since the epoch */\n#ifdef _WIN32\n            const time_t TIME_MAX = INT32_MAX;\n#else\n            const time_t TIME_MAX = INT64_MAX;\n#endif\n            time_t sse, d;\n\n            if (*bp < '0' || *bp > '9') {\n                bp = NULL;\n                continue;\n            }\n\n            sse = *bp++ - '0';\n            while (*bp >= '0' && *bp <= '9') {\n                d = *bp++ - '0';\n                if (sse > TIME_MAX/10) {\n                    bp = NULL;\n                    break;\n                }\n                sse *= 10;\n                if (sse > TIME_MAX - d) {\n                    bp = NULL;\n                    break;\n                }\n                sse += d;\n            }\n            if (bp == NULL)\n                continue;\n\n#ifdef _WIN32\n            if (localtime_s(tm, &sse))\n#else\n            if (localtime_r(&sse, tm) == NULL)\n#endif\n                bp = NULL;\n            else\n                state |= S_YDAY | S_WDAY | S_MON | S_MDAY | S_YEAR;\n            continue;\n            }\n\n        case 'U':\t/* The week of year, beginning on sunday. */\n        case 'W':\t/* The week of year, beginning on monday. */\n            /*\n             * This is bogus, as we can not assume any valid\n             * information present in the tm structure at this\n             * point to calculate a real value, so save the\n             * week for now in case it can be used later.\n             */\n            bp = conv_num(bp, &i, 0, 53);\n            LEGAL_ALT(ALT_O);\n            if (c == 'U')\n                day_offset = TM_SUNDAY;\n            else\n                day_offset = TM_MONDAY;\n            week_offset = i;\n            continue;\n\n        case 'w':\t/* The day of week, beginning on sunday. */\n            bp = conv_num(bp, &tm->tm_wday, 0, 6);\n            LEGAL_ALT(ALT_O);\n            state |= S_WDAY;\n            continue;\n\n        case 'u':\t/* The day of week, monday = 1. */\n            bp = conv_num(bp, &i, 1, 7);\n            tm->tm_wday = i % 7;\n            LEGAL_ALT(ALT_O);\n            state |= S_WDAY;\n            continue;\n\n        case 'g':\t/* The year corresponding to the ISO week\n                 * number but without the century.\n                 */\n            bp = conv_num(bp, &i, 0, 99);\n            continue;\n\n        case 'G':\t/* The year corresponding to the ISO week\n                 * number with century.\n                 */\n            do\n                bp++;\n            while (isdigit(*bp));\n            continue;\n\n        case 'V':\t/* The ISO 8601:1988 week number as decimal */\n            bp = conv_num(bp, &i, 0, 53);\n            continue;\n\n        case 'Y':\t/* The year. */\n            i = TM_YEAR_BASE;\t/* just for data sanity... */\n            bp = conv_num(bp, &i, 0, 9999);\n            tm->tm_year = i - TM_YEAR_BASE;\n            LEGAL_ALT(ALT_E);\n            state |= S_YEAR;\n            continue;\n\n        case 'y':\t/* The year within 100 years of the epoch. */\n            /* LEGAL_ALT(ALT_E | ALT_O); */\n            bp = conv_num(bp, &i, 0, 99);\n\n            if (split_year)\n                /* preserve century */\n                i += (tm->tm_year / 100) * 100;\n            else {\n                split_year = 1;\n                if (i <= 68)\n                    i = i + 2000 - TM_YEAR_BASE;\n            }\n            tm->tm_year = i;\n            state |= S_YEAR;\n            continue;\n\n        case 'Z':       // time zone name\n        case 'z':       //\n#ifdef _WIN32\n            _tzset();\n#else\n            tzset();\n#endif\n            mandatory = c == 'z';\n            /*\n             * We recognize all ISO 8601 formats:\n             * Z\t= Zulu time/UTC\n             * [+-]hhmm\n             * [+-]hh:mm\n             * [+-]hh\n             * We recognize all RFC-822/RFC-2822 formats:\n             * UT|GMT\n             *          North American : UTC offsets\n             * E[DS]T = Eastern : -4 | -5\n             * C[DS]T = Central : -5 | -6\n             * M[DS]T = Mountain: -6 | -7\n             * P[DS]T = Pacific : -7 | -8\n             *          Nautical/Military\n             * [A-IL-M] = -1 ... -9 (J not used)\n             * [N-Y]  = +1 ... +12\n             * Note: J maybe used to denote non-nautical\n             *       local time\n             */\n            if (mandatory)\n                while (isspace(*bp))\n                    bp++;\n\n            zname = bp;\n            switch (*bp++) {\n            case 'G':\n                if (*bp++ != 'M')\n                    goto namedzone;\n                /*FALLTHROUGH*/\n            case 'U':\n                if (*bp++ != 'T')\n                    goto namedzone;\n                else if (!delim(*bp) && *bp++ != 'C')\n                    goto namedzone;\n                /*FALLTHROUGH*/\n            case 'Z':\n                if (!delim(*bp))\n                    goto namedzone;\n                tm->tm_isdst = 0;\n#ifdef TM_GMTOFF\n                tm->TM_GMTOFF = 0;\n#endif\n#ifdef TM_ZONE\n                tm->TM_ZONE = utc;\n#endif\n                continue;\n            case '+':\n                neg = 0;\n                break;\n            case '-':\n                neg = 1;\n                break;\n            default:\nnamedzone:\n                bp = zname;\n\n                /* Nautical / Military style */\n                if (delim(bp[1]) &&\n                    ((*bp >= 'A' && *bp <= 'I') ||\n                     (*bp >= 'L' && *bp <= 'Y'))) {\n#ifdef TM_GMTOFF\n                    /* Argh! No 'J'! */\n                    if (*bp >= 'A' && *bp <= 'I')\n                        tm->TM_GMTOFF =\n                            (int)*bp - ('A' - 1);\n                    else if (*bp >= 'L' && *bp <= 'M')\n                        tm->TM_GMTOFF = (int)*bp - 'A';\n                    else if (*bp >= 'N' && *bp <= 'Y')\n                        tm->TM_GMTOFF = 'M' - (int)*bp;\n                    tm->TM_GMTOFF *= SECSPERHOUR;\n#endif\n#ifdef TM_ZONE\n                    tm->TM_ZONE = NULL; /* XXX */\n#endif\n                    bp++;\n                    continue;\n                }\n                /* 'J' is local time */\n                if (delim(bp[1]) && *bp == 'J') {\n#ifdef TM_GMTOFF\n                    tm->TM_GMTOFF = -timezone;\n#endif\n#ifdef TM_ZONE\n                    tm->TM_ZONE = NULL; /* XXX */\n#endif\n                    bp++;\n                    continue;\n                }\n\n                /*\n                 * From our 3 letter hard-coded table\n                 * XXX: Can be removed, handled by tzload()\n                 */\n                if (delim(bp[0]) || delim(bp[1]) ||\n                    delim(bp[2]) || !delim(bp[3]))\n                    goto loadzone;\n                ep = find_string(bp, &i, nast, NULL, 4);\n                if (ep != NULL) {\n#ifdef TM_GMTOFF\n                    tm->TM_GMTOFF = (-5 - i) * SECSPERHOUR;\n#endif\n#ifdef TM_ZONE\n                    tm->TM_ZONE = __UNCONST(nast[i]);\n#endif\n                    bp = ep;\n                    continue;\n                }\n                ep = find_string(bp, &i, nadt, NULL, 4);\n                if (ep != NULL) {\n                    tm->tm_isdst = 1;\n#ifdef TM_GMTOFF\n                    tm->TM_GMTOFF = (-4 - i) * SECSPERHOUR;\n#endif\n#ifdef TM_ZONE\n                    tm->TM_ZONE = __UNCONST(nadt[i]);\n#endif\n                    bp = ep;\n                    continue;\n                }\n                /*\n                 * Our current timezone\n                 */\n                ep = find_string(bp, &i,\n                             (const char * const *)tzname,\n                              NULL, 2);\n                if (ep != NULL) {\n                    tm->tm_isdst = i;\n#ifdef TM_GMTOFF\n                    tm->TM_GMTOFF = -timezone;\n#endif\n#ifdef TM_ZONE\n                    tm->TM_ZONE = tzname[i];\n#endif\n                    bp = ep;\n                    continue;\n                }\nloadzone:\n                /*\n                 * The hard way, load the zone!\n                 */\n                if (fromzone(&bp, tm, mandatory))\n                    continue;\n                goto out;\n            }\n            offs = 0;\n            for (i = 0; i < 4; ) {\n                if (isdigit(*bp)) {\n                    offs = offs * 10 + (*bp++ - '0');\n                    i++;\n                    continue;\n                }\n                if (i == 2 && *bp == ':') {\n                    bp++;\n                    continue;\n                }\n                break;\n            }\n            if (isdigit(*bp))\n                goto out;\n            switch (i) {\n            case 2:\n                offs *= SECSPERHOUR;\n                break;\n            case 4:\n                i = offs % 100;\n                offs /= 100;\n                if (i >= SECSPERMIN)\n                    goto out;\n                /* Convert minutes into decimal */\n                offs = offs * SECSPERHOUR + i * SECSPERMIN;\n                break;\n            default:\nout:\n                if (mandatory)\n                    return NULL;\n                bp = zname;\n                continue;\n            }\n            /* ISO 8601 & RFC 3339 limit to 23:59 max */\n            if (offs >= (HOURSPERDAY * SECSPERHOUR))\n                goto out;\n            if (neg)\n                offs = -offs;\n            tm->tm_isdst = 0;\t/* XXX */\n#ifdef TM_GMTOFF\n            tm->TM_GMTOFF = offs;\n#endif\n#ifdef TM_ZONE\n            tm->TM_ZONE = NULL;\t/* XXX */\n#endif\n            continue;\n\n        /*\n         * Miscellaneous conversions.\n         */\n        case 'n':\t/* Any kind of white-space. */\n        case 't':\n            while (isspace(*bp))\n                bp++;\n            LEGAL_ALT(0);\n            continue;\n\n\n        default:\t/* Unknown/unsupported conversion. */\n            return NULL;\n        }\n    }\n\n    if (!HAVE_YDAY(state) && HAVE_YEAR(state)) {\n        if (HAVE_MON(state) && HAVE_MDAY(state)) {\n            /* calculate day of year (ordinal date) */\n            tm->tm_yday =  start_of_month[isleap_sum(tm->tm_year,\n                TM_YEAR_BASE)][tm->tm_mon] + (tm->tm_mday - 1);\n            state |= S_YDAY;\n        } else if (day_offset != -1) {\n            /*\n             * Set the date to the first Sunday (or Monday)\n             * of the specified week of the year.\n             */\n            if (!HAVE_WDAY(state)) {\n                tm->tm_wday = day_offset;\n                state |= S_WDAY;\n            }\n            tm->tm_yday = (7 -\n                first_wday_of(tm->tm_year + TM_YEAR_BASE) +\n                day_offset) % 7 + (week_offset - 1) * 7 +\n                tm->tm_wday  - day_offset;\n            state |= S_YDAY;\n        }\n    }\n\n    if (HAVE_YDAY(state) && HAVE_YEAR(state)) {\n        int isleap;\n\n        if (!HAVE_MON(state)) {\n            /* calculate month of day of year */\n            i = 0;\n            isleap = isleap_sum(tm->tm_year, TM_YEAR_BASE);\n            while (tm->tm_yday >= start_of_month[isleap][i])\n                i++;\n            if (i > 12) {\n                i = 1;\n                tm->tm_yday -= start_of_month[isleap][12];\n                tm->tm_year++;\n            }\n            tm->tm_mon = i - 1;\n            state |= S_MON;\n        }\n\n        if (!HAVE_MDAY(state)) {\n            /* calculate day of month */\n            isleap = isleap_sum(tm->tm_year, TM_YEAR_BASE);\n            tm->tm_mday = tm->tm_yday -\n                start_of_month[isleap][tm->tm_mon] + 1;\n            state |= S_MDAY;\n        }\n\n        if (!HAVE_WDAY(state)) {\n            /* calculate day of week */\n            i = 0;\n            week_offset = first_wday_of(tm->tm_year);\n            while (i++ <= tm->tm_yday) {\n                if (week_offset++ >= 6)\n                    week_offset = 0;\n            }\n            tm->tm_wday = week_offset;\n            state |= S_WDAY;\n        }\n    }\n\n    return (char*)bp;\n}\n\n\nstatic const unsigned char *\nconv_num(const unsigned char *buf, int *dest, unsigned int llim, unsigned int ulim)\n{\n    unsigned int result = 0;\n    unsigned char ch;\n\n    /* The limit also determines the number of valid digits. */\n    unsigned int rulim = ulim;\n\n    ch = *buf;\n    if (ch < '0' || ch > '9')\n        return NULL;\n\n    do {\n        result *= 10;\n        result += ch - '0';\n        rulim /= 10;\n        ch = *++buf;\n    } while ((result <= ulim) && rulim && ch >= '0' && ch <= '9');\n\n    if (result < llim || result > ulim)\n        return NULL;\n\n    *dest = result;\n    return buf;\n}\n\nstatic const unsigned char *\nfind_string(const unsigned char *bp, int *tgt, const char * const *n1,\n        const char * const *n2, int c)\n{\n    int i;\n    size_t len;\n\n    /* check full name - then abbreviated ones */\n    for (; n1 != NULL; n1 = n2, n2 = NULL) {\n        for (i = 0; i < c; i++, n1++) {\n            len = strlen(*n1);\n            if (strncasecmp(*n1, (const char *)bp, len) == 0) {\n                *tgt = i;\n                return bp + len;\n            }\n        }\n    }\n\n    /* Nothing matched */\n    return NULL;\n}\n#endif\n"
  },
  {
    "path": "src/util.h",
    "content": "#ifndef UTIL_H\n#define UTIL_H\n\n#ifdef WIN32\n/* For WriteFile() below */\n#include <windows.h>\n#include <io.h>\n#include <processenv.h>\n#include <shellapi.h>\n#include <wchar.h>\n#include <wtypes.h>\n#endif\n\n#include \"jv.h\"\n\njv expand_path(jv);\njv get_home(void);\njv jq_realpath(jv);\n\n/*\n * The Windows CRT and console are something else.  In order for the\n * console to get UTF-8 written to it correctly we have to bypass stdio\n * completely.  No amount of fflush()ing helps.  If the first byte of a\n * buffer being written with fwrite() is non-ASCII UTF-8 then the\n * console misinterprets the byte sequence.  But one must not\n * WriteFile() if stdout is a file!1!!\n *\n * We carry knowledge of whether the FILE * is a tty everywhere we\n * output to it just so we can write with WriteFile() if stdout is a\n * console on WIN32.\n */\n\nstatic void priv_fwrite(const char *s, size_t len, FILE *fout, int is_tty) {\n#ifdef WIN32\n  if (is_tty)\n    WriteFile((HANDLE)_get_osfhandle(fileno(fout)), s, len, NULL, NULL);\n  else\n    fwrite(s, 1, len, fout);\n#else\n  fwrite(s, 1, len, fout);\n#endif\n}\n\nconst void *_jq_memmem(const void *haystack, size_t haystacklen,\n                       const void *needle, size_t needlelen);\n\n#ifndef MIN\n#define MIN(a,b) \\\n  ({ __typeof__ (a) _a = (a); \\\n   __typeof__ (b) _b = (b); \\\n   _a < _b ? _a : _b; })\n#endif\n#ifndef MAX\n#define MAX(a,b) \\\n  ({ __typeof__ (a) _a = (a); \\\n   __typeof__ (b) _b = (b); \\\n   _a > _b ? _a : _b; })\n#endif\n\n#include <time.h>\n\n#ifndef HAVE_STRPTIME\nchar* strptime(const char *buf, const char *fmt, struct tm *tm);\n#endif\n\n#endif /* UTIL_H */\n"
  },
  {
    "path": "tests/base64.test",
    "content": "# Tests are groups of three lines: program, input, expected output\n# Blank lines and lines starting with # are ignored\n\n@base64\n\"\"\n\"\"\n\n@base64\n\"<>&'\\\"\\t\"\n\"PD4mJyIJ\"\n\n# decoding encoded output results in same text\n(@base64|@base64d)\n\"<>&'\\\"\\t\"\n\"<>&'\\\"\\t\"\n\n# regression test for #436\n@base64\n\"foóbar\\n\"\n\"Zm/Ds2Jhcgo=\"\n\n@base64d\n\"\"\n\"\"\n\n@base64d\n\"=\"\n\"\"\n\n@base64d\n\"Zm/Ds2Jhcgo=\"\n\"foóbar\\n\"\n\n# optional trailing equals padding (With padding, this is cWl4YmF6Cg==)\n@base64d\n\"cWl4YmF6Cg\"\n\"qixbaz\\n\"\n\n# invalid base64 characters (whitespace)\n. | try @base64d catch .\n\"Not base64 data\"\n\"string (\\\"Not base64 data\\\") is not valid base64 data\"\n\n# invalid base64 (too many bytes, QUJD = \"ABCD\"\n. | try @base64d catch .\n\"QUJDa\"\n\"string (\\\"QUJDa\\\") trailing base64 byte found\"\n"
  },
  {
    "path": "tests/base64test",
    "content": "#!/bin/sh\n\n. \"${0%/*}/setup\" \"$@\"\n\n$VALGRIND $Q $JQ -L \"$mods\" --run-tests $JQTESTDIR/base64.test\n"
  },
  {
    "path": "tests/jq-f-test.sh",
    "content": "#!/bin/sh\n# this next line is ignored by jq, which otherwise does not continue comments \\\nexec jq -nef \"$0\" \"$@\"\ntrue\n"
  },
  {
    "path": "tests/jq.test",
    "content": "# Tests are groups of three lines: program, input, expected output\n# Blank lines and lines starting with # are ignored\n\n#\n# Simple value tests to check parser. Input is irrelevant\n#\n\ntrue\nnull\ntrue\n\nfalse\nnull\nfalse\n\nnull\n42\nnull\n\n1\nnull\n1\n\n\n-1\nnull\n-1\n\n# FIXME: much more number testing needed\n\n{}\nnull\n{}\n\n[]\nnull\n[]\n\n{x:-1},{x:-.},{x:-.|abs}\n1\n{\"x\":-1}\n{\"x\":-1}\n{\"x\":1}\n\n# The input line starts with a 0xFEFF (byte order mark) codepoint\n# No, there is no reason to have a byte order mark in UTF8 text.\n# But apparently people do, so jq shouldn't break on it.\n.\n﻿\"byte order mark\"\n\"byte order mark\"\n\n# We test escapes by matching them against Unicode codepoints\n# FIXME: more tests needed for weird unicode stuff (e.g. utf16 pairs)\n\"Aa\\r\\n\\t\\b\\f\\u03bc\"\nnull\n\"Aa\\u000d\\u000a\\u0009\\u0008\\u000c\\u03bc\"\n\n.\n\"Aa\\r\\n\\t\\b\\f\\u03bc\"\n\"Aa\\u000d\\u000a\\u0009\\u0008\\u000c\\u03bc\"\n\n%%FAIL\n\"u\\vw\"\njq: error: Invalid escape at line 1, column 4 (while parsing '\"\\v\"') at <top-level>, line 1, column 3:\n    \"u\\vw\"\n      ^^\n\n\"inter\\(\"pol\" + \"ation\")\"\nnull\n\"interpolation\"\n\n@text,@json,([1,.]|@csv,@tsv),@html,(@uri|.,@urid),@sh,(@base64|.,@base64d)\n\"!()<>&'\\\"\\t\"\n\"!()<>&'\\\"\\t\"\n\"\\\"!()<>&'\\\\\\\"\\\\t\\\"\"\n\"1,\\\"!()<>&'\\\"\\\"\\t\\\"\"\n\"1\\t!()<>&'\\\"\\\\t\"\n\"!()&lt;&gt;&amp;&apos;&quot;\\t\"\n\"%21%28%29%3C%3E%26%27%22%09\"\n\"!()<>&'\\\"\\t\"\n\"'!()<>&'\\\\''\\\"\\t'\"\n\"ISgpPD4mJyIJ\"\n\"!()<>&'\\\"\\t\"\n\n# regression test for #436\n@base64\n\"foóbar\\n\"\n\"Zm/Ds2Jhcgo=\"\n\n@base64d\n\"Zm/Ds2Jhcgo=\"\n\"foóbar\\n\"\n\n@uri\n\"\\u03bc\"\n\"%CE%BC\"\n\n@urid\n\"%CE%BC\"\n\"\\u03bc\"\n\n@html \"<b>\\(.)</b>\"\n\"<script>hax</script>\"\n\"<b>&lt;script&gt;hax&lt;/script&gt;</b>\"\n\n[.[]|tojson|fromjson]\n[\"foo\", 1, [\"a\", 1, \"b\", 2, {\"foo\":\"bar\"}]]\n[\"foo\",1,[\"a\",1,\"b\",2,{\"foo\":\"bar\"}]]\n\n#\n# Dictionary construction syntax\n#\n\n{a: 1}\nnull\n{\"a\":1}\n\n{a,b,(.d):.a,e:.b}\n{\"a\":1, \"b\":2, \"c\":3, \"d\":\"c\"}\n{\"a\":1, \"b\":2, \"c\":1, \"e\":2}\n\n{\"a\",b,\"a$\\(1+1)\"}\n{\"a\":1, \"b\":2, \"c\":3, \"a$2\":4}\n{\"a\":1, \"b\":2, \"a$2\":4}\n\n%%FAIL\n{(0):1}\njq: error: Cannot use number (0) as object key at <top-level>, line 1, column 3:\n    {(0):1}\n      ^\n\n%%FAIL\n{1+2:3}\njq: error: May need parentheses around object key expression at <top-level>, line 1, column 2:\n    {1+2:3}\n     ^^^\n\n%%FAIL\n{non_const:., (0):1}\njq: error: Cannot use number (0) as object key at <top-level>, line 1, column 16:\n    {non_const:., (0):1}\n                   ^\n\n#\n# Field access, piping\n#\n\n.foo\n{\"foo\": 42, \"bar\": 43}\n42\n\n.foo | .bar\n{\"foo\": {\"bar\": 42}, \"bar\": \"badvalue\"}\n42\n\n.foo.bar\n{\"foo\": {\"bar\": 42}, \"bar\": \"badvalue\"}\n42\n\n.foo_bar\n{\"foo_bar\": 2}\n2\n\n.[\"foo\"].bar\n{\"foo\": {\"bar\": 42}, \"bar\": \"badvalue\"}\n42\n\n.\"foo\".\"bar\"\n{\"foo\": {\"bar\": 20}}\n20\n\n.e0, .E1, .E-1, .E+1\n{\"e0\": 1, \"E1\": 2, \"E\": 3}\n1\n2\n2\n4\n\n[.[]|.foo?]\n[1,[2],{\"foo\":3,\"bar\":4},{},{\"foo\":5}]\n[3,null,5]\n\n[.[]|.foo?.bar?]\n[1,[2],[],{\"foo\":3},{\"foo\":{\"bar\":4}},{}]\n[4,null]\n\n[..]\n[1,[[2]],{ \"a\":[1]}]\n[[1,[[2]],{\"a\":[1]}],1,[[2]],[2],2,{\"a\":[1]},[1],1]\n\n[.[]|.[]?]\n[1,null,[],[1,[2,[[3]]]],[{}],[{\"a\":[1,[2]]}]]\n[1,[2,[[3]]],{},{\"a\":[1,[2]]}]\n\n[.[]|.[1:3]?]\n[1,null,true,false,\"abcdef\",{},{\"a\":1,\"b\":2},[],[1,2,3,4,5],[1,2]]\n[null,\"bc\",[],[2,3],[2]]\n\n# chaining/suffix-list, with and without dot\nmap(try .a[] catch ., try .a.[] catch ., .a[]?, .a.[]?)\n[{\"a\": [1,2]}, {\"a\": 123}]\n[1,2,1,2,1,2,1,2,\"Cannot iterate over number (123)\",\"Cannot iterate over number (123)\"]\n\n# oss-fuzz #66070: objects[] leaks if a non-last element throws an error\ntry [\"OK\", (.[] | error)] catch [\"KO\", .]\n{\"a\":[\"b\"],\"c\":[\"d\"]}\n[\"KO\",[\"b\"]]\n\n#\n# Negative array indices\n#\n\ntry (.foo[-1] = 0) catch .\nnull\n\"Out of bounds negative array index\"\n\ntry (.foo[-2] = 0) catch .\nnull\n\"Out of bounds negative array index\"\n\n.[-1] = 5\n[0,1,2]\n[0,1,5]\n\n.[-2] = 5\n[0,1,2]\n[0,5,2]\n\ntry (.[999999999] = 0) catch .\nnull\n\"Array index too large\"\n\n#\n# Multiple outputs, iteration\n#\n\n.[]\n[1,2,3]\n1\n2\n3\n\n1,1\n[]\n1\n1\n\n1,.\n[]\n1\n[]\n\n[.]\n[2]\n[[2]]\n\n[[2]]\n[3]\n[[2]]\n\n[{}]\n[2]\n[{}]\n\n[.[]]\n[\"a\"]\n[\"a\"]\n\n[(.,1),((.,.[]),(2,3))]\n[\"a\",\"b\"]\n[[\"a\",\"b\"],1,[\"a\",\"b\"],\"a\",\"b\",2,3]\n\n[([5,5][]),.,.[]]\n[1,2,3]\n[5,5,[1,2,3],1,2,3]\n\n{x: (1,2)},{x:3} | .x\nnull\n1\n2\n3\n\n[.[-4,-3,-2,-1,0,1,2,3]]\n[1,2,3]\n[null,1,2,3,1,2,3,null]\n\n[range(0;10)]\nnull\n[0,1,2,3,4,5,6,7,8,9]\n\n[range(0,1;3,4)]\nnull\n[0,1,2, 0,1,2,3, 1,2, 1,2,3]\n\n[range(0;10;3)]\nnull\n[0,3,6,9]\n\n[range(0;10;-1)]\nnull\n[]\n\n[range(0;-5;-1)]\nnull\n[0,-1,-2,-3,-4]\n\n[range(0,1;4,5;1,2)]\nnull\n[0,1,2,3,0,2, 0,1,2,3,4,0,2,4, 1,2,3,1,3, 1,2,3,4,1,3]\n\n[while(.<100; .*2)]\n1\n[1,2,4,8,16,32,64]\n\n[(label $here | .[] | if .>1 then break $here else . end), \"hi!\"]\n[0,1,2]\n[0,1,\"hi!\"]\n\n[(label $here | .[] | if .>1 then break $here else . end), \"hi!\"]\n[0,2,1]\n[0,\"hi!\"]\n\n%%FAIL\n. as $foo | break $foo\njq: error: $*label-foo is not defined at <top-level>, line 1, column 13:\n    . as $foo | break $foo\n                ^^^^^^^^^^\n\n[.[]|[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]]\n[1,2,3,4,5]\n[1,2,6,24,120]\n\n[label $out | foreach .[] as $item ([3, null]; if .[0] < 1 then break $out else [.[0] -1, $item] end; .[1])]\n[11,22,33,44,55,66,77,88,99]\n[11,22,33]\n\n[foreach range(5) as $item (0; $item)]\nnull\n[0,1,2,3,4]\n\n[foreach .[] as [$i, $j] (0; . + $i - $j)]\n[[2,1], [5,3], [6,4]]\n[1,3,5]\n\n[foreach .[] as {a:$a} (0; . + $a; -.)]\n[{\"a\":1}, {\"b\":2}, {\"a\":3, \"b\":4}]\n[-1, -1, -4]\n\n[-foreach -.[] as $x (0; . + $x)]\n[1,2,3]\n[1,3,6]\n\n[foreach .[] / .[] as $i (0; . + $i)]\n[1,2]\n[1,3,3.5,4.5]\n\n[foreach .[] as $x (0; . + $x) as $x | $x]\n[1,2,3]\n[1,3,6]\n\n[limit(3; .[])]\n[11,22,33,44,55,66,77,88,99]\n[11,22,33]\n\n[limit(0; error)]\n\"badness\"\n[]\n\n[limit(1; 1, error)]\n\"badness\"\n[1]\n\ntry limit(-1; error) catch .\nnull\n\"limit doesn't support negative count\"\n\n[skip(3; .[])]\n[1,2,3,4,5,6,7,8,9]\n[4,5,6,7,8,9]\n\n[skip(0,2,3,4; .[])]\n[1,2,3]\n[1,2,3,3]\n\n[skip(3; .[])]\n[]\n[]\n\ntry skip(-1; error) catch .\nnull\n\"skip doesn't support negative count\"\n\nnth(1; 0,1,error(\"foo\"))\nnull\n1\n\n[first(range(.)), last(range(.))]\n10\n[0,9]\n\n[first(range(.)), last(range(.))]\n0\n[]\n\n[nth(0,5,9,10,15; range(.)), try nth(-1; range(.)) catch .]\n10\n[0,5,9,\"nth doesn't support negative indices\"]\n\n# Check that first(g) does not extract more than one value from g\nfirst(1,error(\"foo\"))\nnull\n1\n\n#\n# Check that various builtins evaluate all arguments where appropriate,\n# doing cartesian products where appropriate.\n#\n\n# Check that limit does work for each value produced by n!\n[limit(5,7; range(9))]\nnull\n[0,1,2,3,4,0,1,2,3,4,5,6]\n\n# Same check for nth\n[nth(5,7; range(9;0;-1))]\nnull\n[4,2]\n\n# Same check for range/3\n[range(0,1,2;4,3,2;2,3)]\nnull\n[0,2,0,3,0,2,0,0,0,1,3,1,1,1,1,1,2,2,2,2]\n\n# Same check for range/1\n[range(3,5)]\nnull\n[0,1,2,0,1,2,3,4]\n\n# Same check for index/1, rindex/1, indices/1\n[(index(\",\",\"|\"), rindex(\",\",\"|\")), indices(\",\",\"|\")]\n\"a,b|c,d,e||f,g,h,|,|,i,j\"\n[1,3,22,19,[1,5,7,12,14,16,18,20,22],[3,9,10,17,19]]\n\n# Same check for join/1\njoin(\",\",\"/\")\n[\"a\",\"b\",\"c\",\"d\"]\n\"a,b,c,d\"\n\"a/b/c/d\"\n\n[.[]|join(\"a\")]\n[[],[\"\"],[\"\",\"\"],[\"\",\"\",\"\"]]\n[\"\",\"\",\"a\",\"aa\"]\n\n# Same check for flatten/1\nflatten(3,2,1)\n[0, [1], [[2]], [[[3]]]]\n[0,1,2,3]\n[0,1,2,[3]]\n[0,1,[2],[[3]]]\n\n\n#\n# Slices\n#\n\n[.[3:2], .[-5:4], .[:-2], .[-2:], .[3:3][1:], .[10:]]\n[0,1,2,3,4,5,6]\n[[], [2,3], [0,1,2,3,4], [5,6], [], []]\n\n[.[3:2], .[-5:4], .[:-2], .[-2:], .[3:3][1:], .[10:]]\n\"abcdefghi\"\n[\"\",\"\",\"abcdefg\",\"hi\",\"\",\"\"]\n\ndel(.[2:4],.[0],.[-2:])\n[0,1,2,3,4,5,6,7]\n[1,4,5]\n\n.[2:4] = ([], [\"a\",\"b\"], [\"a\",\"b\",\"c\"])\n[0,1,2,3,4,5,6,7]\n[0,1,4,5,6,7]\n[0,1,\"a\",\"b\",4,5,6,7]\n[0,1,\"a\",\"b\",\"c\",4,5,6,7]\n\n# Slices at large offsets (issue #1108)\n#\n# This is written this way because [range(<large number>)] is\n# significantly slower under valgrind than .[<large number>] = value.\n#\n# We range down rather than up so that we have just one realloc.\nreduce range(65540;65536;-1) as $i ([]; .[$i] = $i)|.[65536:]\nnull\n[null,65537,65538,65539,65540]\n\n#\n# Variables\n#\n\n1 as $x | 2 as $y | [$x,$y,$x]\nnull\n[1,2,1]\n\n[1,2,3][] as $x | [[4,5,6,7][$x]]\nnull\n[5]\n[6]\n[7]\n\n42 as $x | . | . | . + 432 | $x + 1\n34324\n43\n\n1 + 2 as $x | -$x\nnull\n-3\n\n\"x\" as $x | \"a\"+\"y\" as $y | $x+\",\"+$y\nnull\n\"x,ay\"\n\n1 as $x | [$x,$x,$x as $x | $x]\nnull\n[1,1,1]\n\n[1, {c:3, d:4}] as [$a, {c:$b, b:$c}] | $a, $b, $c\nnull\n1\n3\nnull\n\n. as {as: $kw, \"str\": $str, (\"e\"+\"x\"+\"p\"): $exp} | [$kw, $str, $exp]\n{\"as\": 1, \"str\": 2, \"exp\": 3}\n[1, 2, 3]\n\n.[] as [$a, $b] | [$b, $a]\n[[1], [1, 2, 3]]\n[null, 1]\n[2, 1]\n\n. as $i | . as [$i] | $i\n[0]\n0\n\n. as [$i] | . as $i | $i\n[0]\n[0]\n\n%%FAIL\n. as [] | null\njq: error: syntax error, unexpected ']', expecting BINDING or '[' or '{' at <top-level>, line 1, column 7:\n    . as [] | null\n          ^\n\n%%FAIL\n. as {} | null\njq: error: syntax error, unexpected '}' at <top-level>, line 1, column 7:\n    . as {} | null\n          ^\n\n%%FAIL\n. as $foo | [$foo, $bar]\njq: error: $bar is not defined at <top-level>, line 1, column 20:\n    . as $foo | [$foo, $bar]\n                       ^^^^\n\n%%FAIL\n. as {(true):$foo} | $foo\njq: error: Cannot use boolean (true) as object key at <top-level>, line 1, column 8:\n    . as {(true):$foo} | $foo\n           ^^^^\n\n# [.,(.[] | {x:.},.),.,.[]]\n\n#\n# Builtin functions\n#\n\n1+1\nnull\n2\n\n1+1\n\"wtasdf\"\n2.0\n\n2-1\nnull\n1\n\n2-(-1)\nnull\n3\n\n1e+0+0.001e3\n\"I wonder what this will be?\"\n20e-1\n\n.+4\n15\n19.0\n\n.+null\n{\"a\":42}\n{\"a\":42}\n\nnull+.\nnull\nnull\n\n.a+.b\n{\"a\":42}\n42\n\n[1,2,3] + [.]\nnull\n[1,2,3,null]\n\n{\"a\":1} + {\"b\":2} + {\"c\":3}\n\"asdfasdf\"\n{\"a\":1, \"b\":2, \"c\":3}\n\n\"asdf\" + \"jkl;\" + . + . + .\n\"some string\"\n\"asdfjkl;some stringsome stringsome string\"\n\n\"\\u0000\\u0020\\u0000\" + .\n\"\\u0000\\u0020\\u0000\"\n\"\\u0000 \\u0000\\u0000 \\u0000\"\n\n42 - .\n11\n31\n\n[1,2,3,4,1] - [.,3]\n1\n[2,4]\n\n[-1 as $x | 1,$x]\nnull\n[1,-1]\n\n[10 * 20, 20 / .]\n4\n[200, 5]\n\n1 + 2 * 2 + 10 / 2\nnull\n10\n\n[16 / 4 / 2, 16 / 4 * 2, 16 - 4 - 2, 16 - 4 + 2]\nnull\n[2, 8, 10, 14]\n\n1e-19 + 1e-20 - 5e-21\nnull\n1.05e-19\n\n1 / 1e-17\nnull\n1e+17\n\n9E999999999, 9999999999E999999990, 1E-999999999, 0.000000001E-999999990\nnull\n9E+999999999\n9.999999999E+999999999\n1E-999999999\n1E-999999999\n\n5E500000000 > 5E-5000000000, 10000E500000000 > 10000E-5000000000\nnull\ntrue\ntrue\n\n# #2825\n(1e999999999, 10e999999999) > (1e-1147483646, 0.1e-1147483646)\nnull\ntrue\ntrue\ntrue\ntrue\n\n25 % 7\nnull\n4\n\n49732 % 472\nnull\n172\n\n[(infinite, -infinite) % (1, -1, infinite)]\nnull\n[0,0,0,0,0,-1]\n\n[nan % 1, 1 % nan | isnan]\nnull\n[true,true]\n\n1 + tonumber + (\"10\" | tonumber)\n4\n15\n\n\"123\\u0000456\" | try tonumber catch .\nnull\n\"string (\\\"123\\\\u0000456\\\") cannot be parsed as a number\"\n\nmap(toboolean)\n[\"false\",\"true\",false,true]\n[false,true,false,true]\n\n.[] | try toboolean catch .\n[null,0,\"tru\",\"truee\",\"fals\",\"falsee\",[],{}]\n\"null (null) cannot be parsed as a boolean\"\n\"number (0) cannot be parsed as a boolean\"\n\"string (\\\"tru\\\") cannot be parsed as a boolean\"\n\"string (\\\"truee\\\") cannot be parsed as a boolean\"\n\"string (\\\"fals\\\") cannot be parsed as a boolean\"\n\"string (\\\"falsee\\\") cannot be parsed as a boolean\"\n\"array ([]) cannot be parsed as a boolean\"\n\"object ({}) cannot be parsed as a boolean\"\n\n\"true\\u0000x\", \"false\\u0000\" | try toboolean catch .\nnull\n\"string (\\\"true\\\\u0000x\\\") cannot be parsed as a boolean\"\n\"string (\\\"false\\\\u0000\\\") cannot be parsed as a boolean\"\n\n[{\"a\":42},.object,10,.num,false,true,null,\"b\",[1,4]] | .[] as $x | [$x == .[]]\n{\"object\": {\"a\":42}, \"num\":10.0}\n[true,  true,  false, false, false, false, false, false, false]\n[true,  true,  false, false, false, false, false, false, false]\n[false, false, true,  true,  false, false, false, false, false]\n[false, false, true,  true,  false, false, false, false, false]\n[false, false, false, false, true,  false, false, false, false]\n[false, false, false, false, false, true,  false, false, false]\n[false, false, false, false, false, false, true,  false, false]\n[false, false, false, false, false, false, false, true,  false]\n[false, false, false, false, false, false, false, false, true ]\n\n[.[] | length]\n[[], {}, [1,2], {\"a\":42}, \"asdf\", \"\\u03bc\"]\n[0, 0, 2, 1, 4, 1]\n\nutf8bytelength\n\"asdf\\u03bc\"\n6\n\n[.[] | try utf8bytelength catch .]\n[[], {}, [1,2], 55, true, false]\n[\"array ([]) only strings have UTF-8 byte length\",\"object ({}) only strings have UTF-8 byte length\",\"array ([1,2]) only strings have UTF-8 byte length\",\"number (55) only strings have UTF-8 byte length\",\"boolean (true) only strings have UTF-8 byte length\",\"boolean (false) only strings have UTF-8 byte length\"]\n\n\nmap(keys)\n[{}, {\"abcd\":1,\"abc\":2,\"abcde\":3}, {\"x\":1, \"z\": 3, \"y\":2}]\n[[], [\"abc\",\"abcd\",\"abcde\"], [\"x\",\"y\",\"z\"]]\n\n[1,2,empty,3,empty,4]\nnull\n[1,2,3,4]\n\nmap(add)\n[[], [1,2,3], [\"a\",\"b\",\"c\"], [[3],[4,5],[6]], [{\"a\":1}, {\"b\":2}, {\"a\":3}]]\n[null, 6, \"abc\", [3,4,5,6], {\"a\":3, \"b\": 2}]\n\nmap_values(.+1)\n[0,1,2]\n[1,2,3]\n\n[add(null), add(range(range(10))), add(empty), add(10,range(10))]\nnull\n[null,120,null,55]\n\n# Real-world use case for add(empty)\n.sum = add(.arr[])\n{\"arr\":[]}\n{\"arr\":[],\"sum\":null}\n\nadd({(.[]):1}) | keys\n[\"a\",\"a\",\"b\",\"a\",\"d\",\"b\",\"d\",\"a\",\"d\"]\n[\"a\",\"b\",\"d\"]\n\n#\n# User-defined functions\n# Oh god.\n#\n\ndef f: . + 1; def g: def g: . + 100; f | g | f; (f | g), g\n3.0\n106.0\n105.0\n\ndef f: (1000,2000); f\n123412345\n1000\n2000\n\ndef f(a;b;c;d;e;f): [a+1,b,c,d,e,f]; f(.[0];.[1];.[0];.[0];.[0];.[0])\n[1,2]\n[2,2,1,1,1,1]\n\ndef f: 1; def g: f, def f: 2; def g: 3; f, def f: g; f, g; def f: 4; [f, def f: g; def g: 5; f, g]+[f,g]\nnull\n[4,1,2,3,3,5,4,1,2,3,3]\n\n# Test precedence of 'def' vs '|'\ndef a: 0; . | a\nnull\n0\n\n# Many arguments\ndef f(a;b;c;d;e;f;g;h;i;j): [j,i,h,g,f,e,d,c,b,a]; f(.[0];.[1];.[2];.[3];.[4];.[5];.[6];.[7];.[8];.[9])\n[0,1,2,3,4,5,6,7,8,9]\n[9,8,7,6,5,4,3,2,1,0]\n\n([1,2] + [4,5])\n[1,2,3]\n[1,2,4,5]\n\ntrue\n[1]\ntrue\n\nnull,1,null\n\"hello\"\nnull\n1\nnull\n\n[1,2,3]\n[5,6]\n[1,2,3]\n\n[.[]|floor]\n[-1.1,1.1,1.9]\n[-2, 1, 1]\n\n[.[]|sqrt]\n[4,9]\n[2,3]\n\n(add / length) as $m | map((. - $m) as $d | $d * $d) | add / length | sqrt\n[2,4,4,4,5,5,7,9]\n2\n\n# Should write a test that calls the -lm function from C (or bc(1)) to\n# check that they match the corresponding jq functions.  However,\n# there's so little template code standing between that it suffices to\n# test a handful of these.  The results were checked by eye against\n# bc(1).\natan * 4 * 1000000|floor / 1000000\n1\n3.141592\n\n[(3.141592 / 2) * (range(0;20) / 20)|cos * 1000000|floor / 1000000]\nnull\n[1,0.996917,0.987688,0.972369,0.951056,0.923879,0.891006,0.85264,0.809017,0.760406,0.707106,0.649448,0.587785,0.522498,0.45399,0.382683,0.309017,0.233445,0.156434,0.078459]\n\n[(3.141592 / 2) * (range(0;20) / 20)|sin * 1000000|floor / 1000000]\nnull\n[0,0.078459,0.156434,0.233445,0.309016,0.382683,0.45399,0.522498,0.587785,0.649447,0.707106,0.760405,0.809016,0.85264,0.891006,0.923879,0.951056,0.972369,0.987688,0.996917]\n\n\ndef f(x): x | x; f([.], . + [42])\n[1,2,3]\n[[[1,2,3]]]\n[[1,2,3],42]\n[[1,2,3,42]]\n[1,2,3,42,42]\n\n# test multiple function arities and redefinition\ndef f: .+1; def g: f; def f: .+100; def f(a):a+.+11; [(g|f(20)), f]\n1\n[33,101]\n\n# test closures and lexical scoping\ndef id(x):x; 2000 as $x | def f(x):1 as $x | id([$x, x, x]); def g(x): 100 as $x | f($x,$x+x); g($x)\n\"more testing\"\n[1,100,2100.0,100,2100.0]\n\n# test def f($a) syntax\ndef x(a;b): a as $a | b as $b | $a + $b; def y($a;$b): $a + $b; def check(a;b): [x(a;b)] == [y(a;b)]; check(.[];.[]*2)\n[1,2,3]\ntrue\n\n# test backtracking through function calls and returns\n# this test is *evil*\n[[20,10][1,0] as $x | def f: (100,200) as $y | def g: [$x + $y, .]; . + $x | g; f[0] | [f][0][1] | f]\n999999999\n[[110.0, 130.0], [210.0, 130.0], [110.0, 230.0], [210.0, 230.0], [120.0, 160.0], [220.0, 160.0], [120.0, 260.0], [220.0, 260.0]]\n\n# test recursion\ndef fac: if . == 1 then 1 else . * (. - 1 | fac) end; [.[] | fac]\n[1,2,3,4]\n[1,2,6,24]\n\n# test stack overflow and reallocation\n# this test is disabled for now, it takes a realllllly long time.\n# def f: if length > 1000 then . else .+[1]|f end; f | length\n# []\n# 1001\n\nreduce .[] as $x (0; . + $x)\n[1,2,4]\n7\n\nreduce .[] as [$i, {j:$j}] (0; . + $i - $j)\n[[2,{\"j\":1}], [5,{\"j\":3}], [6,{\"j\":4}]]\n5\n\nreduce [[1,2,10], [3,4,10]][] as [$i,$j] (0; . + $i * $j)\nnull\n14\n\n[-reduce -.[] as $x (0; . + $x)]\n[1,2,3]\n[6]\n\n[reduce .[] / .[] as $i (0; . + $i)]\n[1,2]\n[4.5]\n\nreduce .[] as $x (0; . + $x) as $x | $x\n[1,2,3]\n6\n\n# This, while useless, should still compile.\nreduce . as $n (.; .)\nnull\nnull\n\n# Destructuring\n. as {$a, b: [$c, {$d}]} | [$a, $c, $d]\n{\"a\":1, \"b\":[2,{\"d\":3}]}\n[1,2,3]\n\n. as {$a, $b:[$c, $d]}| [$a, $b, $c, $d]\n{\"a\":1, \"b\":[2,{\"d\":3}]}\n[1,[2,{\"d\":3}],2,{\"d\":3}]\n\n# Destructuring with alternation\n.[] | . as {$a, b: [$c, {$d}]} ?// [$a, {$b}, $e] ?// $f | [$a, $b, $c, $d, $e, $f]\n[{\"a\":1, \"b\":[2,{\"d\":3}]}, [4, {\"b\":5, \"c\":6}, 7, 8, 9], \"foo\"]\n[1, null, 2, 3, null, null]\n[4, 5, null, null, 7, null]\n[null, null, null, null, null, \"foo\"]\n\n# Destructuring DUP/POP issues\n.[] | . as {a:$a} ?// {a:$a} ?// {a:$a} | $a\n[[3],[4],[5],6]\n# Runtime error: \"jq: Cannot index array with string (\\\"c\\\")\"\n\n.[] as {a:$a} ?// {a:$a} ?// {a:$a} | $a\n[[3],[4],[5],6]\n# Runtime error: \"jq: Cannot index array with string (\\\"c\\\")\"\n\n[[3],[4],[5],6][] | . as {a:$a} ?// {a:$a} ?// {a:$a} | $a\nnull\n# Runtime error: \"jq: Cannot index array with string (\\\"c\\\")\"\n\n[[3],[4],[5],6] | .[] as {a:$a} ?// {a:$a} ?// {a:$a} | $a\nnull\n# Runtime error: \"jq: Cannot index array with string (\\\"c\\\")\"\n\n.[] | . as {a:$a} ?// {a:$a} ?// $a | $a\n[[3],[4],[5],6]\n[3]\n[4]\n[5]\n6\n\n.[] as {a:$a} ?// {a:$a} ?// $a | $a\n[[3],[4],[5],6]\n[3]\n[4]\n[5]\n6\n\n[[3],[4],[5],6][] | . as {a:$a} ?// {a:$a} ?// $a | $a\nnull\n[3]\n[4]\n[5]\n6\n\n[[3],[4],[5],6] | .[] as {a:$a} ?// {a:$a} ?// $a | $a\nnull\n[3]\n[4]\n[5]\n6\n\n.[] | . as {a:$a} ?// $a ?// {a:$a} | $a\n[[3],[4],[5],6]\n[3]\n[4]\n[5]\n6\n\n.[] as {a:$a} ?// $a ?// {a:$a} | $a\n[[3],[4],[5],6]\n[3]\n[4]\n[5]\n6\n\n[[3],[4],[5],6][] | . as {a:$a} ?// $a ?// {a:$a} | $a\nnull\n[3]\n[4]\n[5]\n6\n\n[[3],[4],[5],6] | .[] as {a:$a} ?// $a ?// {a:$a} | $a\nnull\n[3]\n[4]\n[5]\n6\n\n.[] | . as $a ?// {a:$a} ?// {a:$a} | $a\n[[3],[4],[5],6]\n[3]\n[4]\n[5]\n6\n\n.[] as $a ?// {a:$a} ?// {a:$a} | $a\n[[3],[4],[5],6]\n[3]\n[4]\n[5]\n6\n\n[[3],[4],[5],6][] | . as $a ?// {a:$a} ?// {a:$a} | $a\nnull\n[3]\n[4]\n[5]\n6\n\n[[3],[4],[5],6] | .[] as $a ?// {a:$a} ?// {a:$a} | $a\nnull\n[3]\n[4]\n[5]\n6\n\n. as $dot|any($dot[];not)\n[1,2,3,4,true,false,1,2,3,4,5]\ntrue\n\n. as $dot|any($dot[];not)\n[1,2,3,4,true]\nfalse\n\n. as $dot|all($dot[];.)\n[1,2,3,4,true,false,1,2,3,4,5]\nfalse\n\n. as $dot|all($dot[];.)\n[1,2,3,4,true]\ntrue\n\n# Check short-circuiting\nany(true, error; .)\n\"badness\"\ntrue\n\nall(false, error; .)\n\"badness\"\nfalse\n\nany(not)\n[]\nfalse\n\nall(not)\n[]\ntrue\n\nany(not)\n[false]\ntrue\n\nall(not)\n[false]\ntrue\n\n[any,all]\n[]\n[false,true]\n\n[any,all]\n[true]\n[true,true]\n\n[any,all]\n[false]\n[false,false]\n\n[any,all]\n[true,false]\n[true,false]\n\n[any,all]\n[null,null,true]\n[true,false]\n\n#\n# Paths\n#\n\npath(.foo[0,1])\nnull\n[\"foo\", 0]\n[\"foo\", 1]\n\npath(.[] | select(.>3))\n[1,5,3]\n[1]\n\npath(.)\n42\n[]\n\ntry path(.a | map(select(.b == 0))) catch .\n{\"a\":[{\"b\":0}]}\n\"Invalid path expression with result [{\\\"b\\\":0}]\"\n\ntry path(.a | map(select(.b == 0)) | .[0]) catch .\n{\"a\":[{\"b\":0}]}\n\"Invalid path expression near attempt to access element 0 of [{\\\"b\\\":0}]\"\n\ntry path(.a | map(select(.b == 0)) | .c) catch .\n{\"a\":[{\"b\":0}]}\n\"Invalid path expression near attempt to access element \\\"c\\\" of [{\\\"b\\\":0}]\"\n\ntry path(.a | map(select(.b == 0)) | .[]) catch .\n{\"a\":[{\"b\":0}]}\n\"Invalid path expression near attempt to iterate through [{\\\"b\\\":0}]\"\n\npath(.a[path(.b)[0]])\n{\"a\":{\"b\":0}}\n[\"a\",\"b\"]\n\n[paths]\n[1,[[],{\"a\":2}]]\n[[0],[1],[1,0],[1,1],[1,1,\"a\"]]\n\n[\"foo\",1] as $p | getpath($p), setpath($p; 20), delpaths([$p])\n{\"bar\": 42, \"foo\": [\"a\", \"b\", \"c\", \"d\"]}\n\"b\"\n{\"bar\": 42, \"foo\": [\"a\", 20, \"c\", \"d\"]}\n{\"bar\": 42, \"foo\": [\"a\", \"c\", \"d\"]}\n\nmap(getpath([2])), map(setpath([2]; 42)), map(delpaths([[2]]))\n[[0], [0,1], [0,1,2]]\n[null, null, 2]\n[[0,null,42], [0,1,42], [0,1,42]]\n[[0], [0,1], [0,1]]\n\nmap(delpaths([[0,\"foo\"]]))\n[[{\"foo\":2, \"x\":1}], [{\"bar\":2}]]\n[[{\"x\":1}], [{\"bar\":2}]]\n\n[\"foo\",1] as $p | getpath($p), setpath($p; 20), delpaths([$p])\n{\"bar\":false}\nnull\n{\"bar\":false, \"foo\": [null, 20]}\n{\"bar\":false}\n\ndelpaths([[-200]])\n[1,2,3]\n[1,2,3]\n\ntry delpaths(0) catch .\n{}\n\"Paths must be specified as an array\"\n\ndel(.), del(empty), del((.foo,.bar,.baz) | .[2,3,0]), del(.foo[0], .bar[0], .foo, .baz.bar[0].x)\n{\"foo\": [0,1,2,3,4], \"bar\": [0,1]}\nnull\n{\"foo\": [0,1,2,3,4], \"bar\": [0,1]}\n{\"foo\": [1,4], \"bar\": [1]}\n{\"bar\": [1]}\n\ndel(.[1], .[-6], .[2], .[-3:9])\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n[0, 3, 5, 6, 9]\n\ndel(.[nan])\n[1,2,3]\n[1,2,3]\n\ndel(.[nan,nan])\n[1,2,3]\n[1,2,3]\n\n# negative index\nsetpath([-1]; 1)\n[0]\n[1]\n\npick(.a.b.c)\nnull\n{\"a\":{\"b\":{\"c\":null}}}\n\npick(first)\n[1,2]\n[1]\n\npick(first|first)\n[[10,20],30]\n[[10]]\n\n# negative indices in path expressions (since last/1 is .[-1])\ntry pick(last) catch .\n[1,2]\n\"Out of bounds negative array index\"\n\n#\n# Assignment\n#\n.message = \"goodbye\"\n{\"message\": \"hello\"}\n{\"message\": \"goodbye\"}\n\n.foo = .bar\n{\"bar\":42}\n{\"foo\":42, \"bar\":42}\n\n.foo |= .+1\n{\"foo\": 42}\n{\"foo\": 43}\n\n.[] += 2, .[] *= 2, .[] -= 2, .[] /= 2, .[] %=2\n[1,3,5]\n[3,5,7]\n[2,6,10]\n[-1,1,3]\n[0.5, 1.5, 2.5]\n[1,1,1]\n\n[.[] % 7]\n[-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7]\n[0,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,0]\n\n.foo += .foo\n{\"foo\":2}\n{\"foo\":4}\n\n.[0].a |= {\"old\":., \"new\":(.+1)}\n[{\"a\":1,\"b\":2}]\n[{\"a\":{\"old\":1, \"new\":2},\"b\":2}]\n\ndef inc(x): x |= .+1; inc(.[].a)\n[{\"a\":1,\"b\":2},{\"a\":2,\"b\":4},{\"a\":7,\"b\":8}]\n[{\"a\":2,\"b\":2},{\"a\":3,\"b\":4},{\"a\":8,\"b\":8}]\n\n# #1358, getpath/1 should work in path expressions\n.[] | try (getpath([\"a\",0,\"b\"]) |= 5) catch .\n[null,{\"b\":0},{\"a\":0},{\"a\":null},{\"a\":[0,1]},{\"a\":{\"b\":1}},{\"a\":[{}]},{\"a\":[{\"c\":3}]}]\n{\"a\":[{\"b\":5}]}\n{\"b\":0,\"a\":[{\"b\":5}]}\n\"Cannot index number with number (0)\"\n{\"a\":[{\"b\":5}]}\n\"Cannot index number with string (\\\"b\\\")\"\n\"Cannot index object with number (0)\"\n{\"a\":[{\"b\":5}]}\n{\"a\":[{\"c\":3,\"b\":5}]}\n\n# #2051, deletion using assigning empty against arrays\n(.[] | select(. >= 2)) |= empty\n[1,5,3,0,7]\n[1,0]\n\n.[] |= select(. % 2 == 0)\n[0,1,2,3,4,5]\n[0,2,4]\n\n.foo[1,4,2,3] |= empty\n{\"foo\":[0,1,2,3,4,5]}\n{\"foo\":[0,5]}\n\n.[2][3] = 1\n[4]\n[4, null, [null, null, null, 1]]\n\n.foo[2].bar = 1\n{\"foo\":[11], \"bar\":42}\n{\"foo\":[11,null,{\"bar\":1}], \"bar\":42}\n\ntry ((map(select(.a == 1))[].b) = 10) catch .\n[{\"a\":0},{\"a\":1}]\n\"Invalid path expression near attempt to iterate through [{\\\"a\\\":1}]\"\n\ntry ((map(select(.a == 1))[].a) |= .+1) catch .\n[{\"a\":0},{\"a\":1}]\n\"Invalid path expression near attempt to iterate through [{\\\"a\\\":1}]\"\n\ndef x: .[1,2]; x=10\n[0,1,2]\n[0,10,10]\n\ntry (def x: reverse; x=10) catch .\n[0,1,2]\n\"Invalid path expression with result [2,1,0]\"\n\n.[] = 1\n[1,null,Infinity,-Infinity,NaN,-NaN]\n[1,1,1,1,1,1]\n\n#\n# Conditionals\n#\n\n[.[] | if .foo then \"yep\" else \"nope\" end]\n[{\"foo\":0},{\"foo\":1},{\"foo\":[]},{\"foo\":true},{\"foo\":false},{\"foo\":null},{\"foo\":\"foo\"},{}]\n[\"yep\",\"yep\",\"yep\",\"yep\",\"nope\",\"nope\",\"yep\",\"nope\"]\n\n[.[] | if .baz then \"strange\" elif .foo then \"yep\" else \"nope\" end]\n[{\"foo\":0},{\"foo\":1},{\"foo\":[]},{\"foo\":true},{\"foo\":false},{\"foo\":null},{\"foo\":\"foo\"},{}]\n[\"yep\",\"yep\",\"yep\",\"yep\",\"nope\",\"nope\",\"yep\",\"nope\"]\n\n[if 1,null,2 then 3 else 4 end]\nnull\n[3,4,3]\n\n[if empty then 3 else 4 end]\nnull\n[]\n\n[if 1 then 3,4 else 5 end]\nnull\n[3,4]\n\n[if null then 3 else 5,6 end]\nnull\n[5,6]\n\n[if true then 3 end]\n7\n[3]\n\n[if false then 3 end]\n7\n[7]\n\n[if false then 3 else . end]\n7\n[7]\n\n[if false then 3 elif false then 4 end]\n7\n[7]\n\n[if false then 3 elif false then 4 else . end]\n7\n[7]\n\n[-if true then 1 else 2 end]\nnull\n[-1]\n\n{x: if true then 1 else 2 end}\nnull\n{\"x\":1}\n\nif true then [.] else . end []\nnull\nnull\n\n[.[] | [.foo[] // .bar]]\n[{\"foo\":[1,2], \"bar\": 42}, {\"foo\":[1], \"bar\": null}, {\"foo\":[null,false,3], \"bar\": 18}, {\"foo\":[], \"bar\":42}, {\"foo\": [null,false,null], \"bar\": 41}]\n[[1,2], [1], [3], [42], [41]]\n\n.[] //= .[0]\n[\"hello\",true,false,[false],null]\n[\"hello\",true,\"hello\",[false],\"hello\"]\n\n.[] | [.[0] and .[1], .[0] or .[1]]\n[[true,[]], [false,1], [42,null], [null,false]]\n[true,true]\n[false,true]\n[false,true]\n[false,false]\n\n[.[] | not]\n[1,0,false,null,true,\"hello\"]\n[false,false,true,true,false,false]\n\n# Check numeric comparison binops\n[10 > 0, 10 > 10, 10 > 20, 10 < 0, 10 < 10, 10 < 20]\n{}\n[true,false,false,false,false,true]\n\n[10 >= 0, 10 >= 10, 10 >= 20, 10 <= 0, 10 <= 10, 10 <= 20]\n{}\n[true,true,false,false,true,true]\n\n# And some in/equality tests\n[ 10 == 10, 10 != 10, 10 != 11, 10 == 11]\n{}\n[true,false,true,false]\n\n[\"hello\" == \"hello\", \"hello\" != \"hello\", \"hello\" == \"world\", \"hello\" != \"world\" ]\n{}\n[true,false,false,true]\n\n[[1,2,3] == [1,2,3], [1,2,3] != [1,2,3], [1,2,3] == [4,5,6], [1,2,3] != [4,5,6]]\n{}\n[true,false,false,true]\n\n[{\"foo\":42} == {\"foo\":42},{\"foo\":42} != {\"foo\":42}, {\"foo\":42} != {\"bar\":42}, {\"foo\":42} == {\"bar\":42}]\n{}\n[true,false,true,false]\n\n# ugly complicated thing\n[{\"foo\":[1,2,{\"bar\":18},\"world\"]} == {\"foo\":[1,2,{\"bar\":18},\"world\"]},{\"foo\":[1,2,{\"bar\":18},\"world\"]} == {\"foo\":[1,2,{\"bar\":19},\"world\"]}]\n{}\n[true,false]\n\n# containment operator\n[(\"foo\" | contains(\"foo\")), (\"foobar\" | contains(\"foo\")), (\"foo\" | contains(\"foobar\"))]\n{}\n[true, true, false]\n\n# containment operator (embedded NULs!)\n[contains(\"\"), contains(\"\\u0000\")]\n\"\\u0000\"\n[true, true]\n\n[contains(\"\"), contains(\"a\"), contains(\"ab\"), contains(\"c\"), contains(\"d\")]\n\"ab\\u0000cd\"\n[true, true, true, true, true]\n\n[contains(\"cd\"), contains(\"b\\u0000\"), contains(\"ab\\u0000\")]\n\"ab\\u0000cd\"\n[true, true, true]\n\n[contains(\"b\\u0000c\"), contains(\"b\\u0000cd\"), contains(\"b\\u0000cd\")]\n\"ab\\u0000cd\"\n[true, true, true]\n\n[contains(\"@\"), contains(\"\\u0000@\"), contains(\"\\u0000what\")]\n\"ab\\u0000cd\"\n[false, false, false]\n\n\n# Try/catch and general `?` operator\n[.[]|try if . == 0 then error(\"foo\") elif . == 1 then .a elif . == 2 then empty else . end catch .]\n[0,1,2,3]\n[\"foo\",\"Cannot index number with string (\\\"a\\\")\",3]\n\n[.[]|(.a, .a)?]\n[null,true,{\"a\":1}]\n[null,null,1,1]\n\n[[.[]|[.a,.a]]?]\n[null,true,{\"a\":1}]\n[]\n\n[if error then 1 else 2 end?]\n\"foo\"\n[]\n\ntry error(0) // 1\nnull\n1\n\n1, try error(2), 3\nnull\n1\n3\n\n1 + try 2 catch 3 + 4\nnull\n7\n\n[-try .]\n1\n[-1]\n\ntry -.? catch .\n\"foo\"\n\"string (\\\"foo\\\") cannot be negated\"\n\n{x: try 1, y: try error catch 2, z: if true then 3 end}\nnull\n{\"x\":1,\"y\":2,\"z\":3}\n\n{x: 1 + 2, y: false or true, z: null // 3}\nnull\n{\"x\":3,\"y\":true,\"z\":3}\n\n.[] | try error catch .\n[1,null,2]\n1\nnull\n2\n\ntry error(\"\\($__loc__)\") catch .\nnull\n\"{\\\"file\\\":\\\"<top-level>\\\",\\\"line\\\":1}\"\n\n# string operations\n[.[]|startswith(\"foo\")]\n[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"barfoob\"]\n[false, true, false, true, false]\n\n[.[]|endswith(\"foo\")]\n[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"barfoob\"]\n[false, true, true, false, false]\n\n[.[] | split(\", \")]\n[\"a,b, c, d, e,f\",\", a,b, c, d, e,f, \"]\n[[\"a,b\",\"c\",\"d\",\"e,f\"],[\"\",\"a,b\",\"c\",\"d\",\"e,f\",\"\"]]\n\nsplit(\"\")\n\"abc\"\n[\"a\",\"b\",\"c\"]\n\n[.[]|ltrimstr(\"foo\")]\n[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"afoo\"]\n[\"fo\",\"\",\"barfoo\",\"bar\",\"afoo\"]\n\n[.[]|rtrimstr(\"foo\")]\n[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"foob\"]\n[\"fo\",\"\",\"bar\",\"foobar\",\"foob\"]\n\n[.[]|trimstr(\"foo\")]\n[\"fo\", \"foo\", \"barfoo\", \"foobarfoo\", \"foob\"]\n[\"fo\",\"\",\"bar\",\"bar\",\"b\"]\n\n[.[]|ltrimstr(\"\")]\n[\"a\", \"xx\", \"\"]\n[\"a\", \"xx\", \"\"]\n\n[.[]|rtrimstr(\"\")]\n[\"a\", \"xx\", \"\"]\n[\"a\", \"xx\", \"\"]\n\n[.[]|trimstr(\"\")]\n[\"a\", \"xx\", \"\"]\n[\"a\", \"xx\", \"\"]\n\n[(index(\",\"), rindex(\",\")), indices(\",\")]\n\"a,bc,def,ghij,klmno\"\n[1,13,[1,4,8,13]]\n\n[ index(\"aba\"), rindex(\"aba\"), indices(\"aba\") ]\n\"xababababax\"\n[1,7,[1,3,5,7]]\n\n# trim\n# \\u000b is vertical tab (\\v not supported by json)\nmap(trim), map(ltrim), map(rtrim)\n[\" \\n\\t\\r\\f\\u000b\", \"\",\"  \", \"a\", \" a \", \"abc\", \"  abc  \", \"  abc\", \"abc  \"]\n[\"\", \"\", \"\", \"a\", \"a\", \"abc\", \"abc\", \"abc\", \"abc\"]\n[\"\", \"\", \"\", \"a\", \"a \", \"abc\", \"abc  \", \"abc\", \"abc  \"]\n[\"\", \"\", \"\", \"a\", \" a\", \"abc\", \"  abc\", \"  abc\", \"abc\"]\n\ntrim, ltrim, rtrim\n\"\\u0009\\u000A\\u000B\\u000C\\u000D\\u0020\\u0085\\u00A0\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000abc\\u0009\\u000A\\u000B\\u000C\\u000D\\u0020\\u0085\\u00A0\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\"\n\"abc\"\n\"abc\\u0009\\u000A\\u000B\\u000C\\u000D\\u0020\\u0085\\u00A0\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\"\n\"\\u0009\\u000A\\u000B\\u000C\\u000D\\u0020\\u0085\\u00A0\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000abc\"\n\ntry trim catch ., try ltrim catch ., try rtrim catch .\n123\n\"trim input must be a string\"\n\"trim input must be a string\"\n\"trim input must be a string\"\n\nindices(1)\n[0,1,1,2,3,4,1,5]\n[1,2,6]\n\nindices([1,2])\n[0,1,2,3,1,4,2,5,1,2,6,7]\n[1,8]\n\nindices([1,2])\n[1]\n[]\n\nindices(\", \")\n\"a,b, cd,e, fgh, ijkl\"\n[3,9,14]\n\nindex(\"!\")\n\"здравствуй мир!\"\n14\n\n.[:rindex(\"x\")]\n\"正xyz\"\n\"正\"\n\nindices(\"o\")\n\"🇬🇧oo\"\n[2,3]\n\nindices(\"o\")\n\"ƒoo\"\n[1,2]\n\n[.[]|split(\",\")]\n[\"a, bc, def, ghij, jklmn, a,b, c,d, e,f\", \"a,b,c,d, e,f,g,h\"]\n[[\"a\",\" bc\",\" def\",\" ghij\",\" jklmn\",\" a\",\"b\",\" c\",\"d\",\" e\",\"f\"],[\"a\",\"b\",\"c\",\"d\",\" e\",\"f\",\"g\",\"h\"]]\n\n[.[]|split(\", \")]\n[\"a, bc, def, ghij, jklmn, a,b, c,d, e,f\", \"a,b,c,d, e,f,g,h\"]\n[[\"a\",\"bc\",\"def\",\"ghij\",\"jklmn\",\"a,b\",\"c,d\",\"e,f\"],[\"a,b,c,d\",\"e,f,g,h\"]]\n\n[.[] * 3]\n[\"a\", \"ab\", \"abc\"]\n[\"aaa\", \"ababab\", \"abcabcabc\"]\n\n[.[] * \"abc\"]\n[-1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 3.7, 10.0]\n[null,null,\"\",\"\",\"abc\",\"abc\",\"abcabcabc\",\"abcabcabcabcabcabcabcabcabcabc\"]\n\n[. * (nan,-nan)]\n\"abc\"\n[null,null]\n\n. * 100000 | [.[:10],.[-10:]]\n\"abc\"\n[\"abcabcabca\",\"cabcabcabc\"]\n\n. * 1000000000\n\"\"\n\"\"\n\ntry (. * 1000000000) catch .\n\"abc\"\n\"Repeat string result too long\"\n\n[.[] / \",\"]\n[\"a, bc, def, ghij, jklmn, a,b, c,d, e,f\", \"a,b,c,d, e,f,g,h\"]\n[[\"a\",\" bc\",\" def\",\" ghij\",\" jklmn\",\" a\",\"b\",\" c\",\"d\",\" e\",\"f\"],[\"a\",\"b\",\"c\",\"d\",\" e\",\"f\",\"g\",\"h\"]]\n\n[.[] / \", \"]\n[\"a, bc, def, ghij, jklmn, a,b, c,d, e,f\", \"a,b,c,d, e,f,g,h\"]\n[[\"a\",\"bc\",\"def\",\"ghij\",\"jklmn\",\"a,b\",\"c,d\",\"e,f\"],[\"a,b,c,d\",\"e,f,g,h\"]]\n\nmap(.[1] as $needle | .[0] | contains($needle))\n[[[],[]], [[1,2,3], [1,2]], [[1,2,3], [3,1]], [[1,2,3], [4]], [[1,2,3], [1,4]]]\n[true, true, true, false, false]\n\nmap(.[1] as $needle | .[0] | contains($needle))\n[[[\"foobar\", \"foobaz\"], [\"baz\", \"bar\"]], [[\"foobar\", \"foobaz\"], [\"foo\"]], [[\"foobar\", \"foobaz\"], [\"blap\"]]]\n[true, true, false]\n\n[({foo: 12, bar:13} | contains({foo: 12})), ({foo: 12} | contains({})), ({foo: 12, bar:13} | contains({baz:14}))]\n{}\n[true, true, false]\n\n{foo: {baz: 12, blap: {bar: 13}}, bar: 14} | contains({bar: 14, foo: {blap: {}}})\n{}\ntrue\n\n{foo: {baz: 12, blap: {bar: 13}}, bar: 14} | contains({bar: 14, foo: {blap: {bar: 14}}})\n{}\nfalse\n\nsort\n[42,[2,5,3,11],10,{\"a\":42,\"b\":2},{\"a\":42},true,2,[2,6],\"hello\",null,[2,5,6],{\"a\":[],\"b\":1},\"abc\",\"ab\",[3,10],{},false,\"abcd\",null]\n[null,null,false,true,2,10,42,\"ab\",\"abc\",\"abcd\",\"hello\",[2,5,3,11],[2,5,6],[2,6],[3,10],{},{\"a\":42},{\"a\":42,\"b\":2},{\"a\":[],\"b\":1}]\n\n(sort_by(.b) | sort_by(.a)), sort_by(.a, .b), sort_by(.b, .c), group_by(.b), group_by(.a + .b - .c == 2)\n[{\"a\": 1, \"b\": 4, \"c\": 14}, {\"a\": 4, \"b\": 1, \"c\": 3}, {\"a\": 1, \"b\": 4, \"c\": 3}, {\"a\": 0, \"b\": 2, \"c\": 43}]\n[{\"a\": 0, \"b\": 2, \"c\": 43}, {\"a\": 1, \"b\": 4, \"c\": 14}, {\"a\": 1, \"b\": 4, \"c\": 3}, {\"a\": 4, \"b\": 1, \"c\": 3}]\n[{\"a\": 0, \"b\": 2, \"c\": 43}, {\"a\": 1, \"b\": 4, \"c\": 14}, {\"a\": 1, \"b\": 4, \"c\": 3}, {\"a\": 4, \"b\": 1, \"c\": 3}]\n[{\"a\": 4, \"b\": 1, \"c\": 3}, {\"a\": 0, \"b\": 2, \"c\": 43}, {\"a\": 1, \"b\": 4, \"c\": 3}, {\"a\": 1, \"b\": 4, \"c\": 14}]\n[[{\"a\": 4, \"b\": 1, \"c\": 3}], [{\"a\": 0, \"b\": 2, \"c\": 43}], [{\"a\": 1, \"b\": 4, \"c\": 14}, {\"a\": 1, \"b\": 4, \"c\": 3}]]\n[[{\"a\": 1, \"b\": 4, \"c\": 14}, {\"a\": 0, \"b\": 2, \"c\": 43}], [{\"a\": 4, \"b\": 1, \"c\": 3}, {\"a\": 1, \"b\": 4, \"c\": 3}]]\n\nunique\n[1,2,5,3,5,3,1,3]\n[1,2,3,5]\n\nunique\n[]\n[]\n\n[min, max, min_by(.[1]), max_by(.[1]), min_by(.[2]), max_by(.[2])]\n[[4,2,\"a\"],[3,1,\"a\"],[2,4,\"a\"],[1,3,\"a\"]]\n[[1,3,\"a\"],[4,2,\"a\"],[3,1,\"a\"],[2,4,\"a\"],[4,2,\"a\"],[1,3,\"a\"]]\n\n[min,max,min_by(.),max_by(.)]\n[]\n[null,null,null,null]\n\n.foo[.baz]\n{\"foo\":{\"bar\":4},\"baz\":\"bar\"}\n4\n\n.[] | .error = \"no, it's OK\"\n[{\"error\":true}]\n{\"error\": \"no, it's OK\"}\n\n[{a:1}] | .[] | .a=999\nnull\n{\"a\": 999}\n\nto_entries\n{\"a\": 1, \"b\": 2}\n[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]\n\nfrom_entries\n[{\"key\":\"a\", \"value\":1}, {\"Key\":\"b\", \"Value\":2}, {\"name\":\"c\", \"value\":3}, {\"Name\":\"d\", \"Value\":4}]\n{\"a\": 1, \"b\": 2, \"c\": 3, \"d\": 4}\n\nwith_entries(.key |= \"KEY_\" + .)\n{\"a\": 1, \"b\": 2}\n{\"KEY_a\": 1, \"KEY_b\": 2}\n\nmap(has(\"foo\"))\n[{\"foo\": 42}, {}]\n[true, false]\n\nmap(has(2))\n[[0,1], [\"a\",\"b\",\"c\"]]\n[false, true]\n\nhas(nan)\n[0,1,2]\nfalse\n\nkeys\n[42,3,35]\n[0,1,2]\n\n[][.]\n1000000000000000000\nnull\n\nmap([1,2][0:.])\n[-1, 1, 2, 3, 1000000000000000000]\n[[1], [1], [1,2], [1,2], [1,2]]\n\n# Test recursive object merge\n\n{\"k\": {\"a\": 1, \"b\": 2}} * .\n{\"k\": {\"a\": 0,\"c\": 3}}\n{\"k\": {\"a\": 0, \"b\": 2, \"c\": 3}}\n\n{\"k\": {\"a\": 1, \"b\": 2}, \"hello\": {\"x\": 1}} * .\n{\"k\": {\"a\": 0,\"c\": 3}, \"hello\": 1}\n{\"k\": {\"a\": 0, \"b\": 2, \"c\": 3}, \"hello\": 1}\n\n{\"k\": {\"a\": 1, \"b\": 2}, \"hello\": 1} * .\n{\"k\": {\"a\": 0,\"c\": 3}, \"hello\": {\"x\": 1}}\n{\"k\": {\"a\": 0, \"b\": 2, \"c\": 3}, \"hello\": {\"x\": 1}}\n\n{\"a\": {\"b\": 1}, \"c\": {\"d\": 2}, \"e\": 5} * .\n{\"a\": {\"b\": 2}, \"c\": {\"d\": 3, \"f\": 9}}\n{\"a\": {\"b\": 2}, \"c\": {\"d\": 3, \"f\": 9}, \"e\": 5}\n\n[.[]|arrays]\n[1,2,\"foo\",[],[3,[]],{},true,false,null]\n[[],[3,[]]]\n\n[.[]|objects]\n[1,2,\"foo\",[],[3,[]],{},true,false,null]\n[{}]\n\n[.[]|iterables]\n[1,2,\"foo\",[],[3,[]],{},true,false,null]\n[[],[3,[]],{}]\n\n[.[]|scalars]\n[1,2,\"foo\",[],[3,[]],{},true,false,null]\n[1,2,\"foo\",true,false,null]\n\n[.[]|values]\n[1,2,\"foo\",[],[3,[]],{},true,false,null]\n[1,2,\"foo\",[],[3,[]],{},true,false]\n\n[.[]|booleans]\n[1,2,\"foo\",[],[3,[]],{},true,false,null]\n[true,false]\n\n[.[]|nulls]\n[1,2,\"foo\",[],[3,[]],{},true,false,null]\n[null]\n\nflatten\n[0, [1], [[2]], [[[3]]]]\n[0, 1, 2, 3]\n\nflatten(0)\n[0, [1], [[2]], [[[3]]]]\n[0, [1], [[2]], [[[3]]]]\n\nflatten(2)\n[0, [1], [[2]], [[[3]]]]\n[0, 1, 2, [3]]\n\nflatten(2)\n[0, [1, [2]], [1, [[3], 2]]]\n[0, 1, 2, 1, [3], 2]\n\ntry flatten(-1) catch .\n[0, [1], [[2]], [[[3]]]]\n\"flatten depth must not be negative\"\n\ntranspose\n[[1], [2,3]]\n[[1,2],[null,3]]\n\ntranspose\n[]\n[]\n\nascii_upcase\n\"useful but not for é\"\n\"USEFUL BUT NOT FOR é\"\n\nbsearch(0,1,2,3,4)\n[1,2,3]\n-1\n0\n1\n2\n-4\n\nbsearch({x:1})\n[{ \"x\": 0 },{ \"x\": 1 },{ \"x\": 2 }]\n1\n\ntry [\"OK\", bsearch(0)] catch [\"KO\",.]\n\"aa\"\n[\"KO\",\"string (\\\"aa\\\") cannot be searched from\"]\n\nstrftime(\"%Y-%m-%dT%H:%M:%SZ\")\n[2015,2,5,23,51,47,4,63]\n\"2015-03-05T23:51:47Z\"\n\nstrftime(\"%A, %B %d, %Y\")\n1435677542.822351\n\"Tuesday, June 30, 2015\"\n\nstrftime(\"%Y-%m-%dT%H:%M:%SZ\")\n[2024,2,15]\n\"2024-03-15T00:00:00Z\"\n\nmktime\n[2024,8,21]\n1726876800\n\ngmtime\n1425599507\n[2015,2,5,23,51,47,4,63]\n\ngmtime[5]\n1425599507.25\n47.25\n\n# test invalid tm input\ntry strftime(\"%Y-%m-%dT%H:%M:%SZ\") catch .\n[\"a\",1,2,3,4,5,6,7]\n\"strftime/1 requires parsed datetime inputs\"\n\ntry strflocaltime(\"%Y-%m-%dT%H:%M:%SZ\") catch .\n[\"a\",1,2,3,4,5,6,7]\n\"strflocaltime/1 requires parsed datetime inputs\"\n\ntry mktime catch .\n[\"a\",1,2,3,4,5,6,7]\n\"mktime requires parsed datetime inputs\"\n\n# oss-fuzz #67403: non-string argument with number input fails assert\ntry [\"OK\", strftime([])] catch [\"KO\", .]\n0\n[\"KO\",\"strftime/1 requires a string format\"]\n\ntry [\"OK\", strflocaltime({})] catch [\"KO\", .]\n0\n[\"KO\",\"strflocaltime/1 requires a string format\"]\n\n[strptime(\"%Y-%m-%dT%H:%M:%SZ\")|(.,mktime)]\n\"2015-03-05T23:51:47Z\"\n[[2015,2,5,23,51,47,4,63],1425599507]\n\n# Check day-of-week and day of year computations\n# (should trip an assert if this fails)\nlast(range(365 * 67)|(\"1970-03-01T01:02:03Z\"|strptime(\"%Y-%m-%dT%H:%M:%SZ\")|mktime) + (86400 * .)|strftime(\"%Y-%m-%dT%H:%M:%SZ\")|strptime(\"%Y-%m-%dT%H:%M:%SZ\"))\nnull\n[2037,1,11,1,2,3,3,41]\n\n# module system\nimport \"a\" as foo; import \"b\" as bar; def fooa: foo::a; [fooa, bar::a, bar::b, foo::a]\nnull\n[\"a\",\"b\",\"c\",\"a\"]\n\nimport \"c\" as foo; [foo::a, foo::c]\nnull\n[0,\"acmehbah\"]\n\ninclude \"c\"; [a, c]\nnull\n[0,\"acmehbah\"]\n\nimport \"data\" as $e; import \"data\" as $d; [$d[].this,$e[].that,$d::d[].this,$e::e[].that]|join(\";\")\nnull\n\"is a test;is too;is a test;is too\"\n\n# Regression test for #2000\nimport \"data\" as $a; import \"data\" as $b; def f: {$a, $b}; f\nnull\n{\"a\":[{\"this\":\"is a test\",\"that\":\"is too\"}],\"b\":[{\"this\":\"is a test\",\"that\":\"is too\"}]}\n\ninclude \"shadow1\"; e\nnull\n2\n\ninclude \"shadow1\"; include \"shadow2\"; e\nnull\n3\n\nimport \"shadow1\" as f; import \"shadow2\" as f; import \"shadow1\" as e; [e::e, f::e]\nnull\n[2,3]\n\n%%FAIL\nmodule (.+1); 0\njq: error: Module metadata must be constant at <top-level>, line 1, column 8:\n    module (.+1); 0\n           ^^^^^\n\n%%FAIL\nmodule []; 0\njq: error: Module metadata must be an object at <top-level>, line 1, column 8:\n    module []; 0\n           ^^\n\n%%FAIL\ninclude \"a\" (.+1); 0\njq: error: Module metadata must be constant at <top-level>, line 1, column 13:\n    include \"a\" (.+1); 0\n                ^^^^^\n\n%%FAIL\ninclude \"a\" []; 0\njq: error: Module metadata must be an object at <top-level>, line 1, column 13:\n    include \"a\" []; 0\n                ^^\n\n%%FAIL\ninclude \"\\ \"; 0\njq: error: Invalid escape at line 1, column 4 (while parsing '\"\\ \"') at <top-level>, line 1, column 10:\n    include \"\\ \"; 0\n             ^^\n\n%%FAIL\ninclude \"\\(a)\"; 0\njq: error: Import path must be constant at <top-level>, line 1, column 9:\n    include \"\\(a)\"; 0\n            ^^^^^^\n\nmodulemeta\n\"c\"\n{\"whatever\":null,\"deps\":[{\"as\":\"foo\",\"is_data\":false,\"relpath\":\"a\"},{\"search\":\"./\",\"as\":\"d\",\"is_data\":false,\"relpath\":\"d\"},{\"search\":\"./\",\"as\":\"d2\",\"is_data\":false,\"relpath\":\"d\"},{\"search\":\"./../lib/jq\",\"as\":\"e\",\"is_data\":false,\"relpath\":\"e\"},{\"search\":\"./../lib/jq\",\"as\":\"f\",\"is_data\":false,\"relpath\":\"f\"},{\"as\":\"d\",\"is_data\":true,\"relpath\":\"data\"}],\"defs\":[\"a/0\",\"c/0\"]}\n\nmodulemeta | .deps | length\n\"c\"\n6\n\nmodulemeta | .defs | length\n\"c\"\n2\n\n%%FAIL IGNORE MSG\nimport \"syntaxerror\" as e; .\njq: error: syntax error, unexpected ';', expecting end of file at tests/modules/syntaxerror/syntaxerror.jq, line 1, column 4:\n    wat;\n       ^\n\n%%FAIL\n%::wat\njq: error: syntax error, unexpected '%', expecting end of file at <top-level>, line 1, column 1:\n    %::wat\n    ^\n\nimport \"test_bind_order\" as check; check::check\nnull\ntrue\n\ntry -. catch .\n\"very-long-long-long-long-string\"\n\"string (\\\"very-long-long-long-long...\\\") cannot be negated\"\n\ntry (.-.) catch .\n\"very-long-long-long-long-string\"\n\"string (\\\"very-long-long-long-long...\\\") and string (\\\"very-long-long-long-long...\\\") cannot be subtracted\"\n\n\"x\" * range(0; 12; 2) + \"☆\" * 8 | try -. catch .\nnull\n\"string (\\\"☆☆☆☆☆☆☆☆\\\") cannot be negated\"\n\"string (\\\"xx☆☆☆☆☆☆☆☆\\\") cannot be negated\"\n\"string (\\\"xxxx☆☆☆☆☆☆...\\\") cannot be negated\"\n\"string (\\\"xxxxxx☆☆☆☆☆☆...\\\") cannot be negated\"\n\"string (\\\"xxxxxxxx☆☆☆☆☆...\\\") cannot be negated\"\n\"string (\\\"xxxxxxxxxx☆☆☆☆...\\\") cannot be negated\"\n\ntry (. + \"x\") catch . == if have_decnum then \"number (12345678901234567890123456...) and string (\\\"x\\\") cannot be added\" else \"number (12345678901234568000000000...) and string (\\\"x\\\") cannot be added\" end\n123456789012345678901234567890\ntrue\n\njoin(\",\")\n[\"1\",2,true,false,3.4]\n\"1,2,true,false,3.4\"\n\n.[] | join(\",\")\n[[], [null], [null,null], [null,null,null]]\n\"\"\n\"\"\n\",\"\n\",,\"\n\n.[] | join(\",\")\n[[\"a\",null], [null,\"a\"]]\n\"a,\"\n\",a\"\n\ntry join(\",\") catch .\n[\"1\",\"2\",{\"a\":{\"b\":{\"c\":33}}}]\n\"string (\\\"1,2,\\\") and object ({\\\"a\\\":{\\\"b\\\":{\\\"c\\\":33}}}) cannot be added\"\n\ntry join(\",\") catch .\n[\"1\",\"2\",[3,4,5]]\n\"string (\\\"1,2,\\\") and array ([3,4,5]) cannot be added\"\n\n{if:0,and:1,or:2,then:3,else:4,elif:5,end:6,as:7,def:8,reduce:9,foreach:10,try:11,catch:12,label:13,import:14,include:15,module:16}\nnull\n{\"if\":0,\"and\":1,\"or\":2,\"then\":3,\"else\":4,\"elif\":5,\"end\":6,\"as\":7,\"def\":8,\"reduce\":9,\"foreach\":10,\"try\":11,\"catch\":12,\"label\":13,\"import\":14,\"include\":15,\"module\":16}\n\ntry (1/.) catch .\n0\n\"number (1) and number (0) cannot be divided because the divisor is zero\"\n\ntry (1/0) catch .\n0\n\"number (1) and number (0) cannot be divided because the divisor is zero\"\n\ntry (0/0) catch .\n0\n\"number (0) and number (0) cannot be divided because the divisor is zero\"\n\ntry (1%.) catch .\n0\n\"number (1) and number (0) cannot be divided (remainder) because the divisor is zero\"\n\ntry (1%0) catch .\n0\n\"number (1) and number (0) cannot be divided (remainder) because the divisor is zero\"\n\n# Basic numbers tests: integers, powers of two\n[range(-52;52;1)] as $powers | [$powers[]|pow(2;.)|log2|round] == $powers\nnull\ntrue\n\n[range(-99/2;99/2;1)] as $orig | [$orig[]|pow(2;.)|log2] as $back | ($orig|keys)[]|. as $k | (($orig|.[$k])-($back|.[$k]))|if . < 0 then . * -1 else . end|select(.>.00005)\nnull\n\n%%FAIL\n{\njq: error: syntax error, unexpected end of file at <top-level>, line 1, column 1:\n    {\n    ^\n\n%%FAIL\n}\njq: error: syntax error, unexpected INVALID_CHARACTER, expecting end of file at <top-level>, line 1, column 1:\n    }\n    ^\n\n(.[{}] = 0)?\nnull\n\nINDEX(range(5)|[., \"foo\\(.)\"]; .[0])\nnull\n{\"0\":[0,\"foo0\"],\"1\":[1,\"foo1\"],\"2\":[2,\"foo2\"],\"3\":[3,\"foo3\"],\"4\":[4,\"foo4\"]}\n\nJOIN({\"0\":[0,\"abc\"],\"1\":[1,\"bcd\"],\"2\":[2,\"def\"],\"3\":[3,\"efg\"],\"4\":[4,\"fgh\"]}; .[0]|tostring)\n[[5,\"foo\"],[3,\"bar\"],[1,\"foobar\"]]\n[[[5,\"foo\"],null],[[3,\"bar\"],[3,\"efg\"]],[[1,\"foobar\"],[1,\"bcd\"]]]\n\nrange(5;10)|IN(range(10))\nnull\ntrue\ntrue\ntrue\ntrue\ntrue\n\nrange(5;13)|IN(range(0;10;3))\nnull\nfalse\ntrue\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\n\nrange(10;12)|IN(range(10))\nnull\nfalse\nfalse\n\nIN(range(10;20); range(10))\nnull\nfalse\n\nIN(range(5;20); range(10))\nnull\ntrue\n\n# Regression test for #1347\n(.a as $x | .b) = \"b\"\n{\"a\":null,\"b\":null}\n{\"a\":null,\"b\":\"b\"}\n\n# Regression test for #1368\n(.. | select(type == \"object\" and has(\"b\") and (.b | type) == \"array\")|.b) |= .[0]\n{\"a\": {\"b\": [1, {\"b\": 3}]}}\n{\"a\": {\"b\": 1}}\n\nisempty(empty)\nnull\ntrue\n\nisempty(range(3))\nnull\nfalse\n\nisempty(1,error(\"foo\"))\nnull\nfalse\n\n# Regression test for #1815\nindex(\"\")\n\"\"\nnull\n\n# check that dead code removal occurs after builtin it generation\nbuiltins|length > 10\nnull\ntrue\n\n\"-1\"|IN(builtins[] / \"/\"|.[1])\nnull\nfalse\n\nall(builtins[] / \"/\"; .[1]|tonumber >= 0)\nnull\ntrue\n\nbuiltins|any(.[:1] == \"_\")\nnull\nfalse\n\n## Test ability to use keywords (uncomment after eval is pushed)\n#(.[] as $kw | \"\\\"{\\($kw)} as $\\($kw) | $\\($kw) | {$\\($kw)} | {\\($kw):.\\($kw)}\\\"\"|eval|empty),null\n#[\"as\",\"def\",\"module\",\"import\",\"include\",\"if\",\"then\",\"else\",\"elif\",\"end\",\"reduce\",\"foreach\",\"and\",\"or\",\"try\",\"catch\",\"label\",\"break\",\"__loc__\"]\n#null\n#\n#(.[] as $kw | \"\\\"def f($\\($kw)): $\\($kw); f(.)\\\"\"|eval|empty),null\n#[\"as\",\"def\",\"module\",\"import\",\"include\",\"if\",\"then\",\"else\",\"elif\",\"end\",\"reduce\",\"foreach\",\"and\",\"or\",\"try\",\"catch\",\"label\",\"break\",\"__loc__\"]\n#null\n\n\n#\n# Tests to cover the new toliteral number functionality\n# For an example see #1652 and other linked issues\n#\n\n# We are backward and sanity compatible\n\nmap(. == 1)\n[1, 1.0, 1.000, 100e-2, 1e+0, 0.0001e4]\n[true, true, true, true, true, true]\n\n# When no arithmetic is involved jq should preserve the literal value\n\n.[0] | tostring | . == if have_decnum then \"13911860366432393\" else \"13911860366432392\" end\n[13911860366432393]\ntrue\n\n.x | tojson | . == if have_decnum then \"13911860366432393\" else \"13911860366432392\" end\n{\"x\":13911860366432393}\ntrue\n\n(13911860366432393 == 13911860366432392) | . == if have_decnum then false else true end\nnull\ntrue\n\n\n# Applying arithmetic to the value will truncate the result to double\n\n. - 10\n13911860366432393\n13911860366432382\n\n.[0] - 10\n[13911860366432393]\n13911860366432382\n\n.x - 10\n{\"x\":13911860366432393}\n13911860366432382\n\n# Unary negation preserves numerical precision\n-. | tojson == if have_decnum then \"-13911860366432393\" else \"-13911860366432392\" end\n13911860366432393\ntrue\n\n-. | tojson == if have_decnum then \"0.12345678901234567890123456789\" else \"0.12345678901234568\" end\n-0.12345678901234567890123456789\ntrue\n\n[1E+1000,-1E+1000 | tojson] == if have_decnum then [\"1E+1000\",\"-1E+1000\"] else [\"1.7976931348623157e+308\",\"-1.7976931348623157e+308\"] end\nnull\ntrue\n\n. |= try . catch .\n1\n1\n\n# decnum to double conversion\n.[] as $n | $n+0 | [., tostring, . == $n]\n[-9007199254740993, -9007199254740992, 9007199254740992, 9007199254740993, 13911860366432393]\n[-9007199254740992,\"-9007199254740992\",true]\n[-9007199254740992,\"-9007199254740992\",true]\n[9007199254740992,\"9007199254740992\",true]\n[9007199254740992,\"9007199254740992\",true]\n[13911860366432392,\"13911860366432392\",true]\n\n# abs, fabs, length\nabs\n\"abc\"\n\"abc\"\n\nmap(abs)\n[-0, 0, -10, -1.1]\n[0,0,10,1.1]\n\nmap(fabs)\n[-0, 0, -10, -1.1]\n[0,0,10,1.1]\n\nmap(abs == length) | unique\n[-10, -1.1, -1e-1, 1000000000000000002]\n[true]\n\n# The following is NOT prescriptive:\nmap(abs)\n[0.1,1000000000000000002]\n[1e-1, 1000000000000000002]\n\n[1E+1000,-1E+1000 | abs | tojson] | unique == if have_decnum then [\"1E+1000\"] else [\"1.7976931348623157e+308\"] end\nnull\ntrue\n\n[1E+1000,-1E+1000 | length | tojson] | unique == if have_decnum then [\"1E+1000\"] else [\"1.7976931348623157e+308\"] end\nnull\ntrue\n\n# Using a keyword as variable/label name\n\n123 as $label | $label\nnull\n123\n\n[ label $if | range(10) | ., (select(. == 5) | break $if) ]\nnull\n[0,1,2,3,4,5]\n\nreduce .[] as $then (4 as $else | $else; . as $elif | . + $then * $elif)\n[1,2,3]\n96\n\n1 as $foreach | 2 as $and | 3 as $or | { $foreach, $and, $or, a }\n{\"a\":4,\"b\":5}\n{\"foreach\":1,\"and\":2,\"or\":3,\"a\":4}\n\n[ foreach .[] as $try (1 as $catch | $catch - 1; . + $try; .) ]\n[10,9,8,7]\n[10,19,27,34]\n\n\n# Object construction\n\n{ a, $__loc__, c }\n{\"a\":[1,2,3],\"b\":\"foo\",\"c\":{\"hi\":\"hey\"}}\n{\"a\":[1,2,3],\"__loc__\":{\"file\":\"<top-level>\",\"line\":1},\"c\":{\"hi\":\"hey\"}}\n\n1 as $x | \"2\" as $y | \"3\" as $z | { $x, as, $y: 4, ($z): 5, if: 6, foo: 7 }\n{\"as\":8}\n{\"x\":1,\"as\":8,\"2\":4,\"3\":5,\"if\":6,\"foo\":7}\n\n\n# nan is parsed as a valid NaN value from JSON\n\nfromjson | isnan\n\"nan\"\ntrue\n\ntojson | fromjson\n{\"a\":nan}\n{\"a\":null}\n\n# NaN with payload is not parsed\n.[] | try (fromjson | isnan) catch .\n[\"NaN\",\"-NaN\",\"NaN1\",\"NaN10\",\"NaN100\",\"NaN1000\",\"NaN10000\",\"NaN100000\"]\ntrue\ntrue\n\"Invalid numeric literal at EOF at line 1, column 4 (while parsing 'NaN1')\"\n\"Invalid numeric literal at EOF at line 1, column 5 (while parsing 'NaN10')\"\n\"Invalid numeric literal at EOF at line 1, column 6 (while parsing 'NaN100')\"\n\"Invalid numeric literal at EOF at line 1, column 7 (while parsing 'NaN1000')\"\n\"Invalid numeric literal at EOF at line 1, column 8 (while parsing 'NaN10000')\"\n\"Invalid numeric literal at EOF at line 1, column 9 (while parsing 'NaN100000')\"\n\n# calling input/0, or debug/0 in a test doesn't crash jq\n\ntry input catch .\nnull\n\"break\"\n\ndebug\n1\n1\n\n# try/catch catches more than it should #1859\n\"foo\" | try ((try . catch \"caught too much\") | error) catch \"caught just right\"\nnull\n\"caught just right\"\n\n.[]|(try (if .==\"hi\" then . else error end) catch empty) | \"\\(.) there!\"\n[\"hi\",\"ho\"]\n\"hi there!\"\n\ntry ([\"hi\",\"ho\"]|.[]|(try . catch (if .==\"ho\" then \"BROKEN\"|error else empty end)) | if .==\"ho\" then error else \"\\(.) there!\" end) catch \"caught outside \\(.)\"\nnull\n\"hi there!\"\n\"caught outside ho\"\n\n.[]|(try . catch (if .==\"ho\" then \"BROKEN\"|error else empty end)) | if .==\"ho\" then error else \"\\(.) there!\" end\n[\"hi\",\"ho\"]\n\"hi there!\"\n\ntry (try error catch \"inner catch \\(.)\") catch \"outer catch \\(.)\"\n\"foo\"\n\"inner catch foo\"\n\ntry ((try error catch \"inner catch \\(.)\")|error) catch \"outer catch \\(.)\"\n\"foo\"\n\"outer catch inner catch foo\"\n\n# Also #1859, but from #1885\nfirst(.?,.?)\nnull\nnull\n\n# Also #1859, but from #2140\n{foo: \"bar\"} | .foo |= .?\nnull\n{\"foo\": \"bar\"}\n\n# Also #1859, but from #2220\n. |= try 2\n1\n2\n\n. |= try 2 catch 3\n1\n2\n\n.[] |= try tonumber\n[\"1\", \"2a\", \"3\", \" 4\", \"5 \", \"6.7\", \".89\", \"-876\", \"+5.43\", 21]\n[1, 3, 6.7, 0.89, -876, 5.43, 21]\n\n# Also 1859, but from 2073\nany(keys[]|tostring?;true)\n{\"a\":\"1\",\"b\":\"2\",\"c\":\"3\"}\ntrue\n\n\n# explode/implode\n# test replacement character (65533) for outside codepoint range and 0xd800 (55296) - 0xdfff (57343) utf16 surrogate pair range\n# 1.1 and 1.9 to test round down of non-ints\nimplode|explode\n[-1,0,1,2,3,1114111,1114112,55295,55296,57343,57344,1.1,1.9]\n[65533,0,1,2,3,1114111,65533,55295,65533,65533,57344,1,1]\n\nmap(try implode catch .)\n[123,[\"a\"],[nan]]\n[\"implode input must be an array\",\"string (\\\"a\\\") can't be imploded, unicode codepoint needs to be numeric\",\"number (null) can't be imploded, unicode codepoint needs to be numeric\"]\n\ntry 0[implode] catch .\n[]\n\"Cannot index number with string (\\\"\\\")\"\n\n# walk\nwalk(.)\n{\"x\":0}\n{\"x\":0}\n\nwalk(1)\n{\"x\":0}\n1\n\n# The following is a regression test, not a requirement:\n[walk(.,1)]\n{\"x\":0}\n[{\"x\":0},1]\n\n# Issue #2584\nwalk(select(IN({}, []) | not))\n{\"a\":1,\"b\":[]}\n{\"a\":1}\n\n# #2815\n[range(10)] | .[1.2:3.5]\nnull\n[1,2,3]\n\n[range(10)] | .[1.5:3.5]\nnull\n[1,2,3]\n\n[range(10)] | .[1.7:3.5]\nnull\n[1,2,3]\n\n[range(10)] | .[1.7:4294967295]\nnull\n[1,2,3,4,5,6,7,8,9]\n\n[range(10)] | .[1.7:-4294967296]\nnull\n[]\n\n[[range(10)] | .[1.1,1.5,1.7]]\nnull\n[1,1,1]\n\n[range(5)] | .[1.1] = 5\nnull\n[0,5,2,3,4]\n\n[range(3)] | .[nan:1]\nnull\n[0]\n\n[range(3)] | .[1:nan]\nnull\n[1,2]\n\n[range(3)] | .[nan]\nnull\nnull\n\ntry ([range(3)] | .[nan] = 9) catch .\nnull\n\"Cannot set array element at NaN index\"\n\ntry (\"foobar\" | .[1.5:3.5] = \"xyz\") catch .\nnull\n\"Cannot update string slices\"\n\ntry ([range(10)] | .[1.5:3.5] = [\"xyz\"]) catch .\nnull\n[0,\"xyz\",4,5,6,7,8,9]\n\ntry (\"foobar\" | .[1.5]) catch .\nnull\n\"Cannot index string with number (1.5)\"\n\n\n# setpath/2 does not leak the input after an invalid get #2970\n\ntry [\"ok\", setpath([1]; 1)] catch [\"ko\", .]\n{\"hi\":\"hello\"}\n[\"ko\",\"Cannot index object with number (1)\"]\n\ntry fromjson catch .\n\"{'a': 123}\"\n\"Invalid string literal; expected \\\", but got ' at line 1, column 5 (while parsing '{'a': 123}')\"\n\n# ltrimstr/1 rtrimstr/1 don't leak on invalid input #2977\n\ntry ltrimstr(1) catch \"x\", try rtrimstr(1) catch \"x\" | \"ok\"\n\"hi\"\n\"ok\"\n\"ok\"\n\ntry ltrimstr(\"x\") catch \"x\", try rtrimstr(\"x\") catch \"x\" | \"ok\"\n{\"hey\":[]}\n\"ok\"\n\"ok\"\n\n# ltrimstr/1 and rtrimstr/1 return an error for non-strings. #2969\n\n.[] as [$x, $y] | try [\"ok\", ($x | ltrimstr($y))] catch [\"ko\", .]\n[[\"hi\",1],[1,\"hi\"],[\"hi\",\"hi\"],[1,1]]\n[\"ko\",\"startswith() requires string inputs\"]\n[\"ko\",\"startswith() requires string inputs\"]\n[\"ok\",\"\"]\n[\"ko\",\"startswith() requires string inputs\"]\n\n.[] as [$x, $y] | try [\"ok\", ($x | rtrimstr($y))] catch [\"ko\", .]\n[[\"hi\",1],[1,\"hi\"],[\"hi\",\"hi\"],[1,1]]\n[\"ko\",\"endswith() requires string inputs\"]\n[\"ko\",\"endswith() requires string inputs\"]\n[\"ok\",\"\"]\n[\"ko\",\"endswith() requires string inputs\"]\n\n\n# oss-fuzz #66061: setpath/2 leaks when indexing array with array\n\ntry [\"OK\", setpath([[1]]; 1)] catch [\"KO\", .]\n[]\n[\"KO\",\"Cannot update field at array index of array\"]\n\n# regression test for #3227\nforeach .[] as $x (0, 1; . + $x)\n[1, 2]\n1\n3\n2\n4\n\n# regression test for CVE-2025-49014 (use of fmt after free)\n# tests with both empty string literal and empty string created by function\n# as they seems to behave reference wise differently.\nstrflocaltime(\"\" | ., @uri)\n0\n\"\"\n\"\"\n\n# regression tests for #3413\n# upper range bounds should be in sync with the constants defined at\n#   src/jv_parse.c:#define MAX_PARSING_DEPTH (N)\n#   src/jv_print.c:#define MAX_PRINT_DEPTH (N)\n# (N-1)\nreduce range(9999) as $_ ([];[.]) | tojson | fromjson | flatten\nnull\n[]\n\n# (N)\nreduce range(10000) as $_ ([];[.]) | tojson | try (fromjson) catch . | (contains(\"<skipped: too deep>\") | not) and contains(\"Exceeds depth limit for parsing\")\nnull\ntrue\n\n# (N+1)\nreduce range(10001) as $_ ([];[.]) | tojson | contains(\"<skipped: too deep>\")\nnull\ntrue\n"
  },
  {
    "path": "tests/jq_fuzz_compile.c",
    "content": "#include <stdint.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"jq.h\"\n\nint LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {\n  // Creat null-terminated string\n  char *null_terminated = (char *)malloc(size + 1);\n  memcpy(null_terminated, (char *)data, size);\n  null_terminated[size] = '\\0';\n\n  // Fuzzer entrypoint\n  jq_state *jq = NULL;\n  jq = jq_init();\n  if (jq != NULL) {\n    if (jq_compile(jq, null_terminated)) {\n      jq_dump_disassembly(jq, 2);\n    }\n  }\n  jq_teardown(&jq);\n\n  // Free the null-terminated string\n  free(null_terminated);\n\n  return 0;\n}\n"
  },
  {
    "path": "tests/jq_fuzz_execute.cpp",
    "content": "#include <fuzzer/FuzzedDataProvider.h>\n#include <string>\n\n#include \"jq.h\"\n#include \"jv.h\"\n#include \"oniguruma.h\"\n\nextern \"C\" int LLVMFuzzerInitialize(int *argc, char ***argv) {\n  onig_set_parse_depth_limit(1024);\n  return 0;\n}\n\n// Fuzzer inspired by /src/jq_test.c\n// The goal is to have the fuzzer execute the functions:\n// jq_compile -> jv_parse -> jq_next.\nextern \"C\" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {\n  FuzzedDataProvider fdp(data, size);\n  std::string prog_payload = fdp.ConsumeRandomLengthString();\n  std::string parse_payload1 = fdp.ConsumeRandomLengthString();\n  std::string parse_payload2 = fdp.ConsumeRandomLengthString();\n\n  jq_state *jq = NULL;\n  jq = jq_init();\n  if (jq != NULL) {\n    jq_set_attr(jq, jv_string(\"JQ_ORIGIN\"), jv_string(\"/tmp/\"));\n\n    if (jq_compile(jq, prog_payload.c_str())) {\n      // Process to jv_parse and then jv_next\n      jv input = jv_parse(parse_payload1.c_str());\n      if (jv_is_valid(input)) {\n        jq_start(jq, input, 0);\n        jv next = jv_parse(parse_payload2.c_str());\n        if (jv_is_valid(next)) {\n          jv actual = jq_next(jq);\n          jv_free(actual);\n        }\n        jv_free(next);\n      } else {\n        // Only free if input is invalid as otherwise jq_teardown\n        // frees it.\n        jv_free(input);\n      }\n    }\n  }\n  jq_teardown(&jq);\n\n  return 0;\n}\n"
  },
  {
    "path": "tests/jq_fuzz_fixed.cpp",
    "content": "#include <fuzzer/FuzzedDataProvider.h>\n#include <string>\n\n#include \"jq.h\"\n#include \"jv.h\"\n\n\nconst char *jq_progs[] = {\n    \". / \\\", \\\"\",\n    \".[]\",\n    \"$ENV.PAGER\",\n    \".[0]\",\n    \". < 0.12345678901234567890123456788\",\n    \".[] == 1\",\n    \".[] | (1 / .)?\",\n    \"10 / . * 3\",\n    \"[1,2,empty,3]\",\n    \"1, empty, 2\",\n    \"[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]\",\n    \".[-2:]\",\n    \".[-2]\",\n    \".[2]\",\n    \"[ .[] | . * 2]\",\n    \".[2:4]\",\n    \"(. + 2) * 5\",\n    \".[:3]\",\n    \".[4,2]\",\n    \"42 and \\\"a string\\\"\",\n    \"4 - .a\",\n    \". < 5\",\n    \".. | .a?\",\n    \"[.[] | .a?]\",\n    \".a + 1\",\n    \"{a: 1} + {b: 2} + {c: 3} + {a: 42}\",\n    \".a + .b\",\n    \".a = .b\",\n    \".a |= .b\",\n    \"add\",\n    \"all\",\n    \".a + null\",\n    \"any\",\n    \".[] as [$a, $b] | {a: $a, b: $b}\",\n    \". as [$a, $b, {c: $c}] | $a + $b + $c\",\n    \".[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}\",\n    \".[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, \"\n    \"$d, $e}\",\n    \".[] as [$a] ?// [$b] | if $a != null then error(\\\"err: \\\\($a)\\\") else \"\n    \"{$a,$b} end\",\n    \". as $big | [$big, $big + 1] | map(. > \"\n    \"10000000000000000000000000000000)\",\n    \". as $dot|fromstream($dot|tostream)|.==$dot\",\n    \". as $i|[(.*2|. as $i| $i), $i]\",\n    \"ascii_upcase\",\n    \".bar as $x | .foo | . + $x\",\n    \"@base64\",\n    \"@base64d\",\n    \". == {\\\"b\\\": {\\\"d\\\": (4 + 1e-20), \\\"c\\\": 3}, \\\"a\\\":1}\",\n    \"bsearch(0)\",\n    \"bsearch(4) as $ix | if $ix < 0 then .[-(1+$ix)] = 4 else . end\",\n    \"capture(\\\"(?<a>[a-z]+)-(?<n>[0-9]+)\\\")\",\n    \"capture(\\\"(?<a>[a-z]+)-(?<n>[0-9]+)\\\")\",\n    \"combinations\",\n    \"combinations(2)\",\n    \"contains(\\\"bar\\\")\",\n    \"contains([\\\"baz\\\", \\\"bar\\\"])\",\n    \"contains([\\\"bazzzzz\\\", \\\"bar\\\"])\",\n    \"contains({foo: 12, bar: [{barp: 15}]})\",\n    \"def addvalue(f): f as $x | map(. + $x); addvalue(.[0])\",\n    \"def addvalue(f): . + [f]; map(addvalue(.[0]))\",\n    \"def while(cond; update): def _while: if cond then ., (update | \"\n    \"_while) else empty end; _while; [while(.<100; .*2)]\",\n    \"del(.[1, 2])\",\n    \"del(.foo)\",\n    \"delpaths([[\\\"a\\\",\\\"b\\\"]])\",\n    \"empty // 42\",\n    \"[.[]|endswith(\\\"foo\\\")]\",\n    \"env.PAGER\",\n    \"explode\",\n    \". == false\",\n    \"(false, null, 1) // 42\",\n    \"(false, null, 1) | . // 42\",\n    \"flatten\",\n    \"flatten(1)\",\n    \"floor\",\n    \".[\\\"foo\\\"]\",\n    \".[\\\"foo\\\"]?\",\n    \".foo\",\n    \".foo?\",\n    \".foo[]\",\n    \"[.foo?]\",\n    \".foo += 1\",\n    \".foo // 42\",\n    \".foo, .bar\",\n    \"foreach .[] as $item (0; . + $item)\",\n    \"foreach .[] as $item (0; . + $item; [$item, . * 2])\",\n    \"foreach .[] as $item (0; . + 1; {index: ., $item})\",\n    \"fromdate\",\n    \"from_entries\",\n    \"fromstream(1|truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]]))\",\n    \"getpath([\\\"a\\\",\\\"b\\\"])\",\n    \"[getpath([\\\"a\\\",\\\"b\\\"], [\\\"a\\\",\\\"c\\\"])]\",\n    \"group_by(.foo)\",\n    \"[.[] | gsub(\\\", \\\"; \\\":\\\")]\",\n    \"gsub(\\\"$\\\"; \\\"a\\\"; \\\"g\\\")\",\n    \"gsub(\\\"^\\\"; \\\"a\\\")\",\n    \"[gsub(\\\"(?<a>.)\\\"; \\\"\\\\(.a|ascii_upcase)\\\", \\\"\\\\(.a|ascii_downcase)\\\", \"\n    \"\\\"c\\\")]\",\n    \"gsub(\\\"^.*?a\\\"; \\\"b\\\")\",\n    \"gsub(\\\"^.*a\\\"; \\\"b\\\")\",\n    \"gsub(\\\"a\\\";\\\"b\\\")\",\n    \"gsub(\\\"\\\"; \\\"a\\\"; \\\"g\\\")\",\n    \"gsub(\\\"\\\"; \\\"a\\\"; \\\"g\\\")\",\n    \"gsub(\\\"[^a-z]*(?<x>[a-z]*)\\\"; \\\"Z\\\\(.x)\\\")\",\n    \"gsub(\\\"\\\\b(?<x>.)\\\"; \\\"\\\\(.x|ascii_downcase)\\\")\",\n    \"gsub(\\\"(?<d>\\\\d)\\\"; \\\":\\\\(.d);\\\")\",\n    \"gsub(\\\"^\\\"; \\\"\\\"; \\\"g\\\")\",\n    \"[gsub(\\\"p\\\"; \\\"a\\\", \\\"b\\\")]\",\n    \"gsub(\\\"(?=u)\\\"; \\\"u\\\")\",\n    \"gsub(\\\"(.*)\\\"; \\\"\\\"; \\\"x\\\")\",\n    \"gsub(\\\"(?<x>.)[^a]*\\\"; \\\"+\\\\(.x)-\\\")\",\n    \"gsub(\\\"(?<x>.)(?<y>[0-9])\\\"; \\\"\\\\(.x|ascii_downcase)\\\\(.y)\\\")\",\n    \"@html\",\n    \"if . == 0 then   \\\"zero\\\" elif . == 1 then   \\\"one\\\" else   \\\"many\\\" \"\n    \"end\",\n    \"implode\",\n    \"index(\\\", \\\")\",\n    \"index(1)\",\n    \"index([1,2])\",\n    \"indices(\\\", \\\")\",\n    \"indices(1)\",\n    \"indices([1,2])\",\n    \".[] | (infinite * .) < 0\",\n    \"infinite, nan | type\",\n    \".[] | in({\\\"foo\\\": 42})\",\n    \"inside({\\\"foo\\\": 12, \\\"bar\\\":[1,2,{\\\"barp\\\":12, \\\"blip\\\":13}]})\",\n    \"inside({\\\"foo\\\": 12, \\\"bar\\\":[1,2,{\\\"barp\\\":12, \\\"blip\\\":13}]})\",\n    \"inside(\\\"foobar\\\")\",\n    \"inside([\\\"foobar\\\", \\\"foobaz\\\", \\\"blarp\\\"])\",\n    \"inside([\\\"foobar\\\", \\\"foobaz\\\", \\\"blarp\\\"])\",\n    \"isempty(.[])\",\n    \"isempty(.[])\",\n    \"isempty(empty)\",\n    \"join(\\\" \\\")\",\n    \"join(\\\", \\\")\",\n    \"keys\",\n    \"keys\",\n    \".[] | length\",\n    \"[limit(3;.[])]\",\n    \"[.[]|ltrimstr(\\\"foo\\\")]\",\n    \"map(., .)\",\n    \"map(.+1)\",\n    \"map([., . == 1]) | tojson\",\n    \"map(abs)\",\n    \"map(has(2))\",\n    \"map(has(\\\"foo\\\"))\",\n    \"map(in([0,1]))\",\n    \"map(select(. >= 2))\",\n    \"map(type)\",\n    \"map_values(.+1)\",\n    \"map_values(. // empty)\",\n    \"match(\\\"(abc)+\\\"; \\\"g\\\")\",\n    \"[match(\\\"a\\\"; \\\"gi\\\")]\",\n    \"[match(\\\".+?\\\\b\\\")]\",\n    \"[match([\\\"(bar)\\\"])]\",\n    \"match(\\\"foo\\\")\",\n    \"[match([\\\"foo (?<bar123>bar)? foo\\\", \\\"ig\\\"])]\",\n    \"match(\\\"foo (?<bar123>bar)? foo\\\"; \\\"ig\\\")\",\n    \"match([\\\"foo\\\", \\\"ig\\\"])\",\n    \"[match(\\\"\\\"; \\\"g\\\")]\",\n    \"[ match(\\\".\\\"; \\\"g\\\")] | length\",\n    \"[match(\\\"( )*\\\"; \\\"gn\\\")]\",\n    \"max_by(.foo)\",\n    \"min\",\n    \".[] | .name\",\n    \".[]|numbers\",\n    \"[path(..)]\",\n    \"path(.a[0].b)\",\n    \"[paths]\",\n    \"[paths(type == \\\"number\\\")]\",\n    \"pick(.[2], .[0], .[0])\",\n    \"pick(.a, .b.c, .x)\",\n    \"[range(0; 10; -1)]\",\n    \"[range(0; 10; 3)]\",\n    \"[range(0; -5; -1)]\",\n    \"[range(2; 4)]\",\n    \"range(2; 4)\",\n    \"[range(4)]\",\n    \"[range(.)]|[first, last, nth(5)]\",\n    \"recurse\",\n    \"recurse(. * .; . < 20)\",\n    \"recurse(.foo[])\",\n    \"reduce .[] as [$i,$j] (0; . + $i * $j)\",\n    \"reduce .[] as $item (0; . + $item)\",\n    \"reduce .[] as {$x,$y} (null; .x += $x | .y += [$y])\",\n    \"[repeat(.*2, error)?]\",\n    \"reverse\",\n    \"rindex(\\\", \\\")\",\n    \"rindex(1)\",\n    \"rindex([1,2])\",\n    \"[.[]|rtrimstr(\\\"foo\\\")]\",\n    \"[.[] | scan(\\\", \\\")]\",\n    \"[.[] | scan(\\\"b+\\\"; \\\"i\\\")]\",\n    \"scan(\\\"c\\\")\",\n    \".[] | select(.id == \\\"second\\\")\",\n    \"(..|select(type==\\\"boolean\\\")) |= if . then 1 else 0 end\",\n    \"setpath([0,\\\"a\\\"]; 1)\",\n    \"setpath([\\\"a\\\",\\\"b\\\"]; 1)\",\n    \"setpath([\\\"a\\\",\\\"b\\\"]; 1)\",\n    \"@sh \\\"echo \\\\(.)\\\"\",\n    \"sort\",\n    \"sort_by(.foo)\",\n    \"sort_by(.foo, .bar)\",\n    \"split(\\\", *\\\"; null)\",\n    \"splits(\\\", *\\\")\",\n    \"sqrt\",\n    \"[.[]|startswith(\\\"foo\\\")]\",\n    \"strptime(\\\"%Y-%m-%dT%H:%M:%SZ\\\")\",\n    \"strptime(\\\"%Y-%m-%dT%H:%M:%SZ\\\")|mktime\",\n    \"[sub(\\\"(?<a>.)\\\"; \\\"\\\\(.a|ascii_upcase)\\\", \\\"\\\\(.a|ascii_downcase)\\\")]\",\n    \"[sub(\\\"(?<a>.)\\\"; \\\"\\\\(.a|ascii_upcase)\\\", \\\"\\\\(.a|ascii_downcase)\\\", \"\n    \"\\\"c\\\")]\",\n    \"[sub(\\\"a\\\"; \\\"b\\\", \\\"c\\\")]\",\n    \"sub(\\\"[^a-z]*(?<x>[a-z]+)\\\"; \\\"Z\\\\(.x)\\\"; \\\"g\\\")\",\n    \"[.[]|[[sub(\\\", *\\\";\\\":\\\")], [gsub(\\\", *\\\";\\\":\\\")], [scan(\\\", *\\\")]]]\",\n    \"[.[]|[[sub(\\\", +\\\";\\\":\\\")], [gsub(\\\", +\\\";\\\":\\\")], [scan(\\\", +\\\")]]]\",\n    \"sub(\\\"^(?<head>.)\\\"; \\\"Head=\\\\(.head) Tail=\\\")\",\n    \"[test(\\\"ā\\\")]\",\n    \".[] | test(\\\"a b c # spaces are ignored\\\"; \\\"ix\\\")\",\n    \"test(\\\"foo\\\")\",\n    \"to_entries\",\n    \"[., tojson]\",\n    \"[.[]|tojson]\",\n    \"[.[]|tojson|fromjson]\",\n    \".[] | tonumber\",\n    \"[.[] | tonumber?]\",\n    \".[] | tostring\",\n    \"[.[]|tostring]\",\n    \"transpose\",\n    \"[true, false | not]\",\n    \"(true, false) or false\",\n    \"(true, true) and (true, false)\",\n    \"truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]])\",\n    \"[.[]|try .a]\",\n    \"unique\",\n    \"unique_by(.foo)\",\n    \"unique_by(length)\",\n    \".user, .projects[]\",\n    \"[.user, .projects[]]\",\n    \"{(.user): .titles}\",\n    \"{user, title: .titles[]}\",\n    \"utf8bytelength\",\n    \"walk(if type == \\\"array\\\" then sort else . end)\",\n    \"walk( if type == \\\"object\\\" then with_entries( .key |= sub( \\\"^_+\\\"; \"\n    \"\\\"\\\") ) else . end )\",\n    \"[while(.<100; .*2)]\",\n    \"with_entries(.key |= \\\"KEY_\\\" + .)\",\n    \". - [\\\"xml\\\", \\\"yaml\\\"]\",\n};\n\n// Fuzzer inspired by /src/jq_test.c\n// The goal is to have the fuzzer execute the functions:\n// jq_compile -> jv_parse -> jq_next.\nextern \"C\" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {\n  FuzzedDataProvider fdp(data, size);\n  std::string parse_payload1 = fdp.ConsumeRandomLengthString();\n  std::string parse_payload2 = fdp.ConsumeRandomLengthString();\n\n  int idx = fdp.ConsumeIntegralInRange<int>(\n      0, (sizeof(jq_progs) / sizeof(char *)) - 1);\n\n  jq_state *jq = NULL;\n  jq = jq_init();\n  if (jq != NULL) {\n    jq_set_attr(jq, jv_string(\"JQ_ORIGIN\"), jv_string(\"/tmp/\"));\n\n    if (jq_compile(jq, jq_progs[idx])) {\n      // Process to jv_parse and then jv_next\n      jv input = jv_parse(parse_payload1.c_str());\n      if (jv_is_valid(input)) {\n        jq_start(jq, input, 0);\n        jv next = jv_parse(parse_payload2.c_str());\n        if (jv_is_valid(next)) {\n          jv actual = jq_next(jq);\n          jv_free(actual);\n        }\n        jv_free(next);\n      } else {\n        // Only free if input is invalid as otherwise jq_teardown\n        // frees it.\n        jv_free(input);\n      }\n    }\n  }\n  jq_teardown(&jq);\n\n  return 0;\n}\n"
  },
  {
    "path": "tests/jq_fuzz_load_file.c",
    "content": "#include <stdint.h>\n#include <stdlib.h>\n#include <unistd.h>\n\n#include \"jv.h\"\n\nint LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {\n  // Create file with fuzzer data\n  char filename[256];\n  sprintf(filename, \"/tmp/libfuzzer.%d\", getpid());\n  FILE *fp = fopen(filename, \"wb\");\n  if (!fp) {\n    return 0;\n  }\n  fwrite(data, size, 1, fp);\n  fclose(fp);\n\n  // Fuzz the two version of jv_load_file\n  jv data1 = jv_load_file(filename, 1);\n  jv_free(data1);\n  jv data2 = jv_load_file(filename, 0);\n  jv_free(data2);\n\n  // Clean up fuzz file\n  unlink(filename);\n\n  return 0;\n}\n"
  },
  {
    "path": "tests/jq_fuzz_parse.c",
    "content": "#include <stdint.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"jv.h\"\n\nint LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {\n  // Creat null-terminated string\n  char *null_terminated = (char *)malloc(size + 1);\n  memcpy(null_terminated, (char *)data, size);\n  null_terminated[size] = '\\0';\n\n  // Fuzzer entrypoint\n  jv res = jv_parse(null_terminated);\n  jv_free(res);\n\n  // Free the null-terminated string\n  free(null_terminated);\n\n  return 0;\n}\n"
  },
  {
    "path": "tests/jq_fuzz_parse_extended.c",
    "content": "#include <stdint.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"jv.h\"\n\nint LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {\n  if (size < 8) {\n    return 0;\n  }\n\n  int fuzz_flags = *(int*)data;\n  data += 4;\n  size -= 4;\n  int dump_flags = *(int*)data;\n  data += 4;\n  size -= 4;\n\n  // Creat null-terminated string\n  char *null_terminated = (char *)malloc(size + 1);\n  memcpy(null_terminated, (char *)data, size);\n  null_terminated[size] = '\\0';\n\n  // Fuzzer entrypoint\n  jv res = jv_parse_custom_flags(null_terminated, fuzz_flags);\n  if (jv_is_valid(res)) {\n    jv_dump(res, dump_flags);\n  } else {\n    jv_free(res);\n  }\n\n  // Free the null-terminated string\n  free(null_terminated);\n\n  return 0;\n}\n"
  },
  {
    "path": "tests/jq_fuzz_parse_stream.c",
    "content": "#include <stdint.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"jv.h\"\n\nint LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {\n  // Create null-terminated string\n  char *null_terminated = (char *)malloc(size + 1);\n  memcpy(null_terminated, (char *)data, size);\n  null_terminated[size] = '\\0';\n\n  // Use the iterative jv_parser API for streaming mode.\n  // The single-shot jv_parse_custom_flags() returns \"Unexpected extra JSON\n  // values\" for any compound JSON in streaming mode, because the streaming\n  // parser produces multiple tokens but the single-shot API expects exactly\n  // one value.\n  jv_parser *parser = jv_parser_new(JV_PARSE_STREAMING);\n  jv_parser_set_buf(parser, null_terminated, (int)size, 0);\n\n  jv value;\n  while (jv_is_valid(value = jv_parser_next(parser))) {\n    jv_free(value);\n  }\n  jv_free(value);\n\n  jv_parser_free(parser);\n\n  // Free the null-terminated string\n  free(null_terminated);\n\n  return 0;\n}\n"
  },
  {
    "path": "tests/jqtest",
    "content": "#!/bin/sh\n\n. \"${0%/*}/setup\" \"$@\"\n\n$VALGRIND $Q $JQ -L \"$mods\" --run-tests $JQTESTDIR/jq.test\n"
  },
  {
    "path": "tests/local.supp",
    "content": "{\n   macos valgrind 1\n   Memcheck:Leak\n   match-leak-kinds: possible\n   fun:calloc\n   fun:map_images_nolock\n   ...\n   fun:_dyld_objc_notify_register\n   fun:_objc_init\n   fun:_os_object_init\n   fun:libdispatch_init\n   fun:libSystem_initializer\n   ...\n}\n"
  },
  {
    "path": "tests/man.test",
    "content": ".\n\"Hello, world!\"\n\"Hello, world!\"\n\n.\n0.12345678901234567890123456789\n0.12345678901234567890123456789\n\n[., tojson] == if have_decnum then [12345678909876543212345,\"12345678909876543212345\"] else [12345678909876543000000,\"12345678909876543000000\"] end\n12345678909876543212345\ntrue\n\n[1234567890987654321,-1234567890987654321 | tojson] == if have_decnum then [\"1234567890987654321\",\"-1234567890987654321\"] else [\"1234567890987654400\",\"-1234567890987654400\"] end\nnull\ntrue\n\n. < 0.12345678901234567890123456788\n0.12345678901234567890123456789\nfalse\n\nmap([., . == 1]) | tojson == if have_decnum then \"[[1,true],[1.000,true],[1.0,true],[1.00,true]]\" else \"[[1,true],[1,true],[1,true],[1,true]]\" end\n[1, 1.000, 1.0, 100e-2]\ntrue\n\n. as $big | [$big, $big + 1] | map(. > 10000000000000000000000000000000) | . == if have_decnum then [true, false] else [false, false] end\n10000000000000000000000000000001\ntrue\n\n.foo\n{\"foo\": 42, \"bar\": \"less interesting data\"}\n42\n\n.foo\n{\"notfoo\": true, \"alsonotfoo\": false}\nnull\n\n.[\"foo\"]\n{\"foo\": 42}\n42\n\n.foo?\n{\"foo\": 42, \"bar\": \"less interesting data\"}\n42\n\n.foo?\n{\"notfoo\": true, \"alsonotfoo\": false}\nnull\n\n.[\"foo\"]?\n{\"foo\": 42}\n42\n\n[.foo?]\n[1,2]\n[]\n\n.[0]\n[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]\n{\"name\":\"JSON\", \"good\":true}\n\n.[2]\n[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]\nnull\n\n.[-2]\n[1,2,3]\n2\n\n.[2:4]\n[\"a\",\"b\",\"c\",\"d\",\"e\"]\n[\"c\", \"d\"]\n\n.[2:4]\n\"abcdefghi\"\n\"cd\"\n\n.[:3]\n[\"a\",\"b\",\"c\",\"d\",\"e\"]\n[\"a\", \"b\", \"c\"]\n\n.[-2:]\n[\"a\",\"b\",\"c\",\"d\",\"e\"]\n[\"d\", \"e\"]\n\n.[]\n[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]\n{\"name\":\"JSON\", \"good\":true}\n{\"name\":\"XML\", \"good\":false}\n\n.[]\n[]\n\n.foo[]\n{\"foo\":[1,2,3]}\n1\n2\n3\n\n.[]\n{\"a\": 1, \"b\": 1}\n1\n1\n\n.foo, .bar\n{\"foo\": 42, \"bar\": \"something else\", \"baz\": true}\n42\n\"something else\"\n\n.user, .projects[]\n{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}\n\"stedolan\"\n\"jq\"\n\"wikiflow\"\n\n.[4,2]\n[\"a\",\"b\",\"c\",\"d\",\"e\"]\n\"e\"\n\"c\"\n\n.[] | .name\n[{\"name\":\"JSON\", \"good\":true}, {\"name\":\"XML\", \"good\":false}]\n\"JSON\"\n\"XML\"\n\n(. + 2) * 5\n1\n15\n\n[.user, .projects[]]\n{\"user\":\"stedolan\", \"projects\": [\"jq\", \"wikiflow\"]}\n[\"stedolan\", \"jq\", \"wikiflow\"]\n\n[ .[] | . * 2]\n[1, 2, 3]\n[2, 4, 6]\n\n{user, title: .titles[]}\n{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n{\"user\":\"stedolan\", \"title\": \"JQ Primer\"}\n{\"user\":\"stedolan\", \"title\": \"More JQ\"}\n\n{(.user): .titles}\n{\"user\":\"stedolan\",\"titles\":[\"JQ Primer\", \"More JQ\"]}\n{\"stedolan\": [\"JQ Primer\", \"More JQ\"]}\n\n.. | .a?\n[[{\"a\":1}]]\n1\n\n.a + 1\n{\"a\": 7}\n8\n\n.a + .b\n{\"a\": [1,2], \"b\": [3,4]}\n[1,2,3,4]\n\n.a + null\n{\"a\": 1}\n1\n\n.a + 1\n{}\n1\n\n{a: 1} + {b: 2} + {c: 3} + {a: 42}\nnull\n{\"a\": 42, \"b\": 2, \"c\": 3}\n\n4 - .a\n{\"a\":3}\n1\n\n. - [\"xml\", \"yaml\"]\n[\"xml\", \"yaml\", \"json\"]\n[\"json\"]\n\n10 / . * 3\n5\n6\n\n. / \", \"\n\"a, b,c,d, e\"\n[\"a\",\"b,c,d\",\"e\"]\n\n{\"k\": {\"a\": 1, \"b\": 2}} * {\"k\": {\"a\": 0,\"c\": 3}}\nnull\n{\"k\": {\"a\": 0, \"b\": 2, \"c\": 3}}\n\n.[] | (1 / .)?\n[1,0,-1]\n1\n-1\n\nmap(abs)\n[-10, -1.1, -1e-1]\n[10,1.1,1e-1]\n\n.[] | length\n[[1,2], \"string\", {\"a\":2}, null, -5]\n2\n6\n1\n0\n5\n\nutf8bytelength\n\"\\u03bc\"\n2\n\nkeys\n{\"abc\": 1, \"abcd\": 2, \"Foo\": 3}\n[\"Foo\", \"abc\", \"abcd\"]\n\nkeys\n[42,3,35]\n[0,1,2]\n\nmap(has(\"foo\"))\n[{\"foo\": 42}, {}]\n[true, false]\n\nmap(has(2))\n[[0,1], [\"a\",\"b\",\"c\"]]\n[false, true]\n\n.[] | in({\"foo\": 42})\n[\"foo\", \"bar\"]\ntrue\nfalse\n\nmap(in([0,1]))\n[2, 0]\n[false, true]\n\nmap(.+1)\n[1,2,3]\n[2,3,4]\n\nmap_values(.+1)\n{\"a\": 1, \"b\": 2, \"c\": 3}\n{\"a\": 2, \"b\": 3, \"c\": 4}\n\nmap(., .)\n[1,2]\n[1,1,2,2]\n\nmap_values(. // empty)\n{\"a\": null, \"b\": true, \"c\": false}\n{\"b\":true}\n\npick(.a, .b.c, .x)\n{\"a\": 1, \"b\": {\"c\": 2, \"d\": 3}, \"e\": 4}\n{\"a\":1,\"b\":{\"c\":2},\"x\":null}\n\npick(.[2], .[0], .[0])\n[1,2,3,4]\n[1,null,3]\n\npath(.a[0].b)\nnull\n[\"a\",0,\"b\"]\n\n[path(..)]\n{\"a\":[{\"b\":1}]}\n[[],[\"a\"],[\"a\",0],[\"a\",0,\"b\"]]\n\ndel(.foo)\n{\"foo\": 42, \"bar\": 9001, \"baz\": 42}\n{\"bar\": 9001, \"baz\": 42}\n\ndel(.[1, 2])\n[\"foo\", \"bar\", \"baz\"]\n[\"foo\"]\n\ngetpath([\"a\",\"b\"])\nnull\nnull\n\n[getpath([\"a\",\"b\"], [\"a\",\"c\"])]\n{\"a\":{\"b\":0, \"c\":1}}\n[0, 1]\n\nsetpath([\"a\",\"b\"]; 1)\nnull\n{\"a\": {\"b\": 1}}\n\nsetpath([\"a\",\"b\"]; 1)\n{\"a\":{\"b\":0}}\n{\"a\": {\"b\": 1}}\n\nsetpath([0,\"a\"]; 1)\nnull\n[{\"a\":1}]\n\ndelpaths([[\"a\",\"b\"]])\n{\"a\":{\"b\":1},\"x\":{\"y\":2}}\n{\"a\":{},\"x\":{\"y\":2}}\n\nto_entries\n{\"a\": 1, \"b\": 2}\n[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]\n\nfrom_entries\n[{\"key\":\"a\", \"value\":1}, {\"key\":\"b\", \"value\":2}]\n{\"a\": 1, \"b\": 2}\n\nwith_entries(.key |= \"KEY_\" + .)\n{\"a\": 1, \"b\": 2}\n{\"KEY_a\": 1, \"KEY_b\": 2}\n\nmap(select(. >= 2))\n[1,5,3,0,7]\n[5,3,7]\n\n.[] | select(.id == \"second\")\n[{\"id\": \"first\", \"val\": 1}, {\"id\": \"second\", \"val\": 2}]\n{\"id\": \"second\", \"val\": 2}\n\n.[]|numbers\n[[],{},1,\"foo\",null,true,false]\n1\n\n1, empty, 2\nnull\n1\n2\n\n[1,2,empty,3]\nnull\n[1,2,3]\n\ntry error catch .\n\"error message\"\n\"error message\"\n\ntry error(\"invalid value: \\(.)\") catch .\n42\n\"invalid value: 42\"\n\ntry error(\"\\($__loc__)\") catch .\nnull\n\"{\\\"file\\\":\\\"<top-level>\\\",\\\"line\\\":1}\"\n\n[paths]\n[1,[[],{\"a\":2}]]\n[[0],[1],[1,0],[1,1],[1,1,\"a\"]]\n\n[paths(type == \"number\")]\n[1,[[],{\"a\":2}]]\n[[0],[1,1,\"a\"]]\n\nadd\n[\"a\",\"b\",\"c\"]\n\"abc\"\n\nadd\n[1, 2, 3]\n6\n\nadd\n[]\nnull\n\nadd(.[].a)\n[{\"a\":3}, {\"a\":5}, {\"b\":6}]\n8\n\nany\n[true, false]\ntrue\n\nany\n[false, false]\nfalse\n\nany\n[]\nfalse\n\nall\n[true, false]\nfalse\n\nall\n[true, true]\ntrue\n\nall\n[]\ntrue\n\nflatten\n[1, [2], [[3]]]\n[1, 2, 3]\n\nflatten(1)\n[1, [2], [[3]]]\n[1, 2, [3]]\n\nflatten\n[[]]\n[]\n\nflatten\n[{\"foo\": \"bar\"}, [{\"foo\": \"baz\"}]]\n[{\"foo\": \"bar\"}, {\"foo\": \"baz\"}]\n\nrange(2; 4)\nnull\n2\n3\n\n[range(2; 4)]\nnull\n[2,3]\n\n[range(4)]\nnull\n[0,1,2,3]\n\n[range(0; 10; 3)]\nnull\n[0,3,6,9]\n\n[range(0; 10; -1)]\nnull\n[]\n\n[range(0; -5; -1)]\nnull\n[0,-1,-2,-3,-4]\n\nfloor\n3.14159\n3\n\nsqrt\n9\n3\n\n.[] | tonumber\n[1, \"1\"]\n1\n1\n\n.[] | toboolean\n[\"true\", \"false\", true, false]\ntrue\nfalse\ntrue\nfalse\n\n.[] | tostring\n[1, \"1\", [1]]\n\"1\"\n\"1\"\n\"[1]\"\n\nmap(type)\n[0, false, [], {}, null, \"hello\"]\n[\"number\", \"boolean\", \"array\", \"object\", \"null\", \"string\"]\n\n.[] | (infinite * .) < 0\n[-1, 1]\ntrue\nfalse\n\ninfinite, nan | type\nnull\n\"number\"\n\"number\"\n\nsort\n[8,3,null,6]\n[null,3,6,8]\n\nsort_by(.foo)\n[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":10}, {\"foo\":2, \"bar\":1}]\n[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":4, \"bar\":10}]\n\nsort_by(.foo, .bar)\n[{\"foo\":4, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}]\n[{\"foo\":2, \"bar\":1}, {\"foo\":3, \"bar\":10}, {\"foo\":3, \"bar\":20}, {\"foo\":4, \"bar\":10}]\n\ngroup_by(.foo)\n[{\"foo\":1, \"bar\":10}, {\"foo\":3, \"bar\":100}, {\"foo\":1, \"bar\":1}]\n[[{\"foo\":1, \"bar\":10}, {\"foo\":1, \"bar\":1}], [{\"foo\":3, \"bar\":100}]]\n\nmin\n[5,4,2,7]\n2\n\nmax_by(.foo)\n[{\"foo\":1, \"bar\":14}, {\"foo\":2, \"bar\":3}]\n{\"foo\":2, \"bar\":3}\n\nunique\n[1,2,5,3,5,3,1,3]\n[1,2,3,5]\n\nunique_by(.foo)\n[{\"foo\": 1, \"bar\": 2}, {\"foo\": 1, \"bar\": 3}, {\"foo\": 4, \"bar\": 5}]\n[{\"foo\": 1, \"bar\": 2}, {\"foo\": 4, \"bar\": 5}]\n\nunique_by(length)\n[\"chunky\", \"bacon\", \"kitten\", \"cicada\", \"asparagus\"]\n[\"bacon\", \"chunky\", \"asparagus\"]\n\nreverse\n[1,2,3,4]\n[4,3,2,1]\n\ncontains(\"bar\")\n\"foobar\"\ntrue\n\ncontains([\"baz\", \"bar\"])\n[\"foobar\", \"foobaz\", \"blarp\"]\ntrue\n\ncontains([\"bazzzzz\", \"bar\"])\n[\"foobar\", \"foobaz\", \"blarp\"]\nfalse\n\ncontains({foo: 12, bar: [{barp: 12}]})\n{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}\ntrue\n\ncontains({foo: 12, bar: [{barp: 15}]})\n{\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]}\nfalse\n\nindices(\", \")\n\"a,b, cd, efg, hijk\"\n[3,7,12]\n\nindices(1)\n[0,1,2,1,3,1,4]\n[1,3,5]\n\nindices([1,2])\n[0,1,2,3,1,4,2,5,1,2,6,7]\n[1,8]\n\nindex(\", \")\n\"a,b, cd, efg, hijk\"\n3\n\nindex(1)\n[0,1,2,1,3,1,4]\n1\n\nindex([1,2])\n[0,1,2,3,1,4,2,5,1,2,6,7]\n1\n\nrindex(\", \")\n\"a,b, cd, efg, hijk\"\n12\n\nrindex(1)\n[0,1,2,1,3,1,4]\n5\n\nrindex([1,2])\n[0,1,2,3,1,4,2,5,1,2,6,7]\n8\n\ninside(\"foobar\")\n\"bar\"\ntrue\n\ninside([\"foobar\", \"foobaz\", \"blarp\"])\n[\"baz\", \"bar\"]\ntrue\n\ninside([\"foobar\", \"foobaz\", \"blarp\"])\n[\"bazzzzz\", \"bar\"]\nfalse\n\ninside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})\n{\"foo\": 12, \"bar\": [{\"barp\": 12}]}\ntrue\n\ninside({\"foo\": 12, \"bar\":[1,2,{\"barp\":12, \"blip\":13}]})\n{\"foo\": 12, \"bar\": [{\"barp\": 15}]}\nfalse\n\n[.[]|startswith(\"foo\")]\n[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"barfoob\"]\n[false, true, false, true, false]\n\n[.[]|endswith(\"foo\")]\n[\"foobar\", \"barfoo\"]\n[false, true]\n\ncombinations\n[[1,2], [3, 4]]\n[1, 3]\n[1, 4]\n[2, 3]\n[2, 4]\n\ncombinations(2)\n[0, 1]\n[0, 0]\n[0, 1]\n[1, 0]\n[1, 1]\n\n[.[]|ltrimstr(\"foo\")]\n[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"afoo\"]\n[\"fo\",\"\",\"barfoo\",\"bar\",\"afoo\"]\n\n[.[]|rtrimstr(\"foo\")]\n[\"fo\", \"foo\", \"barfoo\", \"foobar\", \"foob\"]\n[\"fo\",\"\",\"bar\",\"foobar\",\"foob\"]\n\n[.[]|trimstr(\"foo\")]\n[\"fo\", \"foo\", \"barfoo\", \"foobarfoo\", \"foob\"]\n[\"fo\",\"\",\"bar\",\"bar\",\"b\"]\n\ntrim, ltrim, rtrim\n\" abc \"\n\"abc\"\n\"abc \"\n\" abc\"\n\nexplode\n\"foobar\"\n[102,111,111,98,97,114]\n\nimplode\n[65, 66, 67]\n\"ABC\"\n\njoin(\", \")\n[\"a\",\"b,c,d\",\"e\"]\n\"a, b,c,d, e\"\n\njoin(\" \")\n[\"a\",1,2.3,true,null,false]\n\"a 1 2.3 true  false\"\n\nascii_upcase\n\"useful but not for é\"\n\"USEFUL BUT NOT FOR é\"\n\n[while(.<100; .*2)]\n1\n[1,2,4,8,16,32,64]\n\n[repeat(.*2, error)?]\n1\n[2]\n\n[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]\n4\n24\n\nrecurse(.foo[])\n{\"foo\":[{\"foo\": []}, {\"foo\":[{\"foo\":[]}]}]}\n{\"foo\":[{\"foo\":[]},{\"foo\":[{\"foo\":[]}]}]}\n{\"foo\":[]}\n{\"foo\":[{\"foo\":[]}]}\n{\"foo\":[]}\n\nrecurse\n{\"a\":0,\"b\":[1]}\n{\"a\":0,\"b\":[1]}\n0\n[1]\n1\n\nrecurse(. * .; . < 20)\n2\n2\n4\n16\n\nwalk(if type == \"array\" then sort else . end)\n[[4, 1, 7], [8, 5, 2], [3, 6, 9]]\n[[1,4,7],[2,5,8],[3,6,9]]\n\n$ENV.PAGER\nnull\n\"less\"\n\nenv.PAGER\nnull\n\"less\"\n\ntranspose\n[[1], [2,3]]\n[[1,2],[null,3]]\n\nbsearch(0)\n[0,1]\n0\n\nbsearch(0)\n[1,2,3]\n-1\n\nbsearch(4) as $ix | if $ix < 0 then .[-(1+$ix)] = 4 else . end\n[1,2,3]\n[1,2,3,4]\n\n\"The input was \\(.), which is one less than \\(.+1)\"\n42\n\"The input was 42, which is one less than 43\"\n\n[.[]|tostring]\n[1, \"foo\", [\"foo\"]]\n[\"1\",\"foo\",\"[\\\"foo\\\"]\"]\n\n[.[]|tojson]\n[1, \"foo\", [\"foo\"]]\n[\"1\",\"\\\"foo\\\"\",\"[\\\"foo\\\"]\"]\n\n[.[]|tojson|fromjson]\n[1, \"foo\", [\"foo\"]]\n[1,\"foo\",[\"foo\"]]\n\n@html\n\"This works if x < y\"\n\"This works if x &lt; y\"\n\n@sh \"echo \\(.)\"\n\"O'Hara's Ale\"\n\"echo 'O'\\\\''Hara'\\\\''s Ale'\"\n\n@base64\n\"This is a message\"\n\"VGhpcyBpcyBhIG1lc3NhZ2U=\"\n\n@base64d\n\"VGhpcyBpcyBhIG1lc3NhZ2U=\"\n\"This is a message\"\n\nfromdate\n\"2015-03-05T23:51:47Z\"\n1425599507\n\nstrptime(\"%Y-%m-%dT%H:%M:%SZ\")\n\"2015-03-05T23:51:47Z\"\n[2015,2,5,23,51,47,4,63]\n\nstrptime(\"%Y-%m-%dT%H:%M:%SZ\")|mktime\n\"2015-03-05T23:51:47Z\"\n1425599507\n\n. == false\nnull\nfalse\n\n. == {\"b\": {\"d\": (4 + 1e-20), \"c\": 3}, \"a\":1}\n{\"a\":1, \"b\": {\"c\": 3, \"d\": 4}}\ntrue\n\n.[] == 1\n[1, 1.0, \"1\", \"banana\"]\ntrue\ntrue\nfalse\nfalse\n\nif . == 0 then   \"zero\" elif . == 1 then   \"one\" else   \"many\" end\n2\n\"many\"\n\n. < 5\n2\ntrue\n\n42 and \"a string\"\nnull\ntrue\n\n(true, false) or false\nnull\ntrue\nfalse\n\n(true, true) and (true, false)\nnull\ntrue\nfalse\ntrue\nfalse\n\n[true, false | not]\nnull\n[false, true]\n\nempty // 42\nnull\n42\n\n.foo // 42\n{\"foo\": 19}\n19\n\n.foo // 42\n{}\n42\n\n(false, null, 1) // 42\nnull\n1\n\n(false, null, 1) | . // 42\nnull\n42\n42\n1\n\ntry .a catch \". is not an object\"\ntrue\n\". is not an object\"\n\n[.[]|try .a]\n[{}, true, {\"a\":1}]\n[null, 1]\n\ntry error(\"some exception\") catch .\ntrue\n\"some exception\"\n\n[.[] | .a?]\n[{}, true, {\"a\":1}]\n[null, 1]\n\n[.[] | tonumber?]\n[\"1\", \"invalid\", \"3\", 4]\n[1, 3, 4]\n\n.bar as $x | .foo | . + $x\n{\"foo\":10, \"bar\":200}\n210\n\n. as $i|[(.*2|. as $i| $i), $i]\n5\n[10,5]\n\n. as [$a, $b, {c: $c}] | $a + $b + $c\n[2, 3, {\"c\": 4, \"d\": 5}]\n9\n\n.[] as [$a, $b] | {a: $a, b: $b}\n[[0], [0, 1], [2, 1, 0]]\n{\"a\":0,\"b\":null}\n{\"a\":0,\"b\":1}\n{\"a\":2,\"b\":1}\n\n.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}\n[{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]\n{\"a\":1,\"b\":2,\"d\":3,\"e\":4}\n{\"a\":1,\"b\":2,\"d\":3,\"e\":4}\n\n.[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}\n[{\"a\": 1, \"b\": 2, \"c\": {\"d\": 3, \"e\": 4}}, {\"a\": 1, \"b\": 2, \"c\": [{\"d\": 3, \"e\": 4}]}]\n{\"a\":1,\"b\":2,\"d\":3,\"e\":null}\n{\"a\":1,\"b\":2,\"d\":null,\"e\":4}\n\n.[] as [$a] ?// [$b] | if $a != null then error(\"err: \\($a)\") else {$a,$b} end\n[[3]]\n{\"a\":null,\"b\":3}\n\ndef addvalue(f): . + [f]; map(addvalue(.[0]))\n[[1,2],[10,20]]\n[[1,2,1], [10,20,10]]\n\ndef addvalue(f): f as $x | map(. + $x); addvalue(.[0])\n[[1,2],[10,20]]\n[[1,2,1,2], [10,20,1,2]]\n\nisempty(empty)\nnull\ntrue\n\nisempty(.[])\n[]\ntrue\n\nisempty(.[])\n[1,2,3]\nfalse\n\n[limit(3; .[])]\n[0,1,2,3,4,5,6,7,8,9]\n[0,1,2]\n\n[skip(3; .[])]\n[0,1,2,3,4,5,6,7,8,9]\n[3,4,5,6,7,8,9]\n\n[first(range(.)), last(range(.)), nth(5; range(.))]\n10\n[0,9,5]\n\n[first(empty), last(empty), nth(5; empty)]\nnull\n[]\n\n[range(.)]|[first, last, nth(5)]\n10\n[0,9,5]\n\nreduce .[] as $item (0; . + $item)\n[1,2,3,4,5]\n15\n\nreduce .[] as [$i,$j] (0; . + $i * $j)\n[[1,2],[3,4],[5,6]]\n44\n\nreduce .[] as {$x,$y} (null; .x += $x | .y += [$y])\n[{\"x\":\"a\",\"y\":1},{\"x\":\"b\",\"y\":2},{\"x\":\"c\",\"y\":3}]\n{\"x\":\"abc\",\"y\":[1,2,3]}\n\nforeach .[] as $item (0; . + $item)\n[1,2,3,4,5]\n1\n3\n6\n10\n15\n\nforeach .[] as $item (0; . + $item; [$item, . * 2])\n[1,2,3,4,5]\n[1,2]\n[2,6]\n[3,12]\n[4,20]\n[5,30]\n\nforeach .[] as $item (0; . + 1; {index: ., $item})\n[\"foo\", \"bar\", \"baz\"]\n{\"index\":1,\"item\":\"foo\"}\n{\"index\":2,\"item\":\"bar\"}\n{\"index\":3,\"item\":\"baz\"}\n\ndef range(init; upto; by): def _range: if (by > 0 and . < upto) or (by < 0 and . > upto) then ., ((.+by)|_range) else empty end; if init == upto then empty elif by == 0 then init else init|_range end; range(0; 10; 3)\nnull\n0\n3\n6\n9\n\ndef while(cond; update): def _while: if cond then ., (update | _while) else empty end; _while; [while(.<100; .*2)]\n1\n[1,2,4,8,16,32,64]\n\ntruncate_stream([[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]])\n1\n[[0],\"b\"]\n[[0]]\n\nfromstream(1|truncate_stream([[0],\"a\"],[[1,0],\"b\"],[[1,0]],[[1]]))\nnull\n[\"b\"]\n\n. as $dot|fromstream($dot|tostream)|.==$dot\n[0,[1,{\"a\":1},{\"b\":2}]]\ntrue\n\n(..|select(type==\"boolean\")) |= if . then 1 else 0 end\n[true,false,[5,true,[true,[false]],false]]\n[1,0,[5,1,[1,[0]],0]]\n\n.foo += 1\n{\"foo\": 42}\n{\"foo\": 43}\n\n.a = .b\n{\"a\": {\"b\": 10}, \"b\": 20}\n{\"a\":20,\"b\":20}\n\n.a |= .b\n{\"a\": {\"b\": 10}, \"b\": 20}\n{\"a\":10,\"b\":20}\n\n(.a, .b) = range(3)\nnull\n{\"a\":0,\"b\":0}\n{\"a\":1,\"b\":1}\n{\"a\":2,\"b\":2}\n\n(.a, .b) |= range(3)\nnull\n{\"a\":0,\"b\":0}\n\n"
  },
  {
    "path": "tests/manonig.test",
    "content": "split(\", \")\n\"a, b,c,d, e, \"\n[\"a\",\"b,c,d\",\"e\",\"\"]\n\nwalk( if type == \"object\" then with_entries( .key |= sub( \"^_+\"; \"\") ) else . end )\n[ { \"_a\": { \"__b\": 2 } } ]\n[{\"a\":{\"b\":2}}]\n\ntest(\"foo\")\n\"foo\"\ntrue\n\n.[] | test(\"a b c # spaces are ignored\"; \"ix\")\n[\"xabcd\", \"ABC\"]\ntrue\ntrue\n\nmatch(\"(abc)+\"; \"g\")\n\"abc abc\"\n{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 0, \"length\": 3, \"string\": \"abc\", \"name\": null}]}\n{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"abc\", \"name\": null}]}\n\nmatch(\"foo\")\n\"foo bar foo\"\n{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}\n\nmatch([\"foo\", \"ig\"])\n\"foo bar FOO\"\n{\"offset\": 0, \"length\": 3, \"string\": \"foo\", \"captures\": []}\n{\"offset\": 8, \"length\": 3, \"string\": \"FOO\", \"captures\": []}\n\nmatch(\"foo (?<bar123>bar)? foo\"; \"ig\")\n\"foo bar foo foo  foo\"\n{\"offset\": 0, \"length\": 11, \"string\": \"foo bar foo\", \"captures\": [{\"offset\": 4, \"length\": 3, \"string\": \"bar\", \"name\": \"bar123\"}]}\n{\"offset\": 12, \"length\": 8, \"string\": \"foo  foo\", \"captures\": [{\"offset\": -1, \"length\": 0, \"string\": null, \"name\": \"bar123\"}]}\n\n[ match(\".\"; \"g\")] | length\n\"abc\"\n3\n\ncapture(\"(?<a>[a-z]+)-(?<n>[0-9]+)\")\n\"xyzzy-14\"\n{ \"a\": \"xyzzy\", \"n\": \"14\" }\n\nscan(\"c\")\n\"abcdefabc\"\n\"c\"\n\"c\"\n\nscan(\"(a+)(b+)\")\n\"abaabbaaabbb\"\n[\"a\",\"b\"]\n[\"aa\",\"bb\"]\n[\"aaa\",\"bbb\"]\n\nsplit(\", *\"; null)\n\"ab,cd, ef\"\n[\"ab\",\"cd\",\"ef\"]\n\nsplits(\", *\")\n\"ab,cd,   ef, gh\"\n\"ab\"\n\"cd\"\n\"ef\"\n\"gh\"\n\nsplits(\",? *\"; \"n\")\n\"ab,cd ef,  gh\"\n\"ab\"\n\"cd\"\n\"ef\"\n\"gh\"\n\nsub(\"[^a-z]*(?<x>[a-z]+)\"; \"Z\\(.x)\"; \"g\")\n\"123abc456def\"\n\"ZabcZdef\"\n\n[sub(\"(?<a>.)\"; \"\\(.a|ascii_upcase)\", \"\\(.a|ascii_downcase)\")]\n\"aB\"\n[\"AB\",\"aB\"]\n\ngsub(\"(?<x>.)[^a]*\"; \"+\\(.x)-\")\n\"Abcabc\"\n\"+A-+a-\"\n\n[gsub(\"p\"; \"a\", \"b\")]\n\"p\"\n[\"a\",\"b\"]\n\n"
  },
  {
    "path": "tests/manonigtest",
    "content": "#!/bin/sh\n\n. \"${0%/*}/setup\" \"$@\"\n\n$VALGRIND $Q $JQ -L \"$mods\" --run-tests $JQBASEDIR/tests/manonig.test\n"
  },
  {
    "path": "tests/mantest",
    "content": "#!/bin/sh\n\n. \"${0%/*}/setup\" \"$@\"\n\n# We set PAGER because there's a mantest for `env` that uses it.\nenv PAGER=less $VALGRIND $Q $JQ -L \"$mods\" --run-tests $JQBASEDIR/tests/man.test\n"
  },
  {
    "path": "tests/modules/a.jq",
    "content": "module {version:1.7};\ndef a: \"a\";\n"
  },
  {
    "path": "tests/modules/b/b.jq",
    "content": "def a: \"b\";\ndef b: \"c\";\n"
  },
  {
    "path": "tests/modules/c/c.jq",
    "content": "module {whatever:null};\nimport \"a\" as foo;\nimport \"d\" as d {search:\"./\"};\nimport \"d\" as d2{search:\"./\"};\nimport \"e\" as e {search:\"./../lib/jq\"};\nimport \"f\" as f {search:\"./../lib/jq\"};\nimport \"data\" as $d;\ndef a: 0;\ndef c:\n  if $d::d[0] != {this:\"is a test\",that:\"is too\"} then error(\"data import is busted\")\n  elif d2::meh != d::meh then error(\"import twice doesn't work\")\n  elif foo::a != \"a\" then error(\"foo::a didn't work as expected\")\n  elif d::meh != \"meh\" then error(\"d::meh didn't work as expected\")\n  elif e::bah != \"bah\" then error(\"e::bah didn't work as expected\")\n  elif f::f != \"f is here\" then error(\"f::f didn't work as expected\")\n  else foo::a + \"c\" + d::meh + e::bah end;\n"
  },
  {
    "path": "tests/modules/c/d.jq",
    "content": "def meh: \"meh\";\n"
  },
  {
    "path": "tests/modules/data.json",
    "content": "{\n  \"this\": \"is a test\",\n  \"that\": \"is too\"\n}\n"
  },
  {
    "path": "tests/modules/home1/.jq",
    "content": "def foo: \"baz\";\ndef f: \"wat\";\ndef f: \"foo\";\ndef g: \"bar\";\ndef fg: f+g;\n"
  },
  {
    "path": "tests/modules/home2/.jq/g.jq",
    "content": "def g: 1;\n"
  },
  {
    "path": "tests/modules/shadow1.jq",
    "content": "def e: 1;\ndef e: 2;\n"
  },
  {
    "path": "tests/modules/shadow2.jq",
    "content": "def e: 3;\n"
  },
  {
    "path": "tests/modules/syntaxerror/syntaxerror.jq",
    "content": "wat;\n"
  },
  {
    "path": "tests/modules/test_bind_order.jq",
    "content": "import \"test_bind_order0\" as t;\nimport \"test_bind_order1\" as t;\nimport \"test_bind_order2\" as t;\ndef check: if [t::sym0,t::sym1,t::sym2] == [0,1,2] then true else false end;\n"
  },
  {
    "path": "tests/modules/test_bind_order0.jq",
    "content": "def sym0: 0;\ndef sym1: 0;\n"
  },
  {
    "path": "tests/modules/test_bind_order1.jq",
    "content": "def sym1: 1;\ndef sym2: 1;\n"
  },
  {
    "path": "tests/modules/test_bind_order2.jq",
    "content": "def sym2: 2;\n"
  },
  {
    "path": "tests/no-main-program.jq",
    "content": "def a: .;\n"
  },
  {
    "path": "tests/onig.supp",
    "content": "{\n\tonig node recycling\n\tMemcheck:Leak\n\t...\n\tfun:onig_parse_make_tree\n\t...\n}\n{\n\tonig unicode case insensitivity 1\n\tMemcheck:Leak\n\t...\n\tfun:setup_tree\n\t...\n}\n{\n\tonig unicode case insensitivity 2\n\tMemcheck:Leak\n\t...\n\tfun:onig*unicode*\n\t...\n}\n"
  },
  {
    "path": "tests/onig.test",
    "content": "# match builtin\n[match(\"( )*\"; \"g\")]\n\"abc\"\n[{\"offset\":0,\"length\":0,\"string\":\"\",\"captures\":[{\"offset\":-1,\"string\":null,\"length\":0,\"name\":null}]},{\"offset\":1,\"length\":0,\"string\":\"\",\"captures\":[{\"offset\":-1,\"string\":null,\"length\":0,\"name\":null}]},{\"offset\":2,\"length\":0,\"string\":\"\",\"captures\":[{\"offset\":-1,\"string\":null,\"length\":0,\"name\":null}]},{\"offset\":3,\"length\":0,\"string\":\"\",\"captures\":[{\"offset\":-1,\"string\":null,\"length\":0,\"name\":null}]}]\n\n[match(\"( )*\"; \"gn\")]\n\"abc\"\n[]\n\n[match(\"\"; \"g\")]\n\"ab\"\n[{\"offset\":0,\"length\":0,\"string\":\"\",\"captures\":[]},{\"offset\":1,\"length\":0,\"string\":\"\",\"captures\":[]},{\"offset\":2,\"length\":0,\"string\":\"\",\"captures\":[]}]\n\n[match(\"a\"; \"gi\")]\n\"āáàä\"\n[]\n\n[match([\"(bar)\"])]\n\"foo bar\"\n[{\"offset\": 4, \"length\": 3, \"string\": \"bar\", \"captures\":[{\"offset\": 4, \"length\": 3, \"string\": \"bar\", \"name\": null}]}]\n\n# offsets account for combining codepoints and multi-byte UTF-8\n[match(\"bar\")]\n\"ā bar with a combining codepoint U+0304\"\n[{\"offset\": 3, \"length\": 3, \"string\": \"bar\", \"captures\":[]}]\n\n# matches with combining codepoints still count them in their length\n[match(\"bār\")]\n\"a bār\"\n[{\"offset\": 2, \"length\": 4, \"string\": \"bār\", \"captures\":[]}]\n\n[match(\".+?\\\\b\")]\n\"ā two-codepoint grapheme\"\n[{\"offset\": 0, \"length\": 2, \"string\": \"ā\", \"captures\":[]}]\n\n[match([\"foo (?<bar123>bar)? foo\", \"ig\"])]\n\"foo bar foo foo  foo\"\n[{\"offset\": 0, \"length\": 11, \"string\": \"foo bar foo\", \"captures\":[{\"offset\": 4, \"length\": 3, \"string\": \"bar\", \"name\": \"bar123\"}]},{\"offset\":12, \"length\": 8, \"string\": \"foo  foo\", \"captures\":[{\"offset\": -1, \"length\": 0, \"string\": null, \"name\": \"bar123\"}]}]\n\n# non-matched optional group\n\"a\",\"b\",\"c\" | capture(\"(?<x>a)?b?\")\nnull\n{\"x\":\"a\"}\n{\"x\":null}\n{\"x\":null}\n\n\"a\",\"b\",\"c\" | match(\"(?<x>a)?b?\")\nnull\n{\"offset\":0,\"length\":1,\"string\":\"a\",\"captures\":[{\"offset\":0,\"length\":1,\"string\":\"a\",\"name\":\"x\"}]}\n{\"offset\":0,\"length\":1,\"string\":\"b\",\"captures\":[{\"offset\":-1,\"string\":null,\"length\":0,\"name\":\"x\"}]}\n{\"offset\":0,\"length\":0,\"string\":\"\",\"captures\":[{\"offset\":-1,\"string\":null,\"length\":0,\"name\":\"x\"}]}\n\n# same as above but allow empty match for group\n\"a\",\"b\",\"c\" | capture(\"(?<x>a?)?b?\")\nnull\n{\"x\":\"a\"}\n{\"x\":\"\"}\n{\"x\":\"\"}\n\n\"a\",\"b\",\"c\" | match(\"(?<x>a?)?b?\")\nnull\n{\"offset\":0,\"length\":1,\"string\":\"a\",\"captures\":[{\"offset\":0,\"length\":1,\"string\":\"a\",\"name\":\"x\"}]}\n{\"offset\":0,\"length\":1,\"string\":\"b\",\"captures\":[{\"offset\":0,\"string\":\"\",\"length\":0,\"name\":\"x\"}]}\n{\"offset\":0,\"length\":0,\"string\":\"\",\"captures\":[{\"offset\":0,\"string\":\"\",\"length\":0,\"name\":\"x\"}]}\n\n#test builtin\n[test(\"( )*\"; \"gn\")]\n\"abc\"\n[false]\n\n[test(\"ā\")]\n\"ā\"\n[true]\n\ncapture(\"(?<a>[a-z]+)-(?<n>[0-9]+)\")\n\"xyzzy-14\"\n{\"a\":\"xyzzy\",\"n\":\"14\"}\n\n\n# jq-coded utilities built on match:\n#\n# The second element in these tests' inputs tests the case where the\n# fromstring matches both the head and tail of the string\n[.[] | sub(\", \"; \":\")]\n[\"a,b, c, d, e,f\", \", a,b, c, d, e,f, \"]\n[\"a,b:c, d, e,f\",\":a,b, c, d, e,f, \"]\n\nsub(\"^(?<head>.)\"; \"Head=\\(.head) Tail=\")\n\"abcdef\"\n\"Head=a Tail=bcdef\"\n\n[.[] | gsub(\", \"; \":\")]\n[\"a,b, c, d, e,f\",\", a,b, c, d, e,f, \"]\n[\"a,b:c:d:e,f\",\":a,b:c:d:e,f:\"]\n\ngsub(\"(?<d>\\\\d)\"; \":\\(.d);\")\n\"a1b2\"\n\"a:1;b:2;\"\n\ngsub(\"a\";\"b\")\n\"aaaaa\"\n\"bbbbb\"\n\ngsub(\"(.*)\"; \"\"; \"x\")\n\"\"\n\"\"\n\ngsub(\"\"; \"a\"; \"g\")\n\"\"\n\"a\"\n\ngsub(\"^\"; \"\"; \"g\")\n\"a\"\n\"a\"\n\ngsub(\"\"; \"a\"; \"g\")\n\"a\"\n\"aaa\"\n\ngsub(\"$\"; \"a\"; \"g\")\n\"a\"\n\"aa\"\n\ngsub(\"^\"; \"a\")\n\"\"\n\"a\"\n\ngsub(\"(?=u)\"; \"u\")\n\"qux\"\n\"quux\"\n\ngsub(\"^.*a\"; \"b\")\n\"aaa\"\n\"b\"\n\ngsub(\"^.*?a\"; \"b\")\n\"aaa\"\n\"baa\"\n\n# The following is for regression testing and should not be construed as a requirement:\n[gsub(\"a\"; \"b\", \"c\")]\n\"a\"\n[\"b\",\"c\"]\n\n[.[] | scan(\", \")]\n[\"a,b, c, d, e,f\",\", a,b, c, d, e,f, \"]\n[\", \",\", \",\", \",\", \",\", \",\", \",\", \",\", \"]\n\n[.[]|[[sub(\", *\";\":\")], [gsub(\", *\";\":\")], [scan(\", *\")]]]\n[\"a,b, c, d, e,f\",\", a,b, c, d, e,f, \"]\n[[[\"a:b, c, d, e,f\"],[\"a:b:c:d:e:f\"],[\",\",\", \",\", \",\", \",\",\"]],[[\":a,b, c, d, e,f, \"],[\":a:b:c:d:e:f:\"],[\", \",\",\",\", \",\", \",\", \",\",\",\", \"]]]\n\n[.[]|[[sub(\", +\";\":\")], [gsub(\", +\";\":\")], [scan(\", +\")]]]\n[\"a,b, c, d, e,f\",\", a,b, c, d, e,f, \"]\n[[[\"a,b:c, d, e,f\"],[\"a,b:c:d:e,f\"],[\", \",\", \",\", \"]],[[\":a,b, c, d, e,f, \"],[\":a,b:c:d:e,f:\"],[\", \",\", \",\", \",\", \",\", \"]]]\n\n[.[] | scan(\"b+\"; \"i\")]\n[\"\",\"bBb\",\"abcABBBCabbbc\"]\n[\"bBb\",\"b\",\"BBB\",\"bbb\"]\n\n# reference to named captures\ngsub(\"(?<x>.)[^a]*\"; \"+\\(.x)-\")\n\"Abcabc\"\n\"+A-+a-\"\n\ngsub(\"(?<x>.)(?<y>[0-9])\"; \"\\(.x|ascii_downcase)\\(.y)\")\n\"A1 B2 CD\"\n\"a1 b2 CD\"\n\ngsub(\"\\\\b(?<x>.)\"; \"\\(.x|ascii_downcase)\")\n\"ABC DEF\"\n\"aBC dEF\"\n\ngsub(\"[^a-z]*(?<x>[a-z]*)\"; \"Z\\(.x)\")\n\"123foo456bar\"\n\"ZfooZbarZ\"\n\n# utf-8\nsub(\"(?<x>.)\"; \"\\(.x)!\")\n\"’\"\n\"’!\"\n\n[sub(\"a\"; \"b\", \"c\")]\n\"a\"\n[\"b\",\"c\"]\n\n[sub(\"(?<a>.)\"; \"\\(.a|ascii_upcase)\", \"\\(.a|ascii_downcase)\", \"c\")]\n\"aB\"\n[\"AB\",\"aB\",\"cB\"]\n\n[gsub(\"(?<a>.)\"; \"\\(.a|ascii_upcase)\", \"\\(.a|ascii_downcase)\", \"c\")]\n\"aB\"\n[\"AB\",\"ab\",\"cc\"]\n\n# splits\n[splits(\"\")]\n\"ab\"\n[\"\",\"a\",\"b\",\"\"]\n\n[splits(\"c\")]\n\"ab\"\n[\"ab\"]\n\n[splits(\"a+\"; \"i\")]\n\"abAABBabA\"\n[\"\",\"b\",\"BB\",\"b\",\"\"]\n\n[splits(\"b+\"; \"i\")]\n\"abAABBabA\"\n[\"a\",\"AA\",\"a\",\"A\"]\n\n"
  },
  {
    "path": "tests/onigtest",
    "content": "#!/bin/sh\n\n. \"${0%/*}/setup\" \"$@\"\n\n$VALGRIND $Q $JQ -L \"$mods\" --run-tests $JQTESTDIR/onig.test\n"
  },
  {
    "path": "tests/optional.test",
    "content": "# See tests/jq.test and the jq manual for more information.\n\n# Regression test for #3276 (fails on mingw/WIN32)\nfromdate\n\"2038-01-19T03:14:08Z\"\n2147483648\n\n# %e is not available on mingw/WIN32\nstrftime(\"%A, %B %e, %Y\")\n1435677542.822351\n\"Tuesday, June 30, 2015\"\n\n"
  },
  {
    "path": "tests/optionaltest",
    "content": "#!/bin/sh\n\n. \"${0%/*}/setup\" \"$@\"\n\n$VALGRIND $Q $JQ -L \"$mods\" --run-tests $JQTESTDIR/optional.test\n"
  },
  {
    "path": "tests/setup",
    "content": "#!/bin/sh\n\n# This is meant to be included by each test's shell script driver.\n\nif [ -n \"$TRACE_TESTS\" ]; then\n    set -x\nfi\n\nset -eu\n\nJQTESTDIR=$(cd \"$(dirname \"$0\")\" && pwd)\nJQBASEDIR=$JQTESTDIR/..\nJQ=${JQ:-$JQBASEDIR/jq}\n\n# Some tests have locale-dependent output; use C locale.  Fixes #3038\nLC_ALL=C\nexport LC_ALL\n\nif [ -n \"${ENABLE_VALGRIND-}\" ] && which valgrind > /dev/null; then\n    VALGRIND=\"valgrind --error-exitcode=1 --leak-check=full \\\n                       --suppressions=$JQTESTDIR/onig.supp \\\n                       --suppressions=$JQTESTDIR/local.supp\"\n    VG_EXIT0=--error-exitcode=0\n    Q=-q\nelse\n    VALGRIND=\n    VG_EXIT0=\n    Q=\nfi\n\nmods=$JQTESTDIR/modules\n\nclean=true\nd=\nclean () {\n    if ! $clean; then\n        echo \"See temp files in $d!\"\n    elif [ -n \"$d\" ]; then\n        rm -rf \"$d\"\n    fi\n}\ntrap clean EXIT\nd=$(mktemp -d -t jqXXXXXX || true)\nif [ -z \"$d\" ]; then\n    echo \"Your OS does not support mktemp(1) -d\" 1>&2\n    exit 1\nfi\n"
  },
  {
    "path": "tests/shtest",
    "content": "#!/bin/sh -x\n\n. \"${0%/*}/setup\" \"$@\"\n\nmsys=false\nmingw=false\ncase \"$(uname -s)\" in\nMSYS*)  msys=true;;\nMINGW*) mingw=true;;\nesac\n\nJQ_NO_B=$JQ\nJQ=\"$JQ -b\"\n\nPATH=$JQBASEDIR:$PATH $JQBASEDIR/tests/jq-f-test.sh > /dev/null\n\nSHELL=/bin/sh\nexport SHELL\n\nunset JQ_COLORS\nunset NO_COLOR\n\nif [ -f \"$JQBASEDIR/.libs/libinject_errors.so\" ]; then\n  # Do some simple error injection tests to check that we're handling\n  # I/O errors correctly.\n  (\n  libinject=$JQBASEDIR/.libs/libinject_errors.so\n  cd $d\n  LD_PRELOAD=$libinject $JQ . /dev/null\n  touch fail_read\n  LD_PRELOAD=$libinject $JQ . fail_read && exit 2\n  touch fail_close\n  LD_PRELOAD=$libinject $JQ . fail_close && exit 2\n  true\n  )\nfi\n\nprintf 'a\\0b\\nc\\0d\\ne' > $d/input\n$VALGRIND $Q $JQ -Rse '. == \"a\\u0000b\\nc\\u0000d\\ne\"' $d/input\n$VALGRIND $Q $JQ -Rne '[inputs] == [\"a\\u0000b\", \"c\\u0000d\", \"e\"]' $d/input\n\n## Test constant folding\nnref=$($VALGRIND $Q $JQ -n --debug-dump-disasm '\"foo\"' | wc -l)\nfor exp in '1+1' '1-1' '2*3' '9/3' '9%3' '9==3' '9!=3' \\\n  '9<3' '9>3' '9<=3' '9>=3' '1+2*3-4/5%6' '\"foo\" + \"bar\"'; do\n  n=$($VALGRIND $Q $JQ -n --debug-dump-disasm \"$exp\" | wc -l)\n  if [ $n -ne $nref ]; then\n    echo \"Constant expression folding didn't work: $exp\"\n    exit 1\n  fi\ndone\n\n## Test JSON sequence support\ncat > $d/expected <<EOF\njq: ignoring parse error: Truncated value at line 2, column 5\njq: ignoring parse error: Truncated value at line 2, column 25\njq: ignoring parse error: Truncated value at line 2, column 41\nEOF\nprintf '1\\0362 3\\n[0,1\\036[4,5]true\"ab\"{\"c\":4\\036{}{\"d\":5,\"e\":6\"\\036false\\n'|$VALGRIND $Q $JQ -ces --seq '. == [2,3,[4,5],true,\"ab\",{},false]' > /dev/null 2> $d/out\ncmp $d/out $d/expected\n\ncat > $d/expected <<EOF\njq: ignoring parse error: Truncated value at line 2, column 5\njq: ignoring parse error: Truncated value at line 2, column 25\njq: ignoring parse error: Truncated value at line 3, column 1\nEOF\nprintf '1\\0362 3\\n[0,1\\036[4,5]true\"ab\"{\"c\":4\\036{}{\"d\":5,\"e\":6\"false\\n\\036null'|$VALGRIND $Q $JQ -ces --seq '. == [2,3,[4,5],true,\"ab\",{},null]' > /dev/null 2> $d/out\ncmp $d/out $d/expected\n\n# Note that here jq sees no inputs at all but it still succeeds because\n# --seq ignores parse errors\ncat > $d/expected <<EOF\njq: ignoring parse error: Unfinished abandoned text at EOF at line 1, column 4\nEOF\nprintf '\"foo' | $JQ -c --seq . > $d/out 2>&1\ncmp $d/out $d/expected\n\n# with -e option should give 4 here as there's no valid output after\n# ignoring parse errors with --seq.\nprintf '\"foo' | $JQ -ce --seq . > $d/out 2>&1 || ret=$?\n[ $ret -eq 4 ]\ncmp $d/out $d/expected\n\n# Numeric values truncated by EOF are ignored\ncat > $d/expected <<EOF\njq: ignoring parse error: Unfinished abandoned text at EOF at line 1, column 1\nEOF\nprintf '1' | $JQ -c --seq . > $d/out 2>&1\ncmp $d/out $d/expected\n\ncat > $d/expected <<EOF\njq: error (at <stdin>:1): Unfinished abandoned text at EOF at line 2, column 0\nEOF\nif printf '1\\n' | $JQ -cen --seq '[inputs] == []' >/dev/null 2> $d/out; then\n  printf 'Error expected but jq exited successfully\\n' 1>&2\n  exit 2\nfi\ncmp $d/out $d/expected\n\n# Test control characters for #2909\ncat > $d/expected <<EOF\njq: parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 1, column 3\nEOF\nfor i in 1 2 30 31; do\n  if printf \"\\\"$(printf '\\\\%03o' $i)\\\"\" | $JQ '.' > $d/out 2>&1; then\n    printf 'Error expected but jq exited successfully\\n' 1>&2\n    exit 2\n  fi\n  cmp $d/out $d/expected\ndone\nprintf '\" ~\\\\u007f\"\\n' > $d/expected\nprintf \"\\\"$(printf '\\\\%03o' 32 126 127)\\\"\" | $JQ '.' > $d/out 2>&1\ncmp $d/out $d/expected\n\n## Test --exit-status\ndata='{\"i\": 1}\\n{\"i\": 2}\\n{\"i\": 3}\\n'\nprintf \"$data\" | $JQ --exit-status 'select(.i==1)' > /dev/null 2>&1\nprintf \"$data\" | $JQ --exit-status 'select(.i==2)' > /dev/null 2>&1\nprintf \"$data\" | $JQ --exit-status 'select(.i==3)' > /dev/null 2>&1\nret=0\nprintf \"$data\" | $JQ --exit-status 'select(.i==4)' > /dev/null 2>&1 || ret=$?\n[ $ret -eq 4 ]\nret=0\nprintf \"$data\" | $JQ --exit-status 'select(.i==2) | false' > /dev/null 2>&1 || ret=$?\n[ $ret -eq 1 ]\nprintf \"$data\" | $JQ --exit-status 'select(.i==2) | true' > /dev/null 2>&1\n\n\n# Regression test for #951\nprintf '\"a\\n' > $d/input\nif $VALGRIND $Q $JQ -e . $d/input; then\n  printf 'Issue #951 is back?\\n' 1>&2\n  exit 2\nfi\n\n# Regression test for #2146\nif echo \"foobar\" | $JQ .; then\n  printf 'Issue #2146 is back?\\n' 1>&2\n  exit 1\nelif [ $? -ne 5 ]; then\n  echo \"Invalid input had wrong error code\" 1>&2\n  exit 1\nfi\n\n# Regression test for #2367; make sure to call jq twice\nif ! echo '{\"a\": 1E9999999999}' | $JQ . | $JQ -e .a; then\n  printf 'Issue #2367 is back?\\n' 1>&2\n  exit 1\nfi\n\n# Regression test for #1534\necho \"[1,2,3,4]\" > $d/expected\nprintf \"[1,2][3,4]\" | $JQ -cs add > $d/out 2>&1\ncmp $d/out $d/expected\nprintf \"[1,2][3,4]\\n\" | $JQ -cs add > $d/out 2>&1\ncmp $d/out $d/expected\n\n# Regression test for #3273\necho \"[[[0],1],[[0]],[[0],2],[[0]]]\" > $d/expected\nprintf \"[1][2]\" | $JQ -c -s --stream . > $d/out 2>&1\ncmp $d/out $d/expected\nprintf \"[1][2]\\n\" | $JQ -c -s --stream . > $d/out 2>&1\ncmp $d/out $d/expected\n\n# Regression test for --raw-output0\nprintf \"a\\0b\\0\" > $d/expected\nprintf '[\"a\", \"b\"]' | $VALGRIND $Q $JQ --raw-output0 '.[]' > $d/out\ncmp $d/out $d/expected\nprintf \"a\\0\" > $d/expected\nif printf '[\"a\", \"c\\\\u0000d\", \"b\"]' | $VALGRIND $Q $JQ --raw-output0 '.[]' > $d/out; then\n  echo \"Should exit error on string containing NUL with --raw-output0\" 1>&2\n  exit 1\nelif [ $? -ne 5 ]; then\n  echo \"Invalid error code\" 1>&2\n  exit 1\nelse\n  cmp $d/out $d/expected\nfi\n\n# Regression tests for #3194\necho 42 > $d/expected\n$JQ -nn 42 > $d/out 2>&1\ncmp $d/out $d/expected\n\n$JQ -nL. 42 > $d/out 2>&1\ncmp $d/out $d/expected\n$JQ -nL . 42 > $d/out 2>&1\ncmp $d/out $d/expected\n\n$JQ -h > $d/expected 2>&1\n$JQ -hV > $d/out 2>&1\ncmp $d/out $d/expected\n$JQ -h -V > $d/out 2>&1\ncmp $d/out $d/expected\n\n$JQ -V > $d/expected 2>&1\n$JQ -Vh > $d/out 2>&1\ncmp $d/out $d/expected\n$JQ -V -h > $d/out 2>&1\ncmp $d/out $d/expected\n\n# CRLF line break support #1219\nif ! x=$($JQ -n \"$(printf '1\\r\\n+\\r\\n2')\") || [ \"$x\" != '3' ]; then\n  echo 'CRLF line break support failed?' 1>&2\n  exit 1\nfi\n\n## Test streaming parser\n\n## If we add an option to stream to the `import ... as $symbol;` directive\n## then we can move these tests into tests/all.test.\n$VALGRIND $Q $JQ -c '. as $d|path(..) as $p|$d|getpath($p)|select((type|. != \"array\" and . != \"object\") or length==0)|[$p,.]' < \"$JQTESTDIR/torture/input0.json\" > $d/out0\n$VALGRIND $Q $JQ --stream -c '.|select(length==2)' < \"$JQTESTDIR/torture/input0.json\" > $d/out1\ndiff $d/out0 $d/out1\n\nprintf '[\"Unfinished JSON term at EOF at line 1, column 1\",[0]]\\n' > $d/expected\nprintf '[' | $VALGRIND $Q $JQ --stream-errors -c . > $d/out 2>&1\ndiff $d/out $d/expected\n\n\n## XXX This test can be moved to tests/all.test _now_\nclean=false\nif which seq > /dev/null 2>&1; then\n    # XXX We should try every prefix of input0.json, but that makes this\n    # test very, very slow when run with valgrind, and the whole point\n    # is to run it with valgrind.\n    #\n    #len=$(wc -c < \"$JQTESTDIR/torture/input0.json\")\n    if [ -z \"$VALGRIND\" ]; then\n        start=1\n        end=$(wc -c < \"$JQTESTDIR/torture/input0.json\")\n    else\n        start=120\n        end=151\n    fi\n    for i in $(seq $start $end); do\n        dd \"if=tests/torture/input0.json\" bs=$i count=1 2>/dev/null |\n            $VALGRIND $JQ -c . > $d/out0 2>$d/err || true\n        if [ -n \"$VALGRIND\" ]; then\n            grep '^==[0-9][0-9]*== ERROR SUMMARY: 0 errors' $d/err > /dev/null\n        else\n            tail -n1 -- \"$d/err\" | grep -Ei 'assert|abort|core' && false\n        fi\n\n        dd \"if=tests/torture/input0.json\" bs=$i count=1 2>/dev/null |\n            $VALGRIND $JQ -cn --stream 'fromstream(inputs)' > $d/out1 2>$d/err || true\n        if [ -n \"$VALGRIND\" ]; then\n            grep '^==[0-9][0-9]*== ERROR SUMMARY: 0 errors' $d/err > /dev/null\n        else\n            tail -n1 -- \"$d/err\" | grep -Ei 'assert|abort|core' && false\n        fi\n\n        diff $d/out0 $d/out1\n    done\nelse\n    echo \"Not doing torture tests\"\nfi\n\n## Regression test for issue #2378 assert when stream parse broken object pair\necho '{\"a\":1,\"b\",' | $JQ --stream  > /dev/null 2> $d/err || true\ngrep 'Objects must consist of key:value pairs' $d/err > /dev/null\n\n## Regression tests for issue #2463 assert when stream parse non-scalar object key\necho '{{\"a\":\"b\"}}' | $JQ --stream > /dev/null 2> $d/err || true\ngrep \"Expected string key after '{', not '{'\" $d/err > /dev/null\necho '{\"x\":\"y\",{\"a\":\"b\"}}' | $JQ --stream > /dev/null 2> $d/err || true\ngrep \"Expected string key after ',' in object, not '{'\" $d/err > /dev/null\necho '{[\"a\",\"b\"]}' | $JQ --stream > /dev/null 2> $d/err || true\ngrep \"Expected string key after '{', not '\\\\['\" $d/err > /dev/null\necho '{\"x\":\"y\",[\"a\",\"b\"]}' | $JQ --stream > /dev/null 2> $d/err || true\ngrep \"Expected string key after ',' in object, not '\\\\['\" $d/err > /dev/null\n\n# debug, stderr\n$VALGRIND $Q $JQ -n '\"test\", {} | debug, stderr' >/dev/null\n$JQ -n -c -j '\"hello\\nworld\", null, [false, 0], {\"foo\":[\"bar\"]}, \"\\n\" | stderr' >$d/out 2>$d/err\ncat > $d/expected <<'EOF'\nhello\nworldnull[false,0]{\"foo\":[\"bar\"]}\nEOF\ncmp $d/out $d/expected\ncmp $d/err $d/expected\n\n# --arg, --argjson, $ARGS.named\n$VALGRIND $JQ -n -c --arg foo 1 --argjson bar 2 '{$foo, $bar} | ., . == $ARGS.named' > $d/out\nprintf '{\"foo\":\"1\",\"bar\":2}\\ntrue\\n' > $d/expected\ncmp $d/out $d/expected\n\n# --slurpfile, --rawfile\n$VALGRIND $JQ -n --slurpfile foo $JQBASEDIR/tests/modules/data.json \\\n  --rawfile bar $JQBASEDIR/tests/modules/data.json '{$foo, $bar}' > $d/out\ncat > $d/expected <<'EOF'\n{\n  \"foo\": [\n    {\n      \"this\": \"is a test\",\n      \"that\": \"is too\"\n    }\n  ],\n  \"bar\": \"{\\n  \\\"this\\\": \\\"is a test\\\",\\n  \\\"that\\\": \\\"is too\\\"\\n}\\n\"\n}\nEOF\ncmp $d/out $d/expected\n\n# --args, --jsonargs, $ARGS.positional\n$VALGRIND $JQ -n -c --args '$ARGS.positional' foo bar baz > $d/out\nprintf '[\"foo\",\"bar\",\"baz\"]\\n' > $d/expected\ncmp $d/out $d/expected\n$VALGRIND $JQ -n -c --jsonargs '$ARGS.positional' null true '[]' '{}' > $d/out\nprintf '[null,true,[],{}]\\n' > $d/expected\ncmp $d/out $d/expected\n$VALGRIND $JQ -n -c '$ARGS.positional' --args foo 1 --jsonargs 2 '{}' --args 3 4 > $d/out\nprintf '[\"foo\",\"1\",2,{},\"3\",\"4\"]\\n' > $d/expected\ncmp $d/out $d/expected\n$VALGRIND $JQ -n -c '$ARGS.positional' --args --jsonargs > $d/out\nprintf '[]\\n' > $d/expected\ncmp $d/out $d/expected\n\n## Regression test for issue #2572 assert when using --jsonargs and invalid JSON\n$VALGRIND $JQ -n --jsonargs null invalid && EC=$? || EC=$?\nif [ \"$EC\" -ne 2 ]; then\n    echo \"--jsonargs exited with wrong exit code, expected 2 got $EC\" 1>&2\n    exit 1\nfi\n# this tests the args_done code path \"--\"\n$VALGRIND $JQ -n --jsonargs null -- invalid && EC=$? || EC=$?\nif [ \"$EC\" -ne 2 ]; then\n    echo \"--jsonargs exited with wrong exit code, expected 2 got $EC\" 1>&2\n    exit 1\nfi\n\n## Fuzz parser\n\n## XXX With a $(urandom) builtin we could move this test into tests/all.test\nclean=false\nif dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null; then\n    # Have a /dev/urandom, good\n    $VALGRIND $Q $JQ --seq . $d/rand >/dev/null 2>&1\n    $VALGRIND $Q $JQ --seq --stream . $d/rand >/dev/null 2>&1\n    dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null\n    $VALGRIND $Q $JQ --seq . $d/rand >/dev/null 2>&1\n    $VALGRIND $Q $JQ --seq --stream . $d/rand >/dev/null 2>&1\n    dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null\n    $VALGRIND $Q $JQ --seq . $d/rand >/dev/null 2>&1\n    $VALGRIND $Q $JQ --seq --stream . $d/rand >/dev/null 2>&1\nfi\nclean=true\n\n## Test library/module system\n\n# Check handling of ~/.jq; these can't move into jq_test.c yet because\n# they depend on $HOME\nif [ \"$(HOME=\"$mods/home1\" $VALGRIND $Q $JQ -nr fg)\" != foobar ]; then\n    echo \"Bug #479 appears to be back\" 1>&2\n    exit 1\nfi\n\nif $msys || $mingw; then\n    HOME_BAK=$HOME\n    unset HOME\n    if [ \"$(USERPROFILE=\"$mods/home1\" $VALGRIND $Q $JQ -nr foo)\" != baz ]; then\n        echo \"Bug #3104 regressed (sourcing %USERPROFILE%/.jq on Windows)\" 1>&2\n        exit 1\n    fi\n    export HOME=$HOME_BAK\n    unset HOME_BAK\nfi\n\nif [ $(HOME=\"$mods/home1\" $VALGRIND $Q $JQ --debug-dump-disasm -n fg | grep '^[a-z]' | wc -l) -ne 3 ]; then\n    echo \"Binding too many defs into program\" 1>&2\n    exit 1\nfi\n\nif ! HOME=\"$mods/home2\" $VALGRIND $Q $JQ -n 'include \"g\"; empty'; then\n    echo \"Mishandling directory ~/.jq\" 1>&2\n    exit 1\nfi\n\ncd \"$JQBASEDIR\" # so that relative library paths are guaranteed correct\nif ! $VALGRIND $Q $JQ -L ./tests/modules -ne 'import \"test_bind_order\" as check; check::check==true'; then\n    echo \"Issue #817 regression?\" 1>&2\n    exit 1\nfi\n\ncd \"$JQBASEDIR\"\nif ! $VALGRIND $Q $JQ -L tests/modules -ne 'import \"test_bind_order\" as check; check::check==true'; then\n    echo \"Issue #817 regression?\" 1>&2\n    exit 1\nfi\n\n## Halt\n\nif ! $VALGRIND $Q $JQ -n halt; then\n    echo \"jq halt didn't work as expected\" 1>&2\n    exit 1\nfi\nif $VALGRIND $Q $VG_EXIT0 $JQ -n 'halt_error(1)'; then\n    echo \"jq halt_error(1) didn't work as expected\" 1>&2\n    exit 1\nelif [ $? -ne 1 ]; then\n    echo \"jq halt_error(1) had wrong error code\" 1>&2\n    exit 1\nfi\nif $VALGRIND $Q $VG_EXIT0 $JQ -n 'halt_error(11)'; then\n    echo \"jq halt_error(11) didn't work as expected\" 1>&2\n    exit 1\nelif [ $? -ne 11 ]; then\n    echo \"jq halt_error(11) had wrong error code\" 1>&2\n    exit 1\nfi\nif [ -n \"$($VALGRIND $Q $JQ -n 'halt_error(1)' 2>&1)\" ]; then\n    echo \"jq halt_error(1) had unexpected output\" 1>&2\n    exit 1\nfi\nif [ -n \"$($VALGRIND $Q $JQ -n '\"xyz\\n\" | halt_error(1)' 2>/dev/null)\" ]; then\n    echo \"jq halt_error(1) had unexpected output on stdout\" 1>&2\n    exit 1\nfi\nif [ \"$($VALGRIND $Q $JQ -n '\"xy\" | halt_error(1)' 2>&1 || echo \"z\")\" != \"xyz\" ]; then\n    echo \"jq halt_error(1) had unexpected output\" 1>&2\n    exit 1\nfi\nif [ \"$($VALGRIND $Q $JQ -n '\"x\\u0000y\\u0000z\" | halt_error(1)' 2>&1 | tr '\\0' '.')\" != \"x.y.z\" ]; then\n    echo \"jq halt_error(1) had unexpected output\" 1>&2\n    exit 1\nfi\nif [ \"$($VALGRIND $Q $JQ -n '{\"a\":\"xyz\"} | halt_error(1)' 2>&1)\" != '{\"a\":\"xyz\"}' ]; then\n    echo \"jq halt_error(1) had unexpected output\" 1>&2\n    exit 1\nfi\n\n# Check $JQ_COLORS\n\n## Default colors, null input\n$JQ -Ccn . > $d/color\nprintf '\\033[0;90mnull\\033[0m\\n' > $d/expect\ncmp $d/color $d/expect\n\n## Set non-default color, null input\nJQ_COLORS='4;31' $JQ -Ccn . > $d/color\nprintf '\\033[4;31mnull\\033[0m\\n' > $d/expect\ncmp $d/color $d/expect\n\n## Set implicit empty color, null input\n$JQ -Ccn . > $d/color\nprintf '\\033[0;90mnull\\033[0m\\n' > $d/expect\ncmp $d/color $d/expect\n\n## Set explicit empty color, null input\nJQ_COLORS=':' $JQ -Ccn . > $d/color\nprintf '\\033[mnull\\033[0m\\n' > $d/expect\ncmp $d/color $d/expect\n\n## Extra colors, null input\nJQ_COLORS='::::::::' $JQ -Ccn . > $d/color\nprintf '\\033[mnull\\033[0m\\n' > $d/expect\ncmp $d/color $d/expect\n\n## Default colors, complex input\n$JQ -Ccn '[{\"a\":true,\"b\":false},\"abc\",123,null]' > $d/color\n{\n  printf '\\033[1;39m[\\033[0m'\n  printf '\\033[1;39m{\\033[0m'\n  printf '\\033[1;34m\"a\"\\033[0m'\n  printf '\\033[1;39m:\\033[0m'\n  printf '\\033[0;39mtrue\\033[0m'\n  printf '\\033[1;39m,\\033[0m'\n  printf '\\033[1;34m\"b\"\\033[0m'\n  printf '\\033[1;39m:\\033[0m'\n  printf '\\033[0;39mfalse\\033[0m'\n  printf '\\033[1;39m}\\033[0m'\n  printf '\\033[1;39m,\\033[0m'\n  printf '\\033[0;32m\"abc\"\\033[0m'\n  printf '\\033[1;39m,\\033[0m'\n  printf '\\033[0;39m123\\033[0m'\n  printf '\\033[1;39m,\\033[0m'\n  printf '\\033[0;90mnull\\033[0m'\n  printf '\\033[1;39m]\\033[0m\\n'\n} > $d/expect\ncmp $d/color $d/expect\n\n## Set non-default colors, complex input\nJQ_COLORS='0;30:0;31:0;32:0;33:0;34:1;35:1;36:1;37' \\\n  $JQ -Ccn '[{\"a\":true,\"b\":false},\"abc\",123,null]' > $d/color\n{\n  printf '\\033[1;35m[\\033[0m'\n  printf '\\033[1;36m{\\033[0m'\n  printf '\\033[1;37m\"a\"\\033[0m'\n  printf '\\033[1;36m:\\033[0m'\n  printf '\\033[0;32mtrue\\033[0m'\n  printf '\\033[1;36m,\\033[0m'\n  printf '\\033[1;37m\"b\"\\033[0m'\n  printf '\\033[1;36m:\\033[0m'\n  printf '\\033[0;31mfalse\\033[0m'\n  printf '\\033[1;36m}\\033[0m'\n  printf '\\033[1;35m,\\033[0m'\n  printf '\\033[0;34m\"abc\"\\033[0m'\n  printf '\\033[1;35m,\\033[0m'\n  printf '\\033[0;33m123\\033[0m'\n  printf '\\033[1;35m,\\033[0m'\n  printf '\\033[0;30mnull\\033[0m'\n  printf '\\033[1;35m]\\033[0m\\n'\n} > $d/expect\ncmp $d/color $d/expect\n\n## Set non-default colors only for literals, complex input\nJQ_COLORS='0;37:0;31:0;35:0;34:0;36' \\\n  $JQ -Ccn '[{\"a\":true,\"b\":false},\"abc\",123,null]' > $d/color\n{\n  printf '\\033[1;39m[\\033[0m'\n  printf '\\033[1;39m{\\033[0m'\n  printf '\\033[1;34m\"a\"\\033[0m'\n  printf '\\033[1;39m:\\033[0m'\n  printf '\\033[0;35mtrue\\033[0m'\n  printf '\\033[1;39m,\\033[0m'\n  printf '\\033[1;34m\"b\"\\033[0m'\n  printf '\\033[1;39m:\\033[0m'\n  printf '\\033[0;31mfalse\\033[0m'\n  printf '\\033[1;39m}\\033[0m'\n  printf '\\033[1;39m,\\033[0m'\n  printf '\\033[0;36m\"abc\"\\033[0m'\n  printf '\\033[1;39m,\\033[0m'\n  printf '\\033[0;34m123\\033[0m'\n  printf '\\033[1;39m,\\033[0m'\n  printf '\\033[0;37mnull\\033[0m'\n  printf '\\033[1;39m]\\033[0m\\n'\n} > $d/expect\ncmp $d/color $d/expect\n\n## Default colors, complex input, indented\n$JQ -Cn '[{\"a\":true,\"b\":false},\"abc\",123,null]' > $d/color\n{\n  printf '\\033[1;39m[\\033[0m\\n'\n  printf '  \\033[1;39m{\\033[0m\\n'\n  printf '    \\033[1;34m\"a\"\\033[0m'\n  printf '\\033[1;39m:\\033[0m '\n  printf '\\033[0;39mtrue\\033[0m'\n  printf '\\033[1;39m,\\033[0m\\n'\n  printf '    \\033[1;34m\"b\"\\033[0m'\n  printf '\\033[1;39m:\\033[0m '\n  printf '\\033[0;39mfalse\\033[0m\\n'\n  printf '  \\033[1;39m}\\033[0m'\n  printf '\\033[1;39m,\\033[0m\\n'\n  printf '  \\033[0;32m\"abc\"\\033[0m'\n  printf '\\033[1;39m,\\033[0m\\n'\n  printf '  \\033[0;39m123\\033[0m'\n  printf '\\033[1;39m,\\033[0m\\n'\n  printf '  \\033[0;90mnull\\033[0m\\n'\n  printf '\\033[1;39m]\\033[0m\\n'\n} > $d/expect\ncmp $d/color $d/expect\n\n## Set non-default colors, complex input, indented\nJQ_COLORS='0;30:0;31:0;32:0;33:0;34:1;35:1;36:1;37' \\\n  $JQ -Cn '[{\"a\":true,\"b\":false},\"abc\",123,null]' > $d/color\n{\n  printf '\\033[1;35m[\\033[0m\\n'\n  printf '  \\033[1;36m{\\033[0m\\n'\n  printf '    \\033[1;37m\"a\"\\033[0m'\n  printf '\\033[1;36m:\\033[0m '\n  printf '\\033[0;32mtrue\\033[0m'\n  printf '\\033[1;36m,\\033[0m\\n'\n  printf '    \\033[1;37m\"b\"\\033[0m'\n  printf '\\033[1;36m:\\033[0m '\n  printf '\\033[0;31mfalse\\033[0m\\n'\n  printf '  \\033[1;36m}\\033[0m'\n  printf '\\033[1;35m,\\033[0m\\n'\n  printf '  \\033[0;34m\"abc\"\\033[0m'\n  printf '\\033[1;35m,\\033[0m\\n'\n  printf '  \\033[0;33m123\\033[0m'\n  printf '\\033[1;35m,\\033[0m\\n'\n  printf '  \\033[0;30mnull\\033[0m\\n'\n  printf '\\033[1;35m]\\033[0m\\n'\n} > $d/expect\ncmp $d/color $d/expect\n\n## Set truecolor, complex input, indented\nJQ_COLORS=$(printf '38;2;%s:' \\\n  '255;173;173' '255;214;165' '253;255;182' '202;255;191' \\\n  '155;246;255' '160;196;255' '189;178;255' '255;198;255') \\\n  $JQ -Cn '[{\"a\":true,\"b\":false},\"abc\",123,null]' > $d/color\n{\n  printf '\\033[38;2;160;196;255m[\\033[0m\\n'\n  printf '  \\033[38;2;189;178;255m{\\033[0m\\n'\n  printf '    \\033[38;2;255;198;255m\"a\"\\033[0m'\n  printf '\\033[38;2;189;178;255m:\\033[0m '\n  printf '\\033[38;2;253;255;182mtrue\\033[0m'\n  printf '\\033[38;2;189;178;255m,\\033[0m\\n'\n  printf '    \\033[38;2;255;198;255m\"b\"\\033[0m'\n  printf '\\033[38;2;189;178;255m:\\033[0m '\n  printf '\\033[38;2;255;214;165mfalse\\033[0m\\n'\n  printf '  \\033[38;2;189;178;255m}\\033[0m'\n  printf '\\033[38;2;160;196;255m,\\033[0m\\n'\n  printf '  \\033[38;2;155;246;255m\"abc\"\\033[0m'\n  printf '\\033[38;2;160;196;255m,\\033[0m\\n'\n  printf '  \\033[38;2;202;255;191m123\\033[0m'\n  printf '\\033[38;2;160;196;255m,\\033[0m\\n'\n  printf '  \\033[38;2;255;173;173mnull\\033[0m\\n'\n  printf '\\033[38;2;160;196;255m]\\033[0m\\n'\n} > $d/expect\ncmp $d/color $d/expect\n\n# Check invalid JQ_COLORS\necho 'Failed to set $JQ_COLORS' > $d/expect_warning\n$JQ -Ccn '[{\"a\":true,\"b\":false},\"abc\",123,null]' > $d/expect\nfor colors in '/' '[30' '30m' '30:31m:32' '30:*:31' 'invalid'; do\n  JQ_COLORS=$colors \\\n    $JQ -Ccn '[{\"a\":true,\"b\":false},\"abc\",123,null]' > $d/color 2>$d/warning\n  cmp $d/color $d/expect\n  cmp $d/warning $d/expect_warning\ndone\n\n# Check $NO_COLOR\ntest_no_color=true\n$msys  && test_no_color=false\n$mingw && test_no_color=false\nif $test_no_color && command -v script >/dev/null 2>&1; then\n  if script -qc echo /dev/null >/dev/null 2>&1; then\n    faketty() { script -qec \"$*\" /dev/null; }\n  else # macOS\n    faketty() { script -q /dev/null \"$@\" /dev/null |\n      sed 's/^\\x5E\\x44\\x08\\x08//'; }\n  fi\n\n  faketty $JQ_NO_B -n . > $d/color\n  printf '\\033[0;90mnull\\033[0m\\r\\n' > $d/expect\n  od -tc $d/expect\n  od -tc $d/color\n  cmp $d/color $d/expect\n  faketty env NO_COLOR= $JQ_NO_B -n . > $d/color\n  printf '\\033[0;90mnull\\033[0m\\r\\n' > $d/expect\n  od -tc $d/expect\n  od -tc $d/color\n  cmp $d/color $d/expect\n  faketty env NO_COLOR=1 $JQ_NO_B -n . > $d/color\n  printf 'null\\r\\n' > $d/expect\n  od -tc $d/expect\n  od -tc $d/color\n  cmp $d/color $d/expect\n  faketty env NO_COLOR=1 $JQ_NO_B -Cn . > $d/color\n  printf '\\033[0;90mnull\\033[0m\\r\\n' > $d/expect\n  od -tc $d/expect\n  od -tc $d/color\n  cmp $d/color $d/expect\nfi\n\n# #2785\nif $VALGRIND $Q $JQ -n -f \"$JQTESTDIR/no-main-program.jq\" > $d/out 2>&1; then\n  echo \"jq -f $JQTESTDIR/no-main-program.jq succeeded\"\n  exit 1\nelse\n  EC=$?\n  if [ $EC -eq 1 ]; then\n    echo \"jq -f $JQTESTDIR/no-main-program.jq failed with memory errors\"\n    exit 1\n  fi\n  if [ $EC -ne 3 ]; then\n    echo \"jq -f $JQTESTDIR/no-main-program.jq failed with wrong exit code ($EC)\"\n    exit 1\n  fi\nfi\ncat > $d/expected <<EOF\njq: error: Top-level program not given (try \".\")\njq: 1 compile error\nEOF\nif ! diff $d/expected $d/out; then\n  echo \"jq -f $JQTESTDIR/no-main-program.jq failed but its error message is not the expected one\"\n  exit 1\nfi\n\nif ! $VALGRIND $Q $JQ -n -f \"$JQTESTDIR/yes-main-program.jq\" > $d/out 2>&1; then\n  echo \"jq -f $JQTESTDIR/yes-main-program.jq failed\"\n  exit 1\nfi\n\nif ! $msys && ! $mingw && locales=$(locale -a); then\n  { l=$(grep -Ev '^(C|LANG|POSIX|en)' | grep -Ei '\\.utf-?8$' | head -n1) ;} \\\n<<EOF\n$locales\nEOF\n  if [ -z \"$l\" ]; then\n    echo \"WARNING: Not testing localization\"\n  else\n    dt1=$(LC_ALL=$l date +'%a %d %b %Y at %H:%M:%S')\n    dt2=$(LC_ALL=$l jq -nr 'now | strflocaltime(\"%a %d %b %Y at %H:%M:%S\")')\n    dt3=$(LC_ALL=$l date +'%a %d %b %Y at %H:%M:%S')\n    if [ \"$dt1\" != \"$dt2\" ] && [ \"$dt2\" != \"$dt3\" ]; then\n      echo \"jq does not honor LC_ALL environment variable ($dt1, $dt2, $dt3)\"\n      exit 1\n    fi\n  fi\nfi\n\n# Test syntax error messages of multiline filter (we can't test in jq.test)\nif $VALGRIND $Q $JQ -n '[\n  try if .\n         then 1\n         else 2\n  catch ]' > $d/out 2>&1; then\n  echo 'syntax error not detected'\n  exit 1\nfi\ncat > $d/expected <<EOF\njq: error: syntax error, unexpected catch, expecting end or '|' or ',' at <top-level>, line 5, column 3:\n      catch ]\n      ^^^^^\njq: error: Possibly unterminated 'if' statement at <top-level>, line 2, column 7:\n      try if .\n          ^^^^\njq: error: Possibly unterminated 'try' statement at <top-level>, line 2, column 3:\n      try if .\n      ^^^^^^^^\njq: 3 compile errors\nEOF\ndiff $d/out $d/expected\n\n# Test syntax error messages when error happens at the end.\nif $VALGRIND $Q $JQ -n 'if\n' > $d/out 2>&1; then\n  echo 'syntax error not detected'\n  exit 1\nfi\ncat > $d/expected <<EOF\njq: error: syntax error, unexpected end of file at <top-level>, line 1, column 3:\n    if\n      ^\njq: 1 compile error\nEOF\ndiff $d/out $d/expected\n\n# Comments!\nif ! x=$($JQ -n '123 # comment') || [ \"$x\" != 123 ]; then\n  echo 'comment did not work'\n  exit 1\nfi\n\ncr=$(printf \\\\r)\nif ! x=$($JQ -n \"1 # foo$cr + 2\") || [ \"$x\" != 1 ]; then\n  echo 'regression: carriage return terminates comment'\n  exit 1\nfi\n\nif ! x=$($JQ -cn '[\n  1,\n  # foo \\\n  2,\n  # bar \\\\\n  3,\n  4, # baz \\\\\\\n  5, \\\n  6,\n  7\n  # comment \\\n    comment \\\n    comment\n]') || [ \"$x\" != '[1,3,4,7]' ]; then\n  echo 'multiline comment was not handled correctly'\n  exit 1\nfi\n\nif ! x=$($JQ -cn \"$(printf '[\\r\\n1,# comment\\r\\n2,# comment\\\\\\r\\ncomment\\r\\n3\\r\\n]')\") \\\n  || [ \"$x\" != '[1,2,3]' ]; then\n  echo 'multiline comment with CRLF line breaks was not handled correctly'\n  exit 1\nfi\n\n# Allow passing the inline jq script before -- #2919\nif ! r=$($JQ --args -rn -- '$ARGS.positional[0]' bar) || [ \"$r\" != bar ]; then\n    echo \"passing the inline script after -- didn't work\"\n    exit 1\nfi\nif ! r=$($JQ --args -rn 1 -- '$ARGS.positional[0]' bar) || [ \"$r\" != 1 ]; then\n    echo \"passing the inline script before -- didn't work\"\n    exit 1\nfi\n\n# CVE-2023-50246: No heap overflow for '-10E-1000000001'\n$VALGRIND $Q $JQ . <<\\NUM\n-10E-1000000001\nNUM\n\n# test for --indent and --compact-output -- #1465\nprintf '[1,2]\\n' > $d/expected\n$JQ --compact-output -n \"[1,2]\" > $d/out\ncmp $d/out $d/expected\n\nprintf '[\\n1,\\n2\\n]\\n' > $d/expected\n$JQ --indent 0 -n \"[1,2]\" > $d/out\ncmp $d/out $d/expected\n\nprintf '[\\n 1,\\n 2\\n]\\n' > $d/expected\n$JQ --indent 1 -n \"[1,2]\" > $d/out\ncmp $d/out $d/expected\n\nprintf '[\\n     1,\\n     2\\n]\\n' > $d/expected\n$JQ --indent 5 -n \"[1,2]\" > $d/out\ncmp $d/out $d/expected\n\nprintf '[\\n{\\n\"a\": 1\\n}\\n]\\n' > $d/expected\n$JQ --indent 0 -n \"[{a:1}]\" > $d/out\ncmp $d/out $d/expected\n\nprintf '[\\n {\\n  \"a\": 1\\n }\\n]\\n' > $d/expected\n$JQ --indent 1 -n \"[{a:1}]\" > $d/out\ncmp $d/out $d/expected\n\nprintf '[\\n      {\\n            \"a\": 1\\n      }\\n]\\n' > $d/expected\n$JQ --indent 6 -n \"[{a:1}]\" > $d/out\ncmp $d/out $d/expected\n\nif ! $msys && ! $mingw; then\n  # Test handling of timezones -- #2429, #2475\n  if ! r=$(TZ=Asia/Tokyo $JQ -rn '1731627341 | strflocaltime(\"%F %T %z %Z\")') \\\n    || [ \"$r\" != \"2024-11-15 08:35:41 +0900 JST\" ]; then\n    echo \"Incorrectly formatted local time\"\n    exit 1\n  fi\n\n  if ! r=$(TZ=Europe/Paris $JQ -rn '1731627341 | strflocaltime(\"%F %T %z %Z\")') \\\n    || [ \"$r\" != \"2024-11-15 00:35:41 +0100 CET\" ]; then\n    echo \"Incorrectly formatted local time\"\n    exit 1\n  fi\n\n  # Test when DST is in effect: #1912\n  if ! r=$(TZ=Europe/Paris $JQ -rn '1750500000 | strflocaltime(\"%F %T %z %Z\")') \\\n    || [ \"$r\" != \"2025-06-21 12:00:00 +0200 CEST\" ]; then\n    echo \"Incorrectly formatted local time\"\n    exit 1\n  fi\n\n  if ! r=$(TZ=Europe/Paris $JQ -rn '1731627341 | strftime(\"%F %T %z %Z\")') \\\n    || ( [ \"$r\" != \"2024-11-14 23:35:41 +0000 UTC\" ] \\\n      && [ \"$r\" != \"2024-11-14 23:35:41 +0000 GMT\" ] ); then\n    echo \"Incorrectly formatted universal time\"\n    exit 1\n  fi\n\n  if ! r=$(TZ=Etc/GMT+7 $JQ -nc '1731627341 | .,. | [strftime(\"%FT%T\"),strflocaltime(\"%FT%T%z\")]'\n) \\\n    || [ \"$r\" != '[\"2024-11-14T23:35:41\",\"2024-11-14T16:35:41-0700\"]\n[\"2024-11-14T23:35:41\",\"2024-11-14T16:35:41-0700\"]' ]; then\n    echo \"strftime or strftimelocal are not pure functions\"\n    exit 1\n  fi\nfi\n\n# Test ARG_NEWCLOSURE overflow protection (issue #3458)\n# Test 1: Too many function parameters (4097 params triggers the limit)\necho \"Testing function parameter limit...\"\ncat > $d/expected <<EOF\njq: error: too many function parameters or local function definitions (max 4095)\njq: 1 compile error\nEOF\n$JQ -rn '\"def f(\\([range(4097) | \"a\\(.)\"] | join(\";\"))): .; f(\\([range(4097)] | join(\";\")))\"' > $d/prog.jq\n$JQ -nf $d/prog.jq 2> $d/out && {\n  echo \"Expected compile error for too many parameters\"\n  exit 1\n}\ndiff $d/out $d/expected\n\n# Test 2: Too many local functions (4097 functions triggers the limit)\necho \"Testing local function limit...\"\ncat > $d/expected <<EOF\njq: error: too many function parameters or local function definitions (max 4095)\njq: 1 compile error\nEOF\n$JQ -rn '\"\\([range(4097) | \"def f\\(.): \\(.)\"] | join(\"; \")); \\([range(4097) | \"f\\(.)\"] | join(\" + \"))\"' > $d/prog.jq\n$JQ -nf $d/prog.jq 2> $d/out && {\n  echo \"Expected compile error for too many local functions\"\n  exit 1\n}\ndiff $d/out $d/expected\n\nexit 0\n"
  },
  {
    "path": "tests/torture/input0.json",
    "content": "0 12 true false null [] {} [{}] [[]]\n[0,01,[12,22,[34,[45,56],7]],[]]\n{\"a\":[1]}\n{\"a\":[{}]}\n{\"a\":[{},[],[[]]]}\n{\"a\":[{\"b\":[]}]}\n{\"a\":[{\"b\":[]},{},[2]]}\n"
  },
  {
    "path": "tests/uri.test",
    "content": "# Tests are groups of three lines: program, input, expected output\n# Blank lines and lines starting with # are ignored\n\n# @uri\n\n@uri\n\"\"\n\"\"\n\n@uri\n\"\\b\\t\\n\\f\\r\\\"\\\\\"\n\"%08%09%0A%0C%0D%22%5C\"\n\n@uri\n\",-./09:;<=>?@AZ[\\\\]^_`az{|}~\\u007f\"\n\"%2C-.%2F09%3A%3B%3C%3D%3E%3F%40AZ%5B%5C%5D%5E_%60az%7B%7C%7D~%7F\"\n\n@uri\n\"a \\u03bc \\u2230 \\ud83d\\ude0e\"\n\"a%20%CE%BC%20%E2%88%B0%20%F0%9F%98%8E\"\n\n@uri\n\"a\\u0000b\\u0000c\"\n\"a%00b%00c\"\n\n# @urid\n\n@urid\n\"\"\n\"\"\n\n@urid\n\"%08%09%0A%0C%0D%22%5C\"\n\"\\b\\t\\n\\f\\r\\\"\\\\\"\n\n@urid\n\"%2C-.%2F09%3A%3B%3C%3D%3E%3F%40AZ%5B%5C%5D%5E_%60az%7B%7C%7D~%7F\"\n\",-./09:;<=>?@AZ[\\\\]^_`az{|}~\\u007f\"\n\n@urid\n\"a%20%CE%BC%20%E2%88%B0%20%F0%9F%98%8E\"\n\"a \\u03bc \\u2230 \\ud83d\\ude0e\"\n\n@urid\n\"a%00b%00c\"\n\"a\\u0000b\\u0000c\"\n\n@urid\n\"hello world\"\n\"hello world\"\n\n@urid\n\"Knäckebröd\"\n\"Knäckebröd\"\n\n@urid\n\"%c3%a4b%c3%a7d%c3%ab\"\n\"äbçdë\"\n\n@urid\n\"a\\u0000b\\u0000c\"\n\"a\\u0000b\\u0000c\"\n\n# '%' at end of string\n. | try @urid catch .\n\"abc%\"\n\"string (\\\"abc%\\\") is not a valid uri encoding\"\n\n# '%' followed by only one hex digit\n. | try @urid catch .\n\"abc%f\"\n\"string (\\\"abc%f\\\") is not a valid uri encoding\"\n\n# '%' followed by non-hex character\n. | try @urid catch .\n\"abc%g\"\n\"string (\\\"abc%g\\\") is not a valid uri encoding\"\n\n# invalid hex value ('FX')\n. | try @urid catch .\n\"%FX%9F%98%8E\"\n\"string (\\\"%FX%9F%98%8E\\\") is not a valid uri encoding\"\n\n# incomplete 4-byte UTF-8 sequence (only 3 bytes)\n. | try @urid catch .\n\"%F0%93%81\"\n\"string (\\\"%F0%93%81\\\") is not a valid uri encoding\"\n\n# invalid continuation byte (0xC0 is not 10xxxxxx)\n. | try @urid catch .\n\"%F0%C0%81%8E\"\n\"string (\\\"%F0%C0%81%8E\\\") is not a valid uri encoding\"\n"
  },
  {
    "path": "tests/uritest",
    "content": "#!/bin/sh\n\n. \"${0%/*}/setup\" \"$@\"\n\n$VALGRIND $Q $JQ -L \"$mods\" --run-tests $JQTESTDIR/uri.test\n"
  },
  {
    "path": "tests/utf8test",
    "content": "#!/bin/sh -x\n\n. \"${0%/*}/setup\" \"$@\"\n\n# Reading jq file does not corrupt multi-byte characters -- #1311\nfor l in 1 2 3 4; do\n  $VALGRIND $Q $JQ -rn \"[(range($l) | 48), (range(3000) | 128515)] | implode |\n    \\\"\\\\(tojson) | explode | unique == [48, 128515]\\\"\" > $d/input\n  if ! $VALGRIND $Q $JQ -nef $d/input > /dev/null; then\n    echo \"Reading jq file corrupted multi-byte characters\"\n    exit 1\n  fi\ndone\n\n# Slurping raw input does not corrupt multi-byte characters -- #3389\nfor l in 1 2 3 4; do\n  $VALGRIND $Q $JQ -jn \"[(range($l) | 48), (range(3000) | 128515)] | implode\" > $d/input\n  if ! $VALGRIND $Q $JQ -Rse 'explode | unique == [48, 128515]' $d/input > /dev/null; then\n    echo \"Slurping raw input corrupted multi-byte characters\"\n    exit 1\n  fi\ndone\n\nexit 0\n"
  },
  {
    "path": "tests/yes-main-program.jq",
    "content": "def a: .;\n0\n"
  },
  {
    "path": "vendor/decNumber/ICU-license.html",
    "content": "<html>\r\n\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=us-ascii\"></meta>\r\n<title>ICU License - ICU 1.8.1 and later</title>\r\n</head>\r\n\r\n<body>\r\n<h1>ICU License - ICU 1.8.1 and later</h1>\r\n<pre>\r\nCOPYRIGHT AND PERMISSION NOTICE\r\n\r\nCopyright (c) 1995-2005 International Business Machines Corporation and others\r\nAll rights reserved.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a\r\ncopy of this software and associated documentation files (the\r\n\"Software\"), to deal in the Software without restriction, including\r\nwithout limitation the rights to use, copy, modify, merge, publish,\r\ndistribute, and/or sell copies of the Software, and to permit persons\r\nto whom the Software is furnished to do so, provided that the above\r\ncopyright notice(s) and this permission notice appear in all copies of\r\nthe Software and that both the above copyright notice(s) and this\r\npermission notice appear in supporting documentation.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\r\nOF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR\r\nHOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL\r\nINDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING\r\nFROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\r\nNEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION\r\nWITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\r\n\r\nExcept as contained in this notice, the name of a copyright holder\r\nshall not be used in advertising or otherwise to promote the sale, use\r\nor other dealings in this Software without prior written authorization\r\nof the copyright holder.\r\n\r\n--------------------------------------------------------------------------------\r\nAll trademarks and registered trademarks mentioned herein are the property of their respective owners.\r\n</pre>\r\n</body>\r\n</html>\r\n"
  },
  {
    "path": "vendor/decNumber/decBasic.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* decBasic.c -- common base code for Basic decimal types             */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2010.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is included in the package as decNumber.pdf.  This   */\r\n/* document is also available in HTML, together with specifications,  */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This module comprises code that is shared between decDouble and    */\r\n/* decQuad (but not decSingle).  The main arithmetic operations are   */\r\n/* here (Add, Subtract, Multiply, FMA, and Division operators).       */\r\n/*                                                                    */\r\n/* Unlike decNumber, parameterization takes place at compile time     */\r\n/* rather than at runtime.  The parameters are set in the decDouble.c */\r\n/* (etc.) files, which then include this one to produce the compiled  */\r\n/* code.  The functions here, therefore, are code shared between      */\r\n/* multiple formats.                                                  */\r\n/*                                                                    */\r\n/* This must be included after decCommon.c.                           */\r\n/* ------------------------------------------------------------------ */\r\n// Names here refer to decFloat rather than to decDouble, etc., and\r\n// the functions are in strict alphabetical order.\r\n\r\n// The compile-time flags SINGLE, DOUBLE, and QUAD are set up in\r\n// decCommon.c\r\n#if !defined(QUAD)\r\n  #error decBasic.c must be included after decCommon.c\r\n#endif\r\n#if SINGLE\r\n  #error Routines in decBasic.c are for decDouble and decQuad only\r\n#endif\r\n\r\n/* Private constants */\r\n#define DIVIDE      0x80000000     // Divide operations [as flags]\r\n#define REMAINDER   0x40000000     // ..\r\n#define DIVIDEINT   0x20000000     // ..\r\n#define REMNEAR     0x10000000     // ..\r\n\r\n/* Private functions (local, used only by routines in this module) */\r\nstatic decFloat *decDivide(decFloat *, const decFloat *,\r\n                              const decFloat *, decContext *, uInt);\r\nstatic decFloat *decCanonical(decFloat *, const decFloat *);\r\nstatic void      decFiniteMultiply(bcdnum *, uByte *, const decFloat *,\r\n                              const decFloat *);\r\nstatic decFloat *decInfinity(decFloat *, const decFloat *);\r\nstatic decFloat *decInvalid(decFloat *, decContext *);\r\nstatic decFloat *decNaNs(decFloat *, const decFloat *, const decFloat *,\r\n                              decContext *);\r\nstatic Int       decNumCompare(const decFloat *, const decFloat *, Flag);\r\nstatic decFloat *decToIntegral(decFloat *, const decFloat *, decContext *,\r\n                              enum rounding, Flag);\r\nstatic uInt      decToInt32(const decFloat *, decContext *, enum rounding,\r\n                              Flag, Flag);\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decCanonical -- copy a decFloat, making canonical                  */\r\n/*                                                                    */\r\n/*   result gets the canonicalized df                                 */\r\n/*   df     is the decFloat to copy and make canonical                */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This is exposed via decFloatCanonical for Double and Quad only.    */\r\n/* This works on specials, too; no error or exception is possible.    */\r\n/* ------------------------------------------------------------------ */\r\nstatic decFloat * decCanonical(decFloat *result, const decFloat *df) {\r\n  uInt encode, precode, dpd;       // work\r\n  uInt inword, uoff, canon;        // ..\r\n  Int  n;                          // counter (down)\r\n  if (df!=result) *result=*df;     // effect copy if needed\r\n  if (DFISSPECIAL(result)) {\r\n    if (DFISINF(result)) return decInfinity(result, df); // clean Infinity\r\n    // is a NaN\r\n    DFWORD(result, 0)&=~ECONNANMASK;    // clear ECON except selector\r\n    if (DFISCCZERO(df)) return result;  // coefficient continuation is 0\r\n    // drop through to check payload\r\n    }\r\n  // return quickly if the coefficient continuation is canonical\r\n  { // declare block\r\n  #if DOUBLE\r\n    uInt sourhi=DFWORD(df, 0);\r\n    uInt sourlo=DFWORD(df, 1);\r\n    if (CANONDPDOFF(sourhi, 8)\r\n     && CANONDPDTWO(sourhi, sourlo, 30)\r\n     && CANONDPDOFF(sourlo, 20)\r\n     && CANONDPDOFF(sourlo, 10)\r\n     && CANONDPDOFF(sourlo, 0)) return result;\r\n  #elif QUAD\r\n    uInt sourhi=DFWORD(df, 0);\r\n    uInt sourmh=DFWORD(df, 1);\r\n    uInt sourml=DFWORD(df, 2);\r\n    uInt sourlo=DFWORD(df, 3);\r\n    if (CANONDPDOFF(sourhi, 4)\r\n     && CANONDPDTWO(sourhi, sourmh, 26)\r\n     && CANONDPDOFF(sourmh, 16)\r\n     && CANONDPDOFF(sourmh, 6)\r\n     && CANONDPDTWO(sourmh, sourml, 28)\r\n     && CANONDPDOFF(sourml, 18)\r\n     && CANONDPDOFF(sourml, 8)\r\n     && CANONDPDTWO(sourml, sourlo, 30)\r\n     && CANONDPDOFF(sourlo, 20)\r\n     && CANONDPDOFF(sourlo, 10)\r\n     && CANONDPDOFF(sourlo, 0)) return result;\r\n  #endif\r\n  } // block\r\n\r\n  // Loop to repair a non-canonical coefficent, as needed\r\n  inword=DECWORDS-1;               // current input word\r\n  uoff=0;                          // bit offset of declet\r\n  encode=DFWORD(result, inword);\r\n  for (n=DECLETS-1; n>=0; n--) {   // count down declets of 10 bits\r\n    dpd=encode>>uoff;\r\n    uoff+=10;\r\n    if (uoff>32) {                 // crossed uInt boundary\r\n      inword--;\r\n      encode=DFWORD(result, inword);\r\n      uoff-=32;\r\n      dpd|=encode<<(10-uoff);      // get pending bits\r\n      }\r\n    dpd&=0x3ff;                    // clear uninteresting bits\r\n    if (dpd<0x16e) continue;       // must be canonical\r\n    canon=BIN2DPD[DPD2BIN[dpd]];   // determine canonical declet\r\n    if (canon==dpd) continue;      // have canonical declet\r\n    // need to replace declet\r\n    if (uoff>=10) {                // all within current word\r\n      encode&=~(0x3ff<<(uoff-10)); // clear the 10 bits ready for replace\r\n      encode|=canon<<(uoff-10);    // insert the canonical form\r\n      DFWORD(result, inword)=encode;    // .. and save\r\n      continue;\r\n      }\r\n    // straddled words\r\n    precode=DFWORD(result, inword+1);   // get previous\r\n    precode&=0xffffffff>>(10-uoff);     // clear top bits\r\n    DFWORD(result, inword+1)=precode|(canon<<(32-(10-uoff)));\r\n    encode&=0xffffffff<<uoff;           // clear bottom bits\r\n    encode|=canon>>(10-uoff);           // insert canonical\r\n    DFWORD(result, inword)=encode;      // .. and save\r\n    } // n\r\n  return result;\r\n  } // decCanonical\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decDivide -- divide operations                                     */\r\n/*                                                                    */\r\n/*   result gets the result of dividing dfl by dfr:                   */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   op     is the operation selector                                 */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* op is one of DIVIDE, REMAINDER, DIVIDEINT, or REMNEAR.             */\r\n/* ------------------------------------------------------------------ */\r\n#define DIVCOUNT  0                // 1 to instrument subtractions counter\r\n#define DIVBASE   ((uInt)BILLION)  // the base used for divide\r\n#define DIVOPLEN  DECPMAX9         // operand length ('digits' base 10**9)\r\n#define DIVACCLEN (DIVOPLEN*3)     // accumulator length (ditto)\r\nstatic decFloat * decDivide(decFloat *result, const decFloat *dfl,\r\n                            const decFloat *dfr, decContext *set, uInt op) {\r\n  decFloat quotient;               // for remainders\r\n  bcdnum num;                      // for final conversion\r\n  uInt   acc[DIVACCLEN];           // coefficent in base-billion ..\r\n  uInt   div[DIVOPLEN];            // divisor in base-billion ..\r\n  uInt   quo[DIVOPLEN+1];          // quotient in base-billion ..\r\n  uByte  bcdacc[(DIVOPLEN+1)*9+2]; // for quotient in BCD, +1, +1\r\n  uInt   *msua, *msud, *msuq;      // -> msu of acc, div, and quo\r\n  Int    divunits, accunits;       // lengths\r\n  Int    quodigits;                // digits in quotient\r\n  uInt   *lsua, *lsuq;             // -> current acc and quo lsus\r\n  Int    length, multiplier;       // work\r\n  uInt   carry, sign;              // ..\r\n  uInt   *ua, *ud, *uq;            // ..\r\n  uByte  *ub;                      // ..\r\n  uInt   uiwork;                   // for macros\r\n  uInt   divtop;                   // top unit of div adjusted for estimating\r\n  #if DIVCOUNT\r\n  static uInt maxcount=0;          // worst-seen subtractions count\r\n  uInt   divcount=0;               // subtractions count [this divide]\r\n  #endif\r\n\r\n  // calculate sign\r\n  num.sign=(DFWORD(dfl, 0)^DFWORD(dfr, 0)) & DECFLOAT_Sign;\r\n\r\n  if (DFISSPECIAL(dfl) || DFISSPECIAL(dfr)) { // either is special?\r\n    // NaNs are handled as usual\r\n    if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n    // one or two infinities\r\n    if (DFISINF(dfl)) {\r\n      if (DFISINF(dfr)) return decInvalid(result, set); // Two infinities bad\r\n      if (op&(REMAINDER|REMNEAR)) return decInvalid(result, set); // as is rem\r\n      // Infinity/x is infinite and quiet, even if x=0\r\n      DFWORD(result, 0)=num.sign;\r\n      return decInfinity(result, result);\r\n      }\r\n    // must be x/Infinity -- remainders are lhs\r\n    if (op&(REMAINDER|REMNEAR)) return decCanonical(result, dfl);\r\n    // divides: return zero with correct sign and exponent depending\r\n    // on op (Etiny for divide, 0 for divideInt)\r\n    decFloatZero(result);\r\n    if (op==DIVIDEINT) DFWORD(result, 0)|=num.sign; // add sign\r\n     else DFWORD(result, 0)=num.sign;        // zeros the exponent, too\r\n    return result;\r\n    }\r\n  // next, handle zero operands (x/0 and 0/x)\r\n  if (DFISZERO(dfr)) {                       // x/0\r\n    if (DFISZERO(dfl)) {                     // 0/0 is undefined\r\n      decFloatZero(result);\r\n      DFWORD(result, 0)=DECFLOAT_qNaN;\r\n      set->status|=DEC_Division_undefined;\r\n      return result;\r\n      }\r\n    if (op&(REMAINDER|REMNEAR)) return decInvalid(result, set); // bad rem\r\n    set->status|=DEC_Division_by_zero;\r\n    DFWORD(result, 0)=num.sign;\r\n    return decInfinity(result, result);      // x/0 -> signed Infinity\r\n    }\r\n  num.exponent=GETEXPUN(dfl)-GETEXPUN(dfr);  // ideal exponent\r\n  if (DFISZERO(dfl)) {                       // 0/x (x!=0)\r\n    // if divide, result is 0 with ideal exponent; divideInt has\r\n    // exponent=0, remainders give zero with lower exponent\r\n    if (op&DIVIDEINT) {\r\n      decFloatZero(result);\r\n      DFWORD(result, 0)|=num.sign;           // add sign\r\n      return result;\r\n      }\r\n    if (!(op&DIVIDE)) {                      // a remainder\r\n      // exponent is the minimum of the operands\r\n      num.exponent=MINI(GETEXPUN(dfl), GETEXPUN(dfr));\r\n      // if the result is zero the sign shall be sign of dfl\r\n      num.sign=DFWORD(dfl, 0)&DECFLOAT_Sign;\r\n      }\r\n    bcdacc[0]=0;\r\n    num.msd=bcdacc;                          // -> 0\r\n    num.lsd=bcdacc;                          // ..\r\n    return decFinalize(result, &num, set);   // [divide may clamp exponent]\r\n    } // 0/x\r\n  // [here, both operands are known to be finite and non-zero]\r\n\r\n  // extract the operand coefficents into 'units' which are\r\n  // base-billion; the lhs is high-aligned in acc and the msu of both\r\n  // acc and div is at the right-hand end of array (offset length-1);\r\n  // the quotient can need one more unit than the operands as digits\r\n  // in it are not necessarily aligned neatly; further, the quotient\r\n  // may not start accumulating until after the end of the initial\r\n  // operand in acc if that is small (e.g., 1) so the accumulator\r\n  // must have at least that number of units extra (at the ls end)\r\n  GETCOEFFBILL(dfl, acc+DIVACCLEN-DIVOPLEN);\r\n  GETCOEFFBILL(dfr, div);\r\n  // zero the low uInts of acc\r\n  acc[0]=0;\r\n  acc[1]=0;\r\n  acc[2]=0;\r\n  acc[3]=0;\r\n  #if DOUBLE\r\n    #if DIVOPLEN!=2\r\n      #error Unexpected Double DIVOPLEN\r\n    #endif\r\n  #elif QUAD\r\n  acc[4]=0;\r\n  acc[5]=0;\r\n  acc[6]=0;\r\n  acc[7]=0;\r\n    #if DIVOPLEN!=4\r\n      #error Unexpected Quad DIVOPLEN\r\n    #endif\r\n  #endif\r\n\r\n  // set msu and lsu pointers\r\n  msua=acc+DIVACCLEN-1;       // [leading zeros removed below]\r\n  msuq=quo+DIVOPLEN;\r\n  //[loop for div will terminate because operands are non-zero]\r\n  for (msud=div+DIVOPLEN-1; *msud==0;) msud--;\r\n  // the initial least-significant unit of acc is set so acc appears\r\n  // to have the same length as div.\r\n  // This moves one position towards the least possible for each\r\n  // iteration\r\n  divunits=(Int)(msud-div+1); // precalculate\r\n  lsua=msua-divunits+1;       // initial working lsu of acc\r\n  lsuq=msuq;                  // and of quo\r\n\r\n  // set up the estimator for the multiplier; this is the msu of div,\r\n  // plus two bits from the unit below (if any) rounded up by one if\r\n  // there are any non-zero bits or units below that [the extra two\r\n  // bits makes for a much better estimate when the top unit is small]\r\n  divtop=*msud<<2;\r\n  if (divunits>1) {\r\n    uInt *um=msud-1;\r\n    uInt d=*um;\r\n    if (d>=750000000) {divtop+=3; d-=750000000;}\r\n     else if (d>=500000000) {divtop+=2; d-=500000000;}\r\n     else if (d>=250000000) {divtop++; d-=250000000;}\r\n    if (d) divtop++;\r\n     else for (um--; um>=div; um--) if (*um) {\r\n      divtop++;\r\n      break;\r\n      }\r\n    } // >1 unit\r\n\r\n  #if DECTRACE\r\n  {Int i;\r\n  printf(\"----- div=\");\r\n  for (i=divunits-1; i>=0; i--) printf(\"%09ld \", (LI)div[i]);\r\n  printf(\"\\n\");}\r\n  #endif\r\n\r\n  // now collect up to DECPMAX+1 digits in the quotient (this may\r\n  // need OPLEN+1 uInts if unaligned)\r\n  quodigits=0;                // no digits yet\r\n  for (;; lsua--) {           // outer loop -- each input position\r\n    #if DECCHECK\r\n    if (lsua<acc) {\r\n      printf(\"Acc underrun...\\n\");\r\n      break;\r\n      }\r\n    #endif\r\n    #if DECTRACE\r\n    printf(\"Outer: quodigits=%ld acc=\", (LI)quodigits);\r\n    for (ua=msua; ua>=lsua; ua--) printf(\"%09ld \", (LI)*ua);\r\n    printf(\"\\n\");\r\n    #endif\r\n    *lsuq=0;                  // default unit result is 0\r\n    for (;;) {                // inner loop -- calculate quotient unit\r\n      // strip leading zero units from acc (either there initially or\r\n      // from subtraction below); this may strip all if exactly 0\r\n      for (; *msua==0 && msua>=lsua;) msua--;\r\n      accunits=(Int)(msua-lsua+1);                // [maybe 0]\r\n      // subtraction is only necessary and possible if there are as\r\n      // least as many units remaining in acc for this iteration as\r\n      // there are in div\r\n      if (accunits<divunits) {\r\n        if (accunits==0) msua++;                  // restore\r\n        break;\r\n        }\r\n\r\n      // If acc is longer than div then subtraction is definitely\r\n      // possible (as msu of both is non-zero), but if they are the\r\n      // same length a comparison is needed.\r\n      // If a subtraction is needed then a good estimate of the\r\n      // multiplier for the subtraction is also needed in order to\r\n      // minimise the iterations of this inner loop because the\r\n      // subtractions needed dominate division performance.\r\n      if (accunits==divunits) {\r\n        // compare the high divunits of acc and div:\r\n        // acc<div:  this quotient unit is unchanged; subtraction\r\n        //           will be possible on the next iteration\r\n        // acc==div: quotient gains 1, set acc=0\r\n        // acc>div:  subtraction necessary at this position\r\n        for (ud=msud, ua=msua; ud>div; ud--, ua--) if (*ud!=*ua) break;\r\n        // [now at first mismatch or lsu]\r\n        if (*ud>*ua) break;                       // next time...\r\n        if (*ud==*ua) {                           // all compared equal\r\n          *lsuq+=1;                               // increment result\r\n          msua=lsua;                              // collapse acc units\r\n          *msua=0;                                // .. to a zero\r\n          break;\r\n          }\r\n\r\n        // subtraction necessary; estimate multiplier [see above]\r\n        // if both *msud and *msua are small it is cost-effective to\r\n        // bring in part of the following units (if any) to get a\r\n        // better estimate (assume some other non-zero in div)\r\n        #define DIVLO 1000000U\r\n        #define DIVHI (DIVBASE/DIVLO)\r\n        #if DECUSE64\r\n          if (divunits>1) {\r\n            // there cannot be a *(msud-2) for DECDOUBLE so next is\r\n            // an exact calculation unless DECQUAD (which needs to\r\n            // assume bits out there if divunits>2)\r\n            uLong mul=(uLong)*msua * DIVBASE + *(msua-1);\r\n            uLong div=(uLong)*msud * DIVBASE + *(msud-1);\r\n            #if QUAD\r\n            if (divunits>2) div++;\r\n            #endif\r\n            mul/=div;\r\n            multiplier=(Int)mul;\r\n            }\r\n           else multiplier=*msua/(*msud);\r\n        #else\r\n          if (divunits>1 && *msua<DIVLO && *msud<DIVLO) {\r\n            multiplier=(*msua*DIVHI + *(msua-1)/DIVLO)\r\n                      /(*msud*DIVHI + *(msud-1)/DIVLO +1);\r\n            }\r\n           else multiplier=(*msua<<2)/divtop;\r\n        #endif\r\n        }\r\n       else {                                     // accunits>divunits\r\n        // msud is one unit 'lower' than msua, so estimate differently\r\n        #if DECUSE64\r\n          uLong mul;\r\n          // as before, bring in extra digits if possible\r\n          if (divunits>1 && *msua<DIVLO && *msud<DIVLO) {\r\n            mul=((uLong)*msua * DIVHI * DIVBASE) + *(msua-1) * DIVHI\r\n               + *(msua-2)/DIVLO;\r\n            mul/=(*msud*DIVHI + *(msud-1)/DIVLO +1);\r\n            }\r\n           else if (divunits==1) {\r\n            mul=(uLong)*msua * DIVBASE + *(msua-1);\r\n            mul/=*msud;       // no more to the right\r\n            }\r\n           else {\r\n            mul=(uLong)(*msua) * (uInt)(DIVBASE<<2)\r\n                + (*(msua-1)<<2);\r\n            mul/=divtop;      // [divtop already allows for sticky bits]\r\n            }\r\n          multiplier=(Int)mul;\r\n        #else\r\n          multiplier=*msua * ((DIVBASE<<2)/divtop);\r\n        #endif\r\n        }\r\n      if (multiplier==0) multiplier=1;            // marginal case\r\n      *lsuq+=multiplier;\r\n\r\n      #if DIVCOUNT\r\n      // printf(\"Multiplier: %ld\\n\", (LI)multiplier);\r\n      divcount++;\r\n      #endif\r\n\r\n      // Carry out the subtraction  acc-(div*multiplier); for each\r\n      // unit in div, do the multiply, split to units (see\r\n      // decFloatMultiply for the algorithm), and subtract from acc\r\n      #define DIVMAGIC  2305843009U               // 2**61/10**9\r\n      #define DIVSHIFTA 29\r\n      #define DIVSHIFTB 32\r\n      carry=0;\r\n      for (ud=div, ua=lsua; ud<=msud; ud++, ua++) {\r\n        uInt lo, hop;\r\n        #if DECUSE64\r\n          uLong sub=(uLong)multiplier*(*ud)+carry;\r\n          if (sub<DIVBASE) {\r\n            carry=0;\r\n            lo=(uInt)sub;\r\n            }\r\n           else {\r\n            hop=(uInt)(sub>>DIVSHIFTA);\r\n            carry=(uInt)(((uLong)hop*DIVMAGIC)>>DIVSHIFTB);\r\n            // the estimate is now in hi; now calculate sub-hi*10**9\r\n            // to get the remainder (which will be <DIVBASE))\r\n            lo=(uInt)sub;\r\n            lo-=carry*DIVBASE;                    // low word of result\r\n            if (lo>=DIVBASE) {\r\n              lo-=DIVBASE;                        // correct by +1\r\n              carry++;\r\n              }\r\n            }\r\n        #else // 32-bit\r\n          uInt hi;\r\n          // calculate multiplier*(*ud) into hi and lo\r\n          LONGMUL32HI(hi, *ud, multiplier);       // get the high word\r\n          lo=multiplier*(*ud);                    // .. and the low\r\n          lo+=carry;                              // add the old hi\r\n          carry=hi+(lo<carry);                    // .. with any carry\r\n          if (carry || lo>=DIVBASE) {             // split is needed\r\n            hop=(carry<<3)+(lo>>DIVSHIFTA);       // hi:lo/2**29\r\n            LONGMUL32HI(carry, hop, DIVMAGIC);    // only need the high word\r\n            // [DIVSHIFTB is 32, so carry can be used directly]\r\n            // the estimate is now in carry; now calculate hi:lo-est*10**9;\r\n            // happily the top word of the result is irrelevant because it\r\n            // will always be zero so this needs only one multiplication\r\n            lo-=(carry*DIVBASE);\r\n            // the correction here will be at most +1; do it\r\n            if (lo>=DIVBASE) {\r\n              lo-=DIVBASE;\r\n              carry++;\r\n              }\r\n            }\r\n        #endif\r\n        if (lo>*ua) {              // borrow needed\r\n          *ua+=DIVBASE;\r\n          carry++;\r\n          }\r\n        *ua-=lo;\r\n        } // ud loop\r\n      if (carry) *ua-=carry;       // accdigits>divdigits [cannot borrow]\r\n      } // inner loop\r\n\r\n    // the outer loop terminates when there is either an exact result\r\n    // or enough digits; first update the quotient digit count and\r\n    // pointer (if any significant digits)\r\n    #if DECTRACE\r\n    if (*lsuq || quodigits) printf(\"*lsuq=%09ld\\n\", (LI)*lsuq);\r\n    #endif\r\n    if (quodigits) {\r\n      quodigits+=9;                // had leading unit earlier\r\n      lsuq--;\r\n      if (quodigits>DECPMAX+1) break;   // have enough\r\n      }\r\n     else if (*lsuq) {             // first quotient digits\r\n      const uInt *pow;\r\n      for (pow=DECPOWERS; *lsuq>=*pow; pow++) quodigits++;\r\n      lsuq--;\r\n      // [cannot have >DECPMAX+1 on first unit]\r\n      }\r\n\r\n    if (*msua!=0) continue;        // not an exact result\r\n    // acc is zero iff used all of original units and zero down to lsua\r\n    // (must also continue to original lsu for correct quotient length)\r\n    if (lsua>acc+DIVACCLEN-DIVOPLEN) continue;\r\n    for (; msua>lsua && *msua==0;) msua--;\r\n    if (*msua==0 && msua==lsua) break;\r\n    } // outer loop\r\n\r\n  // all of the original operand in acc has been covered at this point\r\n  // quotient now has at least DECPMAX+2 digits\r\n  // *msua is now non-0 if inexact and sticky bits\r\n  // lsuq is one below the last uint of the quotient\r\n  lsuq++;                          // set -> true lsu of quo\r\n  if (*msua) *lsuq|=1;             // apply sticky bit\r\n\r\n  // quo now holds the (unrounded) quotient in base-billion; one\r\n  // base-billion 'digit' per uInt.\r\n  #if DECTRACE\r\n  printf(\"DivQuo:\");\r\n  for (uq=msuq; uq>=lsuq; uq--) printf(\" %09ld\", (LI)*uq);\r\n  printf(\"\\n\");\r\n  #endif\r\n\r\n  // Now convert to BCD for rounding and cleanup, starting from the\r\n  // most significant end [offset by one into bcdacc to leave room\r\n  // for a possible carry digit if rounding for REMNEAR is needed]\r\n  for (uq=msuq, ub=bcdacc+1; uq>=lsuq; uq--, ub+=9) {\r\n    uInt top, mid, rem;                 // work\r\n    if (*uq==0) {                       // no split needed\r\n      UBFROMUI(ub, 0);                  // clear 9 BCD8s\r\n      UBFROMUI(ub+4, 0);                // ..\r\n      *(ub+8)=0;                        // ..\r\n      continue;\r\n      }\r\n    // *uq is non-zero -- split the base-billion digit into\r\n    // hi, mid, and low three-digits\r\n    #define divsplit9 1000000           // divisor\r\n    #define divsplit6 1000              // divisor\r\n    // The splitting is done by simple divides and remainders,\r\n    // assuming the compiler will optimize these [GCC does]\r\n    top=*uq/divsplit9;\r\n    rem=*uq%divsplit9;\r\n    mid=rem/divsplit6;\r\n    rem=rem%divsplit6;\r\n    // lay out the nine BCD digits (plus one unwanted byte)\r\n    UBFROMUI(ub,   UBTOUI(&BIN2BCD8[top*4]));\r\n    UBFROMUI(ub+3, UBTOUI(&BIN2BCD8[mid*4]));\r\n    UBFROMUI(ub+6, UBTOUI(&BIN2BCD8[rem*4]));\r\n    } // BCD conversion loop\r\n  ub--;                                 // -> lsu\r\n\r\n  // complete the bcdnum; quodigits is correct, so the position of\r\n  // the first non-zero is known\r\n  num.msd=bcdacc+1+(msuq-lsuq+1)*9-quodigits;\r\n  num.lsd=ub;\r\n\r\n  // make exponent adjustments, etc\r\n  if (lsua<acc+DIVACCLEN-DIVOPLEN) {    // used extra digits\r\n    num.exponent-=(Int)((acc+DIVACCLEN-DIVOPLEN-lsua)*9);\r\n    // if the result was exact then there may be up to 8 extra\r\n    // trailing zeros in the overflowed quotient final unit\r\n    if (*msua==0) {\r\n      for (; *ub==0;) ub--;             // drop zeros\r\n      num.exponent+=(Int)(num.lsd-ub);  // and adjust exponent\r\n      num.lsd=ub;\r\n      }\r\n    } // adjustment needed\r\n\r\n  #if DIVCOUNT\r\n  if (divcount>maxcount) {              // new high-water nark\r\n    maxcount=divcount;\r\n    printf(\"DivNewMaxCount: %ld\\n\", (LI)maxcount);\r\n    }\r\n  #endif\r\n\r\n  if (op&DIVIDE) return decFinalize(result, &num, set); // all done\r\n\r\n  // Is DIVIDEINT or a remainder; there is more to do -- first form\r\n  // the integer (this is done 'after the fact', unlike as in\r\n  // decNumber, so as not to tax DIVIDE)\r\n\r\n  // The first non-zero digit will be in the first 9 digits, known\r\n  // from quodigits and num.msd, so there is always space for DECPMAX\r\n  // digits\r\n\r\n  length=(Int)(num.lsd-num.msd+1);\r\n  //printf(\"Length exp: %ld %ld\\n\", (LI)length, (LI)num.exponent);\r\n\r\n  if (length+num.exponent>DECPMAX) { // cannot fit\r\n    decFloatZero(result);\r\n    DFWORD(result, 0)=DECFLOAT_qNaN;\r\n    set->status|=DEC_Division_impossible;\r\n    return result;\r\n    }\r\n\r\n  if (num.exponent>=0) {           // already an int, or need pad zeros\r\n    for (ub=num.lsd+1; ub<=num.lsd+num.exponent; ub++) *ub=0;\r\n    num.lsd+=num.exponent;\r\n    }\r\n   else {                          // too long: round or truncate needed\r\n    Int drop=-num.exponent;\r\n    if (!(op&REMNEAR)) {           // simple truncate\r\n      num.lsd-=drop;\r\n      if (num.lsd<num.msd) {       // truncated all\r\n        num.lsd=num.msd;           // make 0\r\n        *num.lsd=0;                // .. [sign still relevant]\r\n        }\r\n      }\r\n     else {                        // round to nearest even [sigh]\r\n      // round-to-nearest, in-place; msd is at or to right of bcdacc+1\r\n      // (this is a special case of Quantize -- q.v. for commentary)\r\n      uByte *roundat;              // -> re-round digit\r\n      uByte reround;               // reround value\r\n      *(num.msd-1)=0;              // in case of left carry, or make 0\r\n      if (drop<length) roundat=num.lsd-drop+1;\r\n       else if (drop==length) roundat=num.msd;\r\n       else roundat=num.msd-1;     // [-> 0]\r\n      reround=*roundat;\r\n      for (ub=roundat+1; ub<=num.lsd; ub++) {\r\n        if (*ub!=0) {\r\n          reround=DECSTICKYTAB[reround];\r\n          break;\r\n          }\r\n        } // check stickies\r\n      if (roundat>num.msd) num.lsd=roundat-1;\r\n       else {\r\n        num.msd--;                           // use the 0 ..\r\n        num.lsd=num.msd;                     // .. at the new MSD place\r\n        }\r\n      if (reround!=0) {                      // discarding non-zero\r\n        uInt bump=0;\r\n        // rounding is DEC_ROUND_HALF_EVEN always\r\n        if (reround>5) bump=1;               // >0.5 goes up\r\n         else if (reround==5)                // exactly 0.5000 ..\r\n          bump=*(num.lsd) & 0x01;            // .. up iff [new] lsd is odd\r\n        if (bump!=0) {                       // need increment\r\n          // increment the coefficient; this might end up with 1000...\r\n          ub=num.lsd;\r\n          for (; UBTOUI(ub-3)==0x09090909; ub-=4) UBFROMUI(ub-3, 0);\r\n          for (; *ub==9; ub--) *ub=0;        // at most 3 more\r\n          *ub+=1;\r\n          if (ub<num.msd) num.msd--;         // carried\r\n          } // bump needed\r\n        } // reround!=0\r\n      } // remnear\r\n    } // round or truncate needed\r\n  num.exponent=0;                            // all paths\r\n  //decShowNum(&num, \"int\");\r\n\r\n  if (op&DIVIDEINT) return decFinalize(result, &num, set); // all done\r\n\r\n  // Have a remainder to calculate\r\n  decFinalize(&quotient, &num, set);         // lay out the integer so far\r\n  DFWORD(&quotient, 0)^=DECFLOAT_Sign;       // negate it\r\n  sign=DFWORD(dfl, 0);                       // save sign of dfl\r\n  decFloatFMA(result, &quotient, dfr, dfl, set);\r\n  if (!DFISZERO(result)) return result;\r\n  // if the result is zero the sign shall be sign of dfl\r\n  DFWORD(&quotient, 0)=sign;                 // construct decFloat of sign\r\n  return decFloatCopySign(result, result, &quotient);\r\n  } // decDivide\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFiniteMultiply -- multiply two finite decFloats                 */\r\n/*                                                                    */\r\n/*   num    gets the result of multiplying dfl and dfr                */\r\n/*   bcdacc .. with the coefficient in this array                     */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*                                                                    */\r\n/* This effects the multiplication of two decFloats, both known to be */\r\n/* finite, leaving the result in a bcdnum ready for decFinalize (for  */\r\n/* use in Multiply) or in a following addition (FMA).                 */\r\n/*                                                                    */\r\n/* bcdacc must have space for at least DECPMAX9*18+1 bytes.           */\r\n/* No error is possible and no status is set.                         */\r\n/* ------------------------------------------------------------------ */\r\n// This routine has two separate implementations of the core\r\n// multiplication; both using base-billion.  One uses only 32-bit\r\n// variables (Ints and uInts) or smaller; the other uses uLongs (for\r\n// multiplication and addition only).  Both implementations cover\r\n// both arithmetic sizes (DOUBLE and QUAD) in order to allow timing\r\n// comparisons.  In any one compilation only one implementation for\r\n// each size can be used, and if DECUSE64 is 0 then use of the 32-bit\r\n// version is forced.\r\n//\r\n// Historical note: an earlier version of this code also supported the\r\n// 256-bit format and has been preserved.  That is somewhat trickier\r\n// during lazy carry splitting because the initial quotient estimate\r\n// (est) can exceed 32 bits.\r\n\r\n#define MULTBASE  ((uInt)BILLION)  // the base used for multiply\r\n#define MULOPLEN  DECPMAX9         // operand length ('digits' base 10**9)\r\n#define MULACCLEN (MULOPLEN*2)              // accumulator length (ditto)\r\n#define LEADZEROS (MULACCLEN*9 - DECPMAX*2) // leading zeros always\r\n\r\n// Assertions: exponent not too large and MULACCLEN is a multiple of 4\r\n#if DECEMAXD>9\r\n  #error Exponent may overflow when doubled for Multiply\r\n#endif\r\n#if MULACCLEN!=(MULACCLEN/4)*4\r\n  // This assumption is used below only for initialization\r\n  #error MULACCLEN is not a multiple of 4\r\n#endif\r\n\r\nstatic void decFiniteMultiply(bcdnum *num, uByte *bcdacc,\r\n                              const decFloat *dfl, const decFloat *dfr) {\r\n  uInt   bufl[MULOPLEN];           // left  coefficient (base-billion)\r\n  uInt   bufr[MULOPLEN];           // right coefficient (base-billion)\r\n  uInt   *ui, *uj;                 // work\r\n  uByte  *ub;                      // ..\r\n  uInt   uiwork;                   // for macros\r\n\r\n  #if DECUSE64\r\n  uLong  accl[MULACCLEN];          // lazy accumulator (base-billion+)\r\n  uLong  *pl;                      // work -> lazy accumulator\r\n  uInt   acc[MULACCLEN];           // coefficent in base-billion ..\r\n  #else\r\n  uInt   acc[MULACCLEN*2];         // accumulator in base-billion ..\r\n  #endif\r\n  uInt   *pa;                      // work -> accumulator\r\n  //printf(\"Base10**9: OpLen=%d MulAcclen=%d\\n\", OPLEN, MULACCLEN);\r\n\r\n  /* Calculate sign and exponent */\r\n  num->sign=(DFWORD(dfl, 0)^DFWORD(dfr, 0)) & DECFLOAT_Sign;\r\n  num->exponent=GETEXPUN(dfl)+GETEXPUN(dfr); // [see assertion above]\r\n\r\n  /* Extract the coefficients and prepare the accumulator */\r\n  // the coefficients of the operands are decoded into base-billion\r\n  // numbers in uInt arrays (bufl and bufr, LSD at offset 0) of the\r\n  // appropriate size.\r\n  GETCOEFFBILL(dfl, bufl);\r\n  GETCOEFFBILL(dfr, bufr);\r\n  #if DECTRACE && 0\r\n    printf(\"CoeffbL:\");\r\n    for (ui=bufl+MULOPLEN-1; ui>=bufl; ui--) printf(\" %08lx\", (LI)*ui);\r\n    printf(\"\\n\");\r\n    printf(\"CoeffbR:\");\r\n    for (uj=bufr+MULOPLEN-1; uj>=bufr; uj--) printf(\" %08lx\", (LI)*uj);\r\n    printf(\"\\n\");\r\n  #endif\r\n\r\n  // start the 64-bit/32-bit differing paths...\r\n#if DECUSE64\r\n\r\n  // zero the accumulator\r\n  #if MULACCLEN==4\r\n    accl[0]=0; accl[1]=0; accl[2]=0; accl[3]=0;\r\n  #else                                      // use a loop\r\n    // MULACCLEN is a multiple of four, asserted above\r\n    for (pl=accl; pl<accl+MULACCLEN; pl+=4) {\r\n      *pl=0; *(pl+1)=0; *(pl+2)=0; *(pl+3)=0;// [reduce overhead]\r\n      } // pl\r\n  #endif\r\n\r\n  /* Effect the multiplication */\r\n  // The multiplication proceeds using MFC's lazy-carry resolution\r\n  // algorithm from decNumber.  First, the multiplication is\r\n  // effected, allowing accumulation of the partial products (which\r\n  // are in base-billion at each column position) into 64 bits\r\n  // without resolving back to base=billion after each addition.\r\n  // These 64-bit numbers (which may contain up to 19 decimal digits)\r\n  // are then split using the Clark & Cowlishaw algorithm (see below).\r\n  // [Testing for 0 in the inner loop is not really a 'win']\r\n  for (ui=bufr; ui<bufr+MULOPLEN; ui++) { // over each item in rhs\r\n    if (*ui==0) continue;                 // product cannot affect result\r\n    pl=accl+(ui-bufr);                    // where to add the lhs\r\n    for (uj=bufl; uj<bufl+MULOPLEN; uj++, pl++) { // over each item in lhs\r\n      // if (*uj==0) continue;            // product cannot affect result\r\n      *pl+=((uLong)*ui)*(*uj);\r\n      } // uj\r\n    } // ui\r\n\r\n  // The 64-bit carries must now be resolved; this means that a\r\n  // quotient/remainder has to be calculated for base-billion (1E+9).\r\n  // For this, Clark & Cowlishaw's quotient estimation approach (also\r\n  // used in decNumber) is needed, because 64-bit divide is generally\r\n  // extremely slow on 32-bit machines, and may be slower than this\r\n  // approach even on 64-bit machines.  This algorithm splits X\r\n  // using:\r\n  //\r\n  //   magic=2**(A+B)/1E+9;   // 'magic number'\r\n  //   hop=X/2**A;            // high order part of X (by shift)\r\n  //   est=magic*hop/2**B     // quotient estimate (may be low by 1)\r\n  //\r\n  // A and B are quite constrained; hop and magic must fit in 32 bits,\r\n  // and 2**(A+B) must be as large as possible (which is 2**61 if\r\n  // magic is to fit).  Further, maxX increases with the length of\r\n  // the operands (and hence the number of partial products\r\n  // accumulated); maxX is OPLEN*(10**18), which is up to 19 digits.\r\n  //\r\n  // It can be shown that when OPLEN is 2 then the maximum error in\r\n  // the estimated quotient is <1, but for larger maximum x the\r\n  // maximum error is above 1 so a correction that is >1 may be\r\n  // needed.  Values of A and B are chosen to satisfy the constraints\r\n  // just mentioned while minimizing the maximum error (and hence the\r\n  // maximum correction), as shown in the following table:\r\n  //\r\n  //   Type    OPLEN   A   B     maxX    maxError  maxCorrection\r\n  //   ---------------------------------------------------------\r\n  //   DOUBLE    2    29  32  <2*10**18    0.63       1\r\n  //   QUAD      4    30  31  <4*10**18    1.17       2\r\n  //\r\n  // In the OPLEN==2 case there is most choice, but the value for B\r\n  // of 32 has a big advantage as then the calculation of the\r\n  // estimate requires no shifting; the compiler can extract the high\r\n  // word directly after multiplying magic*hop.\r\n  #define MULMAGIC 2305843009U          // 2**61/10**9  [both cases]\r\n  #if DOUBLE\r\n    #define MULSHIFTA 29\r\n    #define MULSHIFTB 32\r\n  #elif QUAD\r\n    #define MULSHIFTA 30\r\n    #define MULSHIFTB 31\r\n  #else\r\n    #error Unexpected type\r\n  #endif\r\n\r\n  #if DECTRACE\r\n  printf(\"MulAccl:\");\r\n  for (pl=accl+MULACCLEN-1; pl>=accl; pl--)\r\n    printf(\" %08lx:%08lx\", (LI)(*pl>>32), (LI)(*pl&0xffffffff));\r\n  printf(\"\\n\");\r\n  #endif\r\n\r\n  for (pl=accl, pa=acc; pl<accl+MULACCLEN; pl++, pa++) { // each column position\r\n    uInt lo, hop;                       // work\r\n    uInt est;                           // cannot exceed 4E+9\r\n    if (*pl>=MULTBASE) {\r\n      // *pl holds a binary number which needs to be split\r\n      hop=(uInt)(*pl>>MULSHIFTA);\r\n      est=(uInt)(((uLong)hop*MULMAGIC)>>MULSHIFTB);\r\n      // the estimate is now in est; now calculate hi:lo-est*10**9;\r\n      // happily the top word of the result is irrelevant because it\r\n      // will always be zero so this needs only one multiplication\r\n      lo=(uInt)(*pl-((uLong)est*MULTBASE));  // low word of result\r\n      // If QUAD, the correction here could be +2\r\n      if (lo>=MULTBASE) {\r\n        lo-=MULTBASE;                   // correct by +1\r\n        est++;\r\n        #if QUAD\r\n        // may need to correct by +2\r\n        if (lo>=MULTBASE) {\r\n          lo-=MULTBASE;\r\n          est++;\r\n          }\r\n        #endif\r\n        }\r\n      // finally place lo as the new coefficient 'digit' and add est to\r\n      // the next place up [this is safe because this path is never\r\n      // taken on the final iteration as *pl will fit]\r\n      *pa=lo;\r\n      *(pl+1)+=est;\r\n      } // *pl needed split\r\n     else {                             // *pl<MULTBASE\r\n      *pa=(uInt)*pl;                    // just copy across\r\n      }\r\n    } // pl loop\r\n\r\n#else  // 32-bit\r\n  for (pa=acc;; pa+=4) {                     // zero the accumulator\r\n    *pa=0; *(pa+1)=0; *(pa+2)=0; *(pa+3)=0;  // [reduce overhead]\r\n    if (pa==acc+MULACCLEN*2-4) break;        // multiple of 4 asserted\r\n    } // pa\r\n\r\n  /* Effect the multiplication */\r\n  // uLongs are not available (and in particular, there is no uLong\r\n  // divide) but it is still possible to use MFC's lazy-carry\r\n  // resolution algorithm from decNumber.  First, the multiplication\r\n  // is effected, allowing accumulation of the partial products\r\n  // (which are in base-billion at each column position) into 64 bits\r\n  // [with the high-order 32 bits in each position being held at\r\n  // offset +ACCLEN from the low-order 32 bits in the accumulator].\r\n  // These 64-bit numbers (which may contain up to 19 decimal digits)\r\n  // are then split using the Clark & Cowlishaw algorithm (see\r\n  // below).\r\n  for (ui=bufr;; ui++) {                // over each item in rhs\r\n    uInt hi, lo;                        // words of exact multiply result\r\n    pa=acc+(ui-bufr);                   // where to add the lhs\r\n    for (uj=bufl;; uj++, pa++) {        // over each item in lhs\r\n      LONGMUL32HI(hi, *ui, *uj);        // calculate product of digits\r\n      lo=(*ui)*(*uj);                   // ..\r\n      *pa+=lo;                          // accumulate low bits and ..\r\n      *(pa+MULACCLEN)+=hi+(*pa<lo);     // .. high bits with any carry\r\n      if (uj==bufl+MULOPLEN-1) break;\r\n      }\r\n    if (ui==bufr+MULOPLEN-1) break;\r\n    }\r\n\r\n  // The 64-bit carries must now be resolved; this means that a\r\n  // quotient/remainder has to be calculated for base-billion (1E+9).\r\n  // For this, Clark & Cowlishaw's quotient estimation approach (also\r\n  // used in decNumber) is needed, because 64-bit divide is generally\r\n  // extremely slow on 32-bit machines.  This algorithm splits X\r\n  // using:\r\n  //\r\n  //   magic=2**(A+B)/1E+9;   // 'magic number'\r\n  //   hop=X/2**A;            // high order part of X (by shift)\r\n  //   est=magic*hop/2**B     // quotient estimate (may be low by 1)\r\n  //\r\n  // A and B are quite constrained; hop and magic must fit in 32 bits,\r\n  // and 2**(A+B) must be as large as possible (which is 2**61 if\r\n  // magic is to fit).  Further, maxX increases with the length of\r\n  // the operands (and hence the number of partial products\r\n  // accumulated); maxX is OPLEN*(10**18), which is up to 19 digits.\r\n  //\r\n  // It can be shown that when OPLEN is 2 then the maximum error in\r\n  // the estimated quotient is <1, but for larger maximum x the\r\n  // maximum error is above 1 so a correction that is >1 may be\r\n  // needed.  Values of A and B are chosen to satisfy the constraints\r\n  // just mentioned while minimizing the maximum error (and hence the\r\n  // maximum correction), as shown in the following table:\r\n  //\r\n  //   Type    OPLEN   A   B     maxX    maxError  maxCorrection\r\n  //   ---------------------------------------------------------\r\n  //   DOUBLE    2    29  32  <2*10**18    0.63       1\r\n  //   QUAD      4    30  31  <4*10**18    1.17       2\r\n  //\r\n  // In the OPLEN==2 case there is most choice, but the value for B\r\n  // of 32 has a big advantage as then the calculation of the\r\n  // estimate requires no shifting; the high word is simply\r\n  // calculated from multiplying magic*hop.\r\n  #define MULMAGIC 2305843009U          // 2**61/10**9  [both cases]\r\n  #if DOUBLE\r\n    #define MULSHIFTA 29\r\n    #define MULSHIFTB 32\r\n  #elif QUAD\r\n    #define MULSHIFTA 30\r\n    #define MULSHIFTB 31\r\n  #else\r\n    #error Unexpected type\r\n  #endif\r\n\r\n  #if DECTRACE\r\n  printf(\"MulHiLo:\");\r\n  for (pa=acc+MULACCLEN-1; pa>=acc; pa--)\r\n    printf(\" %08lx:%08lx\", (LI)*(pa+MULACCLEN), (LI)*pa);\r\n  printf(\"\\n\");\r\n  #endif\r\n\r\n  for (pa=acc;; pa++) {                 // each low uInt\r\n    uInt hi, lo;                        // words of exact multiply result\r\n    uInt hop, estlo;                    // work\r\n    #if QUAD\r\n    uInt esthi;                         // ..\r\n    #endif\r\n\r\n    lo=*pa;\r\n    hi=*(pa+MULACCLEN);                 // top 32 bits\r\n    // hi and lo now hold a binary number which needs to be split\r\n\r\n    #if DOUBLE\r\n      hop=(hi<<3)+(lo>>MULSHIFTA);      // hi:lo/2**29\r\n      LONGMUL32HI(estlo, hop, MULMAGIC);// only need the high word\r\n      // [MULSHIFTB is 32, so estlo can be used directly]\r\n      // the estimate is now in estlo; now calculate hi:lo-est*10**9;\r\n      // happily the top word of the result is irrelevant because it\r\n      // will always be zero so this needs only one multiplication\r\n      lo-=(estlo*MULTBASE);\r\n      // esthi=0;                       // high word is ignored below\r\n      // the correction here will be at most +1; do it\r\n      if (lo>=MULTBASE) {\r\n        lo-=MULTBASE;\r\n        estlo++;\r\n        }\r\n    #elif QUAD\r\n      hop=(hi<<2)+(lo>>MULSHIFTA);      // hi:lo/2**30\r\n      LONGMUL32HI(esthi, hop, MULMAGIC);// shift will be 31 ..\r\n      estlo=hop*MULMAGIC;               // .. so low word needed\r\n      estlo=(esthi<<1)+(estlo>>MULSHIFTB); // [just the top bit]\r\n      // esthi=0;                       // high word is ignored below\r\n      lo-=(estlo*MULTBASE);             // as above\r\n      // the correction here could be +1 or +2\r\n      if (lo>=MULTBASE) {\r\n        lo-=MULTBASE;\r\n        estlo++;\r\n        }\r\n      if (lo>=MULTBASE) {\r\n        lo-=MULTBASE;\r\n        estlo++;\r\n        }\r\n    #else\r\n      #error Unexpected type\r\n    #endif\r\n\r\n    // finally place lo as the new accumulator digit and add est to\r\n    // the next place up; this latter add could cause a carry of 1\r\n    // to the high word of the next place\r\n    *pa=lo;\r\n    *(pa+1)+=estlo;\r\n    // esthi is always 0 for DOUBLE and QUAD so this is skipped\r\n    // *(pa+1+MULACCLEN)+=esthi;\r\n    if (*(pa+1)<estlo) *(pa+1+MULACCLEN)+=1; // carry\r\n    if (pa==acc+MULACCLEN-2) break;          // [MULACCLEN-1 will never need split]\r\n    } // pa loop\r\n#endif\r\n\r\n  // At this point, whether using the 64-bit or the 32-bit paths, the\r\n  // accumulator now holds the (unrounded) result in base-billion;\r\n  // one base-billion 'digit' per uInt.\r\n  #if DECTRACE\r\n  printf(\"MultAcc:\");\r\n  for (pa=acc+MULACCLEN-1; pa>=acc; pa--) printf(\" %09ld\", (LI)*pa);\r\n  printf(\"\\n\");\r\n  #endif\r\n\r\n  // Now convert to BCD for rounding and cleanup, starting from the\r\n  // most significant end\r\n  pa=acc+MULACCLEN-1;\r\n  if (*pa!=0) num->msd=bcdacc+LEADZEROS;// drop known lead zeros\r\n   else {                               // >=1 word of leading zeros\r\n    num->msd=bcdacc;                    // known leading zeros are gone\r\n    pa--;                               // skip first word ..\r\n    for (; *pa==0; pa--) if (pa==acc) break; // .. and any more leading 0s\r\n    }\r\n  for (ub=bcdacc;; pa--, ub+=9) {\r\n    if (*pa!=0) {                       // split(s) needed\r\n      uInt top, mid, rem;               // work\r\n      // *pa is non-zero -- split the base-billion acc digit into\r\n      // hi, mid, and low three-digits\r\n      #define mulsplit9 1000000         // divisor\r\n      #define mulsplit6 1000            // divisor\r\n      // The splitting is done by simple divides and remainders,\r\n      // assuming the compiler will optimize these where useful\r\n      // [GCC does]\r\n      top=*pa/mulsplit9;\r\n      rem=*pa%mulsplit9;\r\n      mid=rem/mulsplit6;\r\n      rem=rem%mulsplit6;\r\n      // lay out the nine BCD digits (plus one unwanted byte)\r\n      UBFROMUI(ub,   UBTOUI(&BIN2BCD8[top*4]));\r\n      UBFROMUI(ub+3, UBTOUI(&BIN2BCD8[mid*4]));\r\n      UBFROMUI(ub+6, UBTOUI(&BIN2BCD8[rem*4]));\r\n      }\r\n     else {                             // *pa==0\r\n      UBFROMUI(ub, 0);                  // clear 9 BCD8s\r\n      UBFROMUI(ub+4, 0);                // ..\r\n      *(ub+8)=0;                        // ..\r\n      }\r\n    if (pa==acc) break;\r\n    } // BCD conversion loop\r\n\r\n  num->lsd=ub+8;                        // complete the bcdnum ..\r\n\r\n  #if DECTRACE\r\n  decShowNum(num, \"postmult\");\r\n  decFloatShow(dfl, \"dfl\");\r\n  decFloatShow(dfr, \"dfr\");\r\n  #endif\r\n  return;\r\n  } // decFiniteMultiply\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatAbs -- absolute value, heeding NaNs, etc.                  */\r\n/*                                                                    */\r\n/*   result gets the canonicalized df with sign 0                     */\r\n/*   df     is the decFloat to abs                                    */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This has the same effect as decFloatPlus unless df is negative,    */\r\n/* in which case it has the same effect as decFloatMinus.  The        */\r\n/* effect is also the same as decFloatCopyAbs except that NaNs are    */\r\n/* handled normally (the sign of a NaN is not affected, and an sNaN   */\r\n/* will signal) and the result will be canonical.                     */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatAbs(decFloat *result, const decFloat *df,\r\n                       decContext *set) {\r\n  if (DFISNAN(df)) return decNaNs(result, df, NULL, set);\r\n  decCanonical(result, df);             // copy and check\r\n  DFBYTE(result, 0)&=~0x80;             // zero sign bit\r\n  return result;\r\n  } // decFloatAbs\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatAdd -- add two decFloats                                   */\r\n/*                                                                    */\r\n/*   result gets the result of adding dfl and dfr:                    */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\n#if QUAD\r\n// Table for testing MSDs for fastpath elimination; returns the MSD of\r\n// a decDouble or decQuad (top 6 bits tested) ignoring the sign.\r\n// Infinities return -32 and NaNs return -128 so that summing the two\r\n// MSDs also allows rapid tests for the Specials (see code below).\r\nconst Int DECTESTMSD[64]={\r\n  0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5,   6,    7,\r\n  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 9, 8, 9, -32, -128,\r\n  0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5,   6,    7,\r\n  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 9, 8, 9, -32, -128};\r\n#else\r\n// The table for testing MSDs is shared between the modules\r\nextern const Int DECTESTMSD[64];\r\n#endif\r\n\r\ndecFloat * decFloatAdd(decFloat *result,\r\n                       const decFloat *dfl, const decFloat *dfr,\r\n                       decContext *set) {\r\n  bcdnum num;                      // for final conversion\r\n  Int    bexpl, bexpr;             // left and right biased exponents\r\n  uByte  *ub, *us, *ut;            // work\r\n  uInt   uiwork;                   // for macros\r\n  #if QUAD\r\n  uShort uswork;                   // ..\r\n  #endif\r\n\r\n  uInt sourhil, sourhir;           // top words from source decFloats\r\n                                   // [valid only through end of\r\n                                   // fastpath code -- before swap]\r\n  uInt diffsign;                   // non-zero if signs differ\r\n  uInt carry;                      // carry: 0 or 1 before add loop\r\n  Int  overlap;                    // coefficient overlap (if full)\r\n  Int  summ;                       // sum of the MSDs\r\n  // the following buffers hold coefficients with various alignments\r\n  // (see commentary and diagrams below)\r\n  uByte acc[4+2+DECPMAX*3+8];\r\n  uByte buf[4+2+DECPMAX*2];\r\n  uByte *umsd, *ulsd;              // local MSD and LSD pointers\r\n\r\n  #if DECLITEND\r\n    #define CARRYPAT 0x01000000    // carry=1 pattern\r\n  #else\r\n    #define CARRYPAT 0x00000001    // carry=1 pattern\r\n  #endif\r\n\r\n  /* Start decoding the arguments */\r\n  // The initial exponents are placed into the opposite Ints to\r\n  // that which might be expected; there are two sets of data to\r\n  // keep track of (each decFloat and the corresponding exponent),\r\n  // and this scheme means that at the swap point (after comparing\r\n  // exponents) only one pair of words needs to be swapped\r\n  // whichever path is taken (thereby minimising worst-case path).\r\n  // The calculated exponents will be nonsense when the arguments are\r\n  // Special, but are not used in that path\r\n  sourhil=DFWORD(dfl, 0);          // LHS top word\r\n  summ=DECTESTMSD[sourhil>>26];    // get first MSD for testing\r\n  bexpr=DECCOMBEXP[sourhil>>26];   // get exponent high bits (in place)\r\n  bexpr+=GETECON(dfl);             // .. + continuation\r\n\r\n  sourhir=DFWORD(dfr, 0);          // RHS top word\r\n  summ+=DECTESTMSD[sourhir>>26];   // sum MSDs for testing\r\n  bexpl=DECCOMBEXP[sourhir>>26];\r\n  bexpl+=GETECON(dfr);\r\n\r\n  // here bexpr has biased exponent from lhs, and vice versa\r\n\r\n  diffsign=(sourhil^sourhir)&DECFLOAT_Sign;\r\n\r\n  // now determine whether to take a fast path or the full-function\r\n  // slow path.  The slow path must be taken when:\r\n  //   -- both numbers are finite, and:\r\n  //         the exponents are different, or\r\n  //         the signs are different, or\r\n  //         the sum of the MSDs is >8 (hence might overflow)\r\n  // specialness and the sum of the MSDs can be tested at once using\r\n  // the summ value just calculated, so the test for specials is no\r\n  // longer on the worst-case path (as of 3.60)\r\n\r\n  if (summ<=8) {                   // MSD+MSD is good, or there is a special\r\n    if (summ<0) {                  // there is a special\r\n      // Inf+Inf would give -64; Inf+finite is -32 or higher\r\n      if (summ<-64) return decNaNs(result, dfl, dfr, set);  // one or two NaNs\r\n      // two infinities with different signs is invalid\r\n      if (summ==-64 && diffsign) return decInvalid(result, set);\r\n      if (DFISINF(dfl)) return decInfinity(result, dfl);    // LHS is infinite\r\n      return decInfinity(result, dfr);                      // RHS must be Inf\r\n      }\r\n    // Here when both arguments are finite; fast path is possible\r\n    // (currently only for aligned and same-sign)\r\n    if (bexpr==bexpl && !diffsign) {\r\n      uInt tac[DECLETS+1];              // base-1000 coefficient\r\n      uInt encode;                      // work\r\n\r\n      // Get one coefficient as base-1000 and add the other\r\n      GETCOEFFTHOU(dfl, tac);           // least-significant goes to [0]\r\n      ADDCOEFFTHOU(dfr, tac);\r\n      // here the sum of the MSDs (plus any carry) will be <10 due to\r\n      // the fastpath test earlier\r\n\r\n      // construct the result; low word is the same for both formats\r\n      encode =BIN2DPD[tac[0]];\r\n      encode|=BIN2DPD[tac[1]]<<10;\r\n      encode|=BIN2DPD[tac[2]]<<20;\r\n      encode|=BIN2DPD[tac[3]]<<30;\r\n      DFWORD(result, (DECBYTES/4)-1)=encode;\r\n\r\n      // collect next two declets (all that remains, for Double)\r\n      encode =BIN2DPD[tac[3]]>>2;\r\n      encode|=BIN2DPD[tac[4]]<<8;\r\n\r\n      #if QUAD\r\n      // complete and lay out middling words\r\n      encode|=BIN2DPD[tac[5]]<<18;\r\n      encode|=BIN2DPD[tac[6]]<<28;\r\n      DFWORD(result, 2)=encode;\r\n\r\n      encode =BIN2DPD[tac[6]]>>4;\r\n      encode|=BIN2DPD[tac[7]]<<6;\r\n      encode|=BIN2DPD[tac[8]]<<16;\r\n      encode|=BIN2DPD[tac[9]]<<26;\r\n      DFWORD(result, 1)=encode;\r\n\r\n      // and final two declets\r\n      encode =BIN2DPD[tac[9]]>>6;\r\n      encode|=BIN2DPD[tac[10]]<<4;\r\n      #endif\r\n\r\n      // add exponent continuation and sign (from either argument)\r\n      encode|=sourhil & (ECONMASK | DECFLOAT_Sign);\r\n\r\n      // create lookup index = MSD + top two bits of biased exponent <<4\r\n      tac[DECLETS]|=(bexpl>>DECECONL)<<4;\r\n      encode|=DECCOMBFROM[tac[DECLETS]]; // add constructed combination field\r\n      DFWORD(result, 0)=encode;          // complete\r\n\r\n      // decFloatShow(result, \">\");\r\n      return result;\r\n      } // fast path OK\r\n    // drop through to slow path\r\n    } // low sum or Special(s)\r\n\r\n  /* Slow path required -- arguments are finite and might overflow,   */\r\n  /* or require alignment, or might have different signs              */\r\n\r\n  // now swap either exponents or argument pointers\r\n  if (bexpl<=bexpr) {\r\n    // original left is bigger\r\n    Int bexpswap=bexpl;\r\n    bexpl=bexpr;\r\n    bexpr=bexpswap;\r\n    // printf(\"left bigger\\n\");\r\n    }\r\n   else {\r\n    const decFloat *dfswap=dfl;\r\n    dfl=dfr;\r\n    dfr=dfswap;\r\n    // printf(\"right bigger\\n\");\r\n    }\r\n  // [here dfl and bexpl refer to the datum with the larger exponent,\r\n  // of if the exponents are equal then the original LHS argument]\r\n\r\n  // if lhs is zero then result will be the rhs (now known to have\r\n  // the smaller exponent), which also may need to be tested for zero\r\n  // for the weird IEEE 754 sign rules\r\n  if (DFISZERO(dfl)) {\r\n    decCanonical(result, dfr);               // clean copy\r\n    // \"When the sum of two operands with opposite signs is\r\n    // exactly zero, the sign of that sum shall be '+' in all\r\n    // rounding modes except round toward -Infinity, in which\r\n    // mode that sign shall be '-'.\"\r\n    if (diffsign && DFISZERO(result)) {\r\n      DFWORD(result, 0)&=~DECFLOAT_Sign;     // assume sign 0\r\n      if (set->round==DEC_ROUND_FLOOR) DFWORD(result, 0)|=DECFLOAT_Sign;\r\n      }\r\n    return result;\r\n    } // numfl is zero\r\n  // [here, LHS is non-zero; code below assumes that]\r\n\r\n  // Coefficients layout during the calculations to follow:\r\n  //\r\n  //       Overlap case:\r\n  //       +------------------------------------------------+\r\n  // acc:  |0000|      coeffa      | tail B |               |\r\n  //       +------------------------------------------------+\r\n  // buf:  |0000| pad0s |      coeffb       |               |\r\n  //       +------------------------------------------------+\r\n  //\r\n  //       Touching coefficients or gap:\r\n  //       +------------------------------------------------+\r\n  // acc:  |0000|      coeffa      | gap |      coeffb      |\r\n  //       +------------------------------------------------+\r\n  //       [buf not used or needed; gap clamped to Pmax]\r\n\r\n  // lay out lhs coefficient into accumulator; this starts at acc+4\r\n  // for decDouble or acc+6 for decQuad so the LSD is word-\r\n  // aligned; the top word gap is there only in case a carry digit\r\n  // is prefixed after the add -- it does not need to be zeroed\r\n  #if DOUBLE\r\n    #define COFF 4                      // offset into acc\r\n  #elif QUAD\r\n    UBFROMUS(acc+4, 0);                 // prefix 00\r\n    #define COFF 6                      // offset into acc\r\n  #endif\r\n\r\n  GETCOEFF(dfl, acc+COFF);              // decode from decFloat\r\n  ulsd=acc+COFF+DECPMAX-1;\r\n  umsd=acc+4;                           // [having this here avoids\r\n\r\n  #if DECTRACE\r\n  {bcdnum tum;\r\n  tum.msd=umsd;\r\n  tum.lsd=ulsd;\r\n  tum.exponent=bexpl-DECBIAS;\r\n  tum.sign=DFWORD(dfl, 0) & DECFLOAT_Sign;\r\n  decShowNum(&tum, \"dflx\");}\r\n  #endif\r\n\r\n  // if signs differ, take ten's complement of lhs (here the\r\n  // coefficient is subtracted from all-nines; the 1 is added during\r\n  // the later add cycle -- zeros to the right do not matter because\r\n  // the complement of zero is zero); these are fixed-length inverts\r\n  // where the lsd is known to be at a 4-byte boundary (so no borrow\r\n  // possible)\r\n  carry=0;                              // assume no carry\r\n  if (diffsign) {\r\n    carry=CARRYPAT;                     // for +1 during add\r\n    UBFROMUI(acc+ 4, 0x09090909-UBTOUI(acc+ 4));\r\n    UBFROMUI(acc+ 8, 0x09090909-UBTOUI(acc+ 8));\r\n    UBFROMUI(acc+12, 0x09090909-UBTOUI(acc+12));\r\n    UBFROMUI(acc+16, 0x09090909-UBTOUI(acc+16));\r\n    #if QUAD\r\n    UBFROMUI(acc+20, 0x09090909-UBTOUI(acc+20));\r\n    UBFROMUI(acc+24, 0x09090909-UBTOUI(acc+24));\r\n    UBFROMUI(acc+28, 0x09090909-UBTOUI(acc+28));\r\n    UBFROMUI(acc+32, 0x09090909-UBTOUI(acc+32));\r\n    UBFROMUI(acc+36, 0x09090909-UBTOUI(acc+36));\r\n    #endif\r\n    } // diffsign\r\n\r\n  // now process the rhs coefficient; if it cannot overlap lhs then\r\n  // it can be put straight into acc (with an appropriate gap, if\r\n  // needed) because no actual addition will be needed (except\r\n  // possibly to complete ten's complement)\r\n  overlap=DECPMAX-(bexpl-bexpr);\r\n  #if DECTRACE\r\n  printf(\"exps: %ld %ld\\n\", (LI)(bexpl-DECBIAS), (LI)(bexpr-DECBIAS));\r\n  printf(\"Overlap=%ld carry=%08lx\\n\", (LI)overlap, (LI)carry);\r\n  #endif\r\n\r\n  if (overlap<=0) {                     // no overlap possible\r\n    uInt gap;                           // local work\r\n    // since a full addition is not needed, a ten's complement\r\n    // calculation started above may need to be completed\r\n    if (carry) {\r\n      for (ub=ulsd; *ub==9; ub--) *ub=0;\r\n      *ub+=1;\r\n      carry=0;                          // taken care of\r\n      }\r\n    // up to DECPMAX-1 digits of the final result can extend down\r\n    // below the LSD of the lhs, so if the gap is >DECPMAX then the\r\n    // rhs will be simply sticky bits.  In this case the gap is\r\n    // clamped to DECPMAX and the exponent adjusted to suit [this is\r\n    // safe because the lhs is non-zero].\r\n    gap=-overlap;\r\n    if (gap>DECPMAX) {\r\n      bexpr+=gap-1;\r\n      gap=DECPMAX;\r\n      }\r\n    ub=ulsd+gap+1;                      // where MSD will go\r\n    // Fill the gap with 0s; note that there is no addition to do\r\n    ut=acc+COFF+DECPMAX;                // start of gap\r\n    for (; ut<ub; ut+=4) UBFROMUI(ut, 0); // mind the gap\r\n    if (overlap<-DECPMAX) {             // gap was > DECPMAX\r\n      *ub=(uByte)(!DFISZERO(dfr));      // make sticky digit\r\n      }\r\n     else {                             // need full coefficient\r\n      GETCOEFF(dfr, ub);                // decode from decFloat\r\n      ub+=DECPMAX-1;                    // new LSD...\r\n      }\r\n    ulsd=ub;                            // save new LSD\r\n    } // no overlap possible\r\n\r\n   else {                               // overlap>0\r\n    // coefficients overlap (perhaps completely, although also\r\n    // perhaps only where zeros)\r\n    if (overlap==DECPMAX) {             // aligned\r\n      ub=buf+COFF;                      // where msd will go\r\n      #if QUAD\r\n      UBFROMUS(buf+4, 0);               // clear quad's 00\r\n      #endif\r\n      GETCOEFF(dfr, ub);                // decode from decFloat\r\n      }\r\n     else {                             // unaligned\r\n      ub=buf+COFF+DECPMAX-overlap;      // where MSD will go\r\n      // Fill the prefix gap with 0s; 8 will cover most common\r\n      // unalignments, so start with direct assignments (a loop is\r\n      // then used for any remaining -- the loop (and the one in a\r\n      // moment) is not then on the critical path because the number\r\n      // of additions is reduced by (at least) two in this case)\r\n      UBFROMUI(buf+4, 0);               // [clears decQuad 00 too]\r\n      UBFROMUI(buf+8, 0);\r\n      if (ub>buf+12) {\r\n        ut=buf+12;                      // start any remaining\r\n        for (; ut<ub; ut+=4) UBFROMUI(ut, 0); // fill them\r\n        }\r\n      GETCOEFF(dfr, ub);                // decode from decFloat\r\n\r\n      // now move tail of rhs across to main acc; again use direct\r\n      // copies for 8 digits-worth\r\n      UBFROMUI(acc+COFF+DECPMAX,   UBTOUI(buf+COFF+DECPMAX));\r\n      UBFROMUI(acc+COFF+DECPMAX+4, UBTOUI(buf+COFF+DECPMAX+4));\r\n      if (buf+COFF+DECPMAX+8<ub+DECPMAX) {\r\n        us=buf+COFF+DECPMAX+8;          // source\r\n        ut=acc+COFF+DECPMAX+8;          // target\r\n        for (; us<ub+DECPMAX; us+=4, ut+=4) UBFROMUI(ut, UBTOUI(us));\r\n        }\r\n      } // unaligned\r\n\r\n    ulsd=acc+(ub-buf+DECPMAX-1);        // update LSD pointer\r\n\r\n    // Now do the add of the non-tail; this is all nicely aligned,\r\n    // and is over a multiple of four digits (because for Quad two\r\n    // zero digits were added on the left); words in both acc and\r\n    // buf (buf especially) will often be zero\r\n    // [byte-by-byte add, here, is about 15% slower total effect than\r\n    // the by-fours]\r\n\r\n    // Now effect the add; this is harder on a little-endian\r\n    // machine as the inter-digit carry cannot use the usual BCD\r\n    // addition trick because the bytes are loaded in the wrong order\r\n    // [this loop could be unrolled, but probably scarcely worth it]\r\n\r\n    ut=acc+COFF+DECPMAX-4;              // target LSW (acc)\r\n    us=buf+COFF+DECPMAX-4;              // source LSW (buf, to add to acc)\r\n\r\n    #if !DECLITEND\r\n    for (; ut>=acc+4; ut-=4, us-=4) {   // big-endian add loop\r\n      // bcd8 add\r\n      carry+=UBTOUI(us);                // rhs + carry\r\n      if (carry==0) continue;           // no-op\r\n      carry+=UBTOUI(ut);                // lhs\r\n      // Big-endian BCD adjust (uses internal carry)\r\n      carry+=0x76f6f6f6;                // note top nibble not all bits\r\n      // apply BCD adjust and save\r\n      UBFROMUI(ut, (carry & 0x0f0f0f0f) - ((carry & 0x60606060)>>4));\r\n      carry>>=31;                       // true carry was at far left\r\n      } // add loop\r\n    #else\r\n    for (; ut>=acc+4; ut-=4, us-=4) {   // little-endian add loop\r\n      // bcd8 add\r\n      carry+=UBTOUI(us);                // rhs + carry\r\n      if (carry==0) continue;           // no-op [common if unaligned]\r\n      carry+=UBTOUI(ut);                // lhs\r\n      // Little-endian BCD adjust; inter-digit carry must be manual\r\n      // because the lsb from the array will be in the most-significant\r\n      // byte of carry\r\n      carry+=0x76767676;                // note no inter-byte carries\r\n      carry+=(carry & 0x80000000)>>15;\r\n      carry+=(carry & 0x00800000)>>15;\r\n      carry+=(carry & 0x00008000)>>15;\r\n      carry-=(carry & 0x60606060)>>4;   // BCD adjust back\r\n      UBFROMUI(ut, carry & 0x0f0f0f0f); // clear debris and save\r\n      // here, final carry-out bit is at 0x00000080; move it ready\r\n      // for next word-add (i.e., to 0x01000000)\r\n      carry=(carry & 0x00000080)<<17;\r\n      } // add loop\r\n    #endif\r\n\r\n    #if DECTRACE\r\n    {bcdnum tum;\r\n    printf(\"Add done, carry=%08lx, diffsign=%ld\\n\", (LI)carry, (LI)diffsign);\r\n    tum.msd=umsd;  // acc+4;\r\n    tum.lsd=ulsd;\r\n    tum.exponent=0;\r\n    tum.sign=0;\r\n    decShowNum(&tum, \"dfadd\");}\r\n    #endif\r\n    } // overlap possible\r\n\r\n  // ordering here is a little strange in order to have slowest path\r\n  // first in GCC asm listing\r\n  if (diffsign) {                  // subtraction\r\n    if (!carry) {                  // no carry out means RHS<LHS\r\n      // borrowed -- take ten's complement\r\n      // sign is lhs sign\r\n      num.sign=DFWORD(dfl, 0) & DECFLOAT_Sign;\r\n\r\n      // invert the coefficient first by fours, then add one; space\r\n      // at the end of the buffer ensures the by-fours is always\r\n      // safe, but lsd+1 must be cleared to prevent a borrow\r\n      // if big-endian\r\n      #if !DECLITEND\r\n      *(ulsd+1)=0;\r\n      #endif\r\n      // there are always at least four coefficient words\r\n      UBFROMUI(umsd,    0x09090909-UBTOUI(umsd));\r\n      UBFROMUI(umsd+4,  0x09090909-UBTOUI(umsd+4));\r\n      UBFROMUI(umsd+8,  0x09090909-UBTOUI(umsd+8));\r\n      UBFROMUI(umsd+12, 0x09090909-UBTOUI(umsd+12));\r\n      #if DOUBLE\r\n        #define BNEXT 16\r\n      #elif QUAD\r\n        UBFROMUI(umsd+16, 0x09090909-UBTOUI(umsd+16));\r\n        UBFROMUI(umsd+20, 0x09090909-UBTOUI(umsd+20));\r\n        UBFROMUI(umsd+24, 0x09090909-UBTOUI(umsd+24));\r\n        UBFROMUI(umsd+28, 0x09090909-UBTOUI(umsd+28));\r\n        UBFROMUI(umsd+32, 0x09090909-UBTOUI(umsd+32));\r\n        #define BNEXT 36\r\n      #endif\r\n      if (ulsd>=umsd+BNEXT) {           // unaligned\r\n        // eight will handle most unaligments for Double; 16 for Quad\r\n        UBFROMUI(umsd+BNEXT,   0x09090909-UBTOUI(umsd+BNEXT));\r\n        UBFROMUI(umsd+BNEXT+4, 0x09090909-UBTOUI(umsd+BNEXT+4));\r\n        #if DOUBLE\r\n        #define BNEXTY (BNEXT+8)\r\n        #elif QUAD\r\n        UBFROMUI(umsd+BNEXT+8,  0x09090909-UBTOUI(umsd+BNEXT+8));\r\n        UBFROMUI(umsd+BNEXT+12, 0x09090909-UBTOUI(umsd+BNEXT+12));\r\n        #define BNEXTY (BNEXT+16)\r\n        #endif\r\n        if (ulsd>=umsd+BNEXTY) {        // very unaligned\r\n          ut=umsd+BNEXTY;               // -> continue\r\n          for (;;ut+=4) {\r\n            UBFROMUI(ut, 0x09090909-UBTOUI(ut)); // invert four digits\r\n            if (ut>=ulsd-3) break;      // all done\r\n            }\r\n          }\r\n        }\r\n      // complete the ten's complement by adding 1\r\n      for (ub=ulsd; *ub==9; ub--) *ub=0;\r\n      *ub+=1;\r\n      } // borrowed\r\n\r\n     else {                        // carry out means RHS>=LHS\r\n      num.sign=DFWORD(dfr, 0) & DECFLOAT_Sign;\r\n      // all done except for the special IEEE 754 exact-zero-result\r\n      // rule (see above); while testing for zero, strip leading\r\n      // zeros (which will save decFinalize doing it) (this is in\r\n      // diffsign path, so carry impossible and true umsd is\r\n      // acc+COFF)\r\n\r\n      // Check the initial coefficient area using the fast macro;\r\n      // this will often be all that needs to be done (as on the\r\n      // worst-case path when the subtraction was aligned and\r\n      // full-length)\r\n      if (ISCOEFFZERO(acc+COFF)) {\r\n        umsd=acc+COFF+DECPMAX-1;   // so far, so zero\r\n        if (ulsd>umsd) {           // more to check\r\n          umsd++;                  // to align after checked area\r\n          for (; UBTOUI(umsd)==0 && umsd+3<ulsd;) umsd+=4;\r\n          for (; *umsd==0 && umsd<ulsd;) umsd++;\r\n          }\r\n        if (*umsd==0) {            // must be true zero (and diffsign)\r\n          num.sign=0;              // assume +\r\n          if (set->round==DEC_ROUND_FLOOR) num.sign=DECFLOAT_Sign;\r\n          }\r\n        }\r\n      // [else was not zero, might still have leading zeros]\r\n      } // subtraction gave positive result\r\n    } // diffsign\r\n\r\n   else { // same-sign addition\r\n    num.sign=DFWORD(dfl, 0)&DECFLOAT_Sign;\r\n    #if DOUBLE\r\n    if (carry) {                   // only possible with decDouble\r\n      *(acc+3)=1;                  // [Quad has leading 00]\r\n      umsd=acc+3;\r\n      }\r\n    #endif\r\n    } // same sign\r\n\r\n  num.msd=umsd;                    // set MSD ..\r\n  num.lsd=ulsd;                    // .. and LSD\r\n  num.exponent=bexpr-DECBIAS;      // set exponent to smaller, unbiassed\r\n\r\n  #if DECTRACE\r\n  decFloatShow(dfl, \"dfl\");\r\n  decFloatShow(dfr, \"dfr\");\r\n  decShowNum(&num, \"postadd\");\r\n  #endif\r\n  return decFinalize(result, &num, set); // round, check, and lay out\r\n  } // decFloatAdd\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatAnd -- logical digitwise AND of two decFloats              */\r\n/*                                                                    */\r\n/*   result gets the result of ANDing dfl and dfr                     */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result, which will be canonical with sign=0              */\r\n/*                                                                    */\r\n/* The operands must be positive, finite with exponent q=0, and       */\r\n/* comprise just zeros and ones; if not, Invalid operation results.   */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatAnd(decFloat *result,\r\n                       const decFloat *dfl, const decFloat *dfr,\r\n                       decContext *set) {\r\n  if (!DFISUINT01(dfl) || !DFISUINT01(dfr)\r\n   || !DFISCC01(dfl)   || !DFISCC01(dfr)) return decInvalid(result, set);\r\n  // the operands are positive finite integers (q=0) with just 0s and 1s\r\n  #if DOUBLE\r\n   DFWORD(result, 0)=ZEROWORD\r\n                   |((DFWORD(dfl, 0) & DFWORD(dfr, 0))&0x04009124);\r\n   DFWORD(result, 1)=(DFWORD(dfl, 1) & DFWORD(dfr, 1))&0x49124491;\r\n  #elif QUAD\r\n   DFWORD(result, 0)=ZEROWORD\r\n                   |((DFWORD(dfl, 0) & DFWORD(dfr, 0))&0x04000912);\r\n   DFWORD(result, 1)=(DFWORD(dfl, 1) & DFWORD(dfr, 1))&0x44912449;\r\n   DFWORD(result, 2)=(DFWORD(dfl, 2) & DFWORD(dfr, 2))&0x12449124;\r\n   DFWORD(result, 3)=(DFWORD(dfl, 3) & DFWORD(dfr, 3))&0x49124491;\r\n  #endif\r\n  return result;\r\n  } // decFloatAnd\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatCanonical -- copy a decFloat, making canonical             */\r\n/*                                                                    */\r\n/*   result gets the canonicalized df                                 */\r\n/*   df     is the decFloat to copy and make canonical                */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This works on specials, too; no error or exception is possible.    */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatCanonical(decFloat *result, const decFloat *df) {\r\n  return decCanonical(result, df);\r\n  } // decFloatCanonical\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatClass -- return the class of a decFloat                    */\r\n/*                                                                    */\r\n/*   df is the decFloat to test                                       */\r\n/*   returns the decClass that df falls into                          */\r\n/* ------------------------------------------------------------------ */\r\nenum decClass decFloatClass(const decFloat *df) {\r\n  Int exp;                         // exponent\r\n  if (DFISSPECIAL(df)) {\r\n    if (DFISQNAN(df)) return DEC_CLASS_QNAN;\r\n    if (DFISSNAN(df)) return DEC_CLASS_SNAN;\r\n    // must be an infinity\r\n    if (DFISSIGNED(df)) return DEC_CLASS_NEG_INF;\r\n    return DEC_CLASS_POS_INF;\r\n    }\r\n  if (DFISZERO(df)) {              // quite common\r\n    if (DFISSIGNED(df)) return DEC_CLASS_NEG_ZERO;\r\n    return DEC_CLASS_POS_ZERO;\r\n    }\r\n  // is finite and non-zero; similar code to decFloatIsNormal, here\r\n  // [this could be speeded up slightly by in-lining decFloatDigits]\r\n  exp=GETEXPUN(df)                 // get unbiased exponent ..\r\n     +decFloatDigits(df)-1;        // .. and make adjusted exponent\r\n  if (exp>=DECEMIN) {              // is normal\r\n    if (DFISSIGNED(df)) return DEC_CLASS_NEG_NORMAL;\r\n    return DEC_CLASS_POS_NORMAL;\r\n    }\r\n  // is subnormal\r\n  if (DFISSIGNED(df)) return DEC_CLASS_NEG_SUBNORMAL;\r\n  return DEC_CLASS_POS_SUBNORMAL;\r\n  } // decFloatClass\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatClassString -- return the class of a decFloat as a string  */\r\n/*                                                                    */\r\n/*   df is the decFloat to test                                       */\r\n/*   returns a constant string describing the class df falls into     */\r\n/* ------------------------------------------------------------------ */\r\nconst char *decFloatClassString(const decFloat *df) {\r\n  enum decClass eclass=decFloatClass(df);\r\n  if (eclass==DEC_CLASS_POS_NORMAL)    return DEC_ClassString_PN;\r\n  if (eclass==DEC_CLASS_NEG_NORMAL)    return DEC_ClassString_NN;\r\n  if (eclass==DEC_CLASS_POS_ZERO)      return DEC_ClassString_PZ;\r\n  if (eclass==DEC_CLASS_NEG_ZERO)      return DEC_ClassString_NZ;\r\n  if (eclass==DEC_CLASS_POS_SUBNORMAL) return DEC_ClassString_PS;\r\n  if (eclass==DEC_CLASS_NEG_SUBNORMAL) return DEC_ClassString_NS;\r\n  if (eclass==DEC_CLASS_POS_INF)       return DEC_ClassString_PI;\r\n  if (eclass==DEC_CLASS_NEG_INF)       return DEC_ClassString_NI;\r\n  if (eclass==DEC_CLASS_QNAN)          return DEC_ClassString_QN;\r\n  if (eclass==DEC_CLASS_SNAN)          return DEC_ClassString_SN;\r\n  return DEC_ClassString_UN;           // Unknown\r\n  } // decFloatClassString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatCompare -- compare two decFloats; quiet NaNs allowed       */\r\n/*                                                                    */\r\n/*   result gets the result of comparing dfl and dfr                  */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result, which may be -1, 0, 1, or NaN (Unordered)        */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatCompare(decFloat *result,\r\n                           const decFloat *dfl, const decFloat *dfr,\r\n                           decContext *set) {\r\n  Int comp;                                  // work\r\n  // NaNs are handled as usual\r\n  if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n  // numeric comparison needed\r\n  comp=decNumCompare(dfl, dfr, 0);\r\n  decFloatZero(result);\r\n  if (comp==0) return result;\r\n  DFBYTE(result, DECBYTES-1)=0x01;      // LSD=1\r\n  if (comp<0) DFBYTE(result, 0)|=0x80;  // set sign bit\r\n  return result;\r\n  } // decFloatCompare\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatCompareSignal -- compare two decFloats; all NaNs signal    */\r\n/*                                                                    */\r\n/*   result gets the result of comparing dfl and dfr                  */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result, which may be -1, 0, 1, or NaN (Unordered)        */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatCompareSignal(decFloat *result,\r\n                                 const decFloat *dfl, const decFloat *dfr,\r\n                                 decContext *set) {\r\n  Int comp;                                  // work\r\n  // NaNs are handled as usual, except that all NaNs signal\r\n  if (DFISNAN(dfl) || DFISNAN(dfr)) {\r\n    set->status|=DEC_Invalid_operation;\r\n    return decNaNs(result, dfl, dfr, set);\r\n    }\r\n  // numeric comparison needed\r\n  comp=decNumCompare(dfl, dfr, 0);\r\n  decFloatZero(result);\r\n  if (comp==0) return result;\r\n  DFBYTE(result, DECBYTES-1)=0x01;      // LSD=1\r\n  if (comp<0) DFBYTE(result, 0)|=0x80;  // set sign bit\r\n  return result;\r\n  } // decFloatCompareSignal\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatCompareTotal -- compare two decFloats with total ordering  */\r\n/*                                                                    */\r\n/*   result gets the result of comparing dfl and dfr                  */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   returns result, which may be -1, 0, or 1                         */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatCompareTotal(decFloat *result,\r\n                                const decFloat *dfl, const decFloat *dfr) {\r\n  Int  comp;                                 // work\r\n  uInt uiwork;                               // for macros\r\n  #if QUAD\r\n  uShort uswork;                             // ..\r\n  #endif\r\n  if (DFISNAN(dfl) || DFISNAN(dfr)) {\r\n    Int nanl, nanr;                          // work\r\n    // morph NaNs to +/- 1 or 2, leave numbers as 0\r\n    nanl=DFISSNAN(dfl)+DFISQNAN(dfl)*2;      // quiet > signalling\r\n    if (DFISSIGNED(dfl)) nanl=-nanl;\r\n    nanr=DFISSNAN(dfr)+DFISQNAN(dfr)*2;\r\n    if (DFISSIGNED(dfr)) nanr=-nanr;\r\n    if (nanl>nanr) comp=+1;\r\n     else if (nanl<nanr) comp=-1;\r\n     else { // NaNs are the same type and sign .. must compare payload\r\n      // buffers need +2 for QUAD\r\n      uByte bufl[DECPMAX+4];                 // for LHS coefficient + foot\r\n      uByte bufr[DECPMAX+4];                 // for RHS coefficient + foot\r\n      uByte *ub, *uc;                        // work\r\n      Int sigl;                              // signum of LHS\r\n      sigl=(DFISSIGNED(dfl) ? -1 : +1);\r\n\r\n      // decode the coefficients\r\n      // (shift both right two if Quad to make a multiple of four)\r\n      #if QUAD\r\n        UBFROMUS(bufl, 0);\r\n        UBFROMUS(bufr, 0);\r\n      #endif\r\n      GETCOEFF(dfl, bufl+QUAD*2);            // decode from decFloat\r\n      GETCOEFF(dfr, bufr+QUAD*2);            // ..\r\n      // all multiples of four, here\r\n      comp=0;                                // assume equal\r\n      for (ub=bufl, uc=bufr; ub<bufl+DECPMAX+QUAD*2; ub+=4, uc+=4) {\r\n        uInt ui=UBTOUI(ub);\r\n        if (ui==UBTOUI(uc)) continue; // so far so same\r\n        // about to find a winner; go by bytes in case little-endian\r\n        for (;; ub++, uc++) {\r\n          if (*ub==*uc) continue;\r\n          if (*ub>*uc) comp=sigl;            // difference found\r\n           else comp=-sigl;                  // ..\r\n           break;\r\n          }\r\n        }\r\n      } // same NaN type and sign\r\n    }\r\n   else {\r\n    // numeric comparison needed\r\n    comp=decNumCompare(dfl, dfr, 1);    // total ordering\r\n    }\r\n  decFloatZero(result);\r\n  if (comp==0) return result;\r\n  DFBYTE(result, DECBYTES-1)=0x01;      // LSD=1\r\n  if (comp<0) DFBYTE(result, 0)|=0x80;  // set sign bit\r\n  return result;\r\n  } // decFloatCompareTotal\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatCompareTotalMag -- compare magnitudes with total ordering  */\r\n/*                                                                    */\r\n/*   result gets the result of comparing abs(dfl) and abs(dfr)        */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   returns result, which may be -1, 0, or 1                         */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatCompareTotalMag(decFloat *result,\r\n                                const decFloat *dfl, const decFloat *dfr) {\r\n  decFloat a, b;                        // for copy if needed\r\n  // copy and redirect signed operand(s)\r\n  if (DFISSIGNED(dfl)) {\r\n    decFloatCopyAbs(&a, dfl);\r\n    dfl=&a;\r\n    }\r\n  if (DFISSIGNED(dfr)) {\r\n    decFloatCopyAbs(&b, dfr);\r\n    dfr=&b;\r\n    }\r\n  return decFloatCompareTotal(result, dfl, dfr);\r\n  } // decFloatCompareTotalMag\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatCopy -- copy a decFloat as-is                              */\r\n/*                                                                    */\r\n/*   result gets the copy of dfl                                      */\r\n/*   dfl    is the decFloat to copy                                   */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This is a bitwise operation; no errors or exceptions are possible. */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatCopy(decFloat *result, const decFloat *dfl) {\r\n  if (dfl!=result) *result=*dfl;             // copy needed\r\n  return result;\r\n  } // decFloatCopy\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatCopyAbs -- copy a decFloat as-is and set sign bit to 0     */\r\n/*                                                                    */\r\n/*   result gets the copy of dfl with sign bit 0                      */\r\n/*   dfl    is the decFloat to copy                                   */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This is a bitwise operation; no errors or exceptions are possible. */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatCopyAbs(decFloat *result, const decFloat *dfl) {\r\n  if (dfl!=result) *result=*dfl;        // copy needed\r\n  DFBYTE(result, 0)&=~0x80;             // zero sign bit\r\n  return result;\r\n  } // decFloatCopyAbs\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatCopyNegate -- copy a decFloat as-is with inverted sign bit */\r\n/*                                                                    */\r\n/*   result gets the copy of dfl with sign bit inverted               */\r\n/*   dfl    is the decFloat to copy                                   */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This is a bitwise operation; no errors or exceptions are possible. */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatCopyNegate(decFloat *result, const decFloat *dfl) {\r\n  if (dfl!=result) *result=*dfl;        // copy needed\r\n  DFBYTE(result, 0)^=0x80;              // invert sign bit\r\n  return result;\r\n  } // decFloatCopyNegate\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatCopySign -- copy a decFloat with the sign of another       */\r\n/*                                                                    */\r\n/*   result gets the result of copying dfl with the sign of dfr       */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This is a bitwise operation; no errors or exceptions are possible. */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatCopySign(decFloat *result,\r\n                            const decFloat *dfl, const decFloat *dfr) {\r\n  uByte sign=(uByte)(DFBYTE(dfr, 0)&0x80);   // save sign bit\r\n  if (dfl!=result) *result=*dfl;             // copy needed\r\n  DFBYTE(result, 0)&=~0x80;                  // clear sign ..\r\n  DFBYTE(result, 0)=(uByte)(DFBYTE(result, 0)|sign); // .. and set saved\r\n  return result;\r\n  } // decFloatCopySign\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatDigits -- return the number of digits in a decFloat        */\r\n/*                                                                    */\r\n/*   df is the decFloat to investigate                                */\r\n/*   returns the number of significant digits in the decFloat; a      */\r\n/*     zero coefficient returns 1 as does an infinity (a NaN returns  */\r\n/*     the number of digits in the payload)                           */\r\n/* ------------------------------------------------------------------ */\r\n// private macro to extract a declet according to provided formula\r\n// (form), and if it is non-zero then return the calculated digits\r\n// depending on the declet number (n), where n=0 for the most\r\n// significant declet; uses uInt dpd for work\r\n#define dpdlenchk(n, form)  dpd=(form)&0x3ff;     \\\r\n  if (dpd) return (DECPMAX-1-3*(n))-(3-DPD2BCD8[dpd*4+3])\r\n// next one is used when it is known that the declet must be\r\n// non-zero, or is the final zero declet\r\n#define dpdlendun(n, form)  dpd=(form)&0x3ff;     \\\r\n  if (dpd==0) return 1;                           \\\r\n  return (DECPMAX-1-3*(n))-(3-DPD2BCD8[dpd*4+3])\r\n\r\nuInt decFloatDigits(const decFloat *df) {\r\n  uInt dpd;                        // work\r\n  uInt sourhi=DFWORD(df, 0);       // top word from source decFloat\r\n  #if QUAD\r\n  uInt sourmh, sourml;\r\n  #endif\r\n  uInt sourlo;\r\n\r\n  if (DFISINF(df)) return 1;\r\n  // A NaN effectively has an MSD of 0; otherwise if non-zero MSD\r\n  // then the coefficient is full-length\r\n  if (!DFISNAN(df) && DECCOMBMSD[sourhi>>26]) return DECPMAX;\r\n\r\n  #if DOUBLE\r\n    if (sourhi&0x0003ffff) {     // ends in first\r\n      dpdlenchk(0, sourhi>>8);\r\n      sourlo=DFWORD(df, 1);\r\n      dpdlendun(1, (sourhi<<2) | (sourlo>>30));\r\n      } // [cannot drop through]\r\n    sourlo=DFWORD(df, 1);  // sourhi not involved now\r\n    if (sourlo&0xfff00000) {     // in one of first two\r\n      dpdlenchk(1, sourlo>>30);  // very rare\r\n      dpdlendun(2, sourlo>>20);\r\n      } // [cannot drop through]\r\n    dpdlenchk(3, sourlo>>10);\r\n    dpdlendun(4, sourlo);\r\n    // [cannot drop through]\r\n\r\n  #elif QUAD\r\n    if (sourhi&0x00003fff) {     // ends in first\r\n      dpdlenchk(0, sourhi>>4);\r\n      sourmh=DFWORD(df, 1);\r\n      dpdlendun(1, ((sourhi)<<6) | (sourmh>>26));\r\n      } // [cannot drop through]\r\n    sourmh=DFWORD(df, 1);\r\n    if (sourmh) {\r\n      dpdlenchk(1, sourmh>>26);\r\n      dpdlenchk(2, sourmh>>16);\r\n      dpdlenchk(3, sourmh>>6);\r\n      sourml=DFWORD(df, 2);\r\n      dpdlendun(4, ((sourmh)<<4) | (sourml>>28));\r\n      } // [cannot drop through]\r\n    sourml=DFWORD(df, 2);\r\n    if (sourml) {\r\n      dpdlenchk(4, sourml>>28);\r\n      dpdlenchk(5, sourml>>18);\r\n      dpdlenchk(6, sourml>>8);\r\n      sourlo=DFWORD(df, 3);\r\n      dpdlendun(7, ((sourml)<<2) | (sourlo>>30));\r\n      } // [cannot drop through]\r\n    sourlo=DFWORD(df, 3);\r\n    if (sourlo&0xfff00000) {     // in one of first two\r\n      dpdlenchk(7, sourlo>>30);  // very rare\r\n      dpdlendun(8, sourlo>>20);\r\n      } // [cannot drop through]\r\n    dpdlenchk(9, sourlo>>10);\r\n    dpdlendun(10, sourlo);\r\n    // [cannot drop through]\r\n  #endif\r\n  } // decFloatDigits\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatDivide -- divide a decFloat by another                     */\r\n/*                                                                    */\r\n/*   result gets the result of dividing dfl by dfr:                   */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\n// This is just a wrapper.\r\ndecFloat * decFloatDivide(decFloat *result,\r\n                          const decFloat *dfl, const decFloat *dfr,\r\n                          decContext *set) {\r\n  return decDivide(result, dfl, dfr, set, DIVIDE);\r\n  } // decFloatDivide\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatDivideInteger -- integer divide a decFloat by another      */\r\n/*                                                                    */\r\n/*   result gets the result of dividing dfl by dfr:                   */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatDivideInteger(decFloat *result,\r\n                             const decFloat *dfl, const decFloat *dfr,\r\n                             decContext *set) {\r\n  return decDivide(result, dfl, dfr, set, DIVIDEINT);\r\n  } // decFloatDivideInteger\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatFMA -- multiply and add three decFloats, fused             */\r\n/*                                                                    */\r\n/*   result gets the result of (dfl*dfr)+dff with a single rounding   */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   dff    is the final decFloat (fhs)                               */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatFMA(decFloat *result, const decFloat *dfl,\r\n                       const decFloat *dfr, const decFloat *dff,\r\n                       decContext *set) {\r\n\r\n  // The accumulator has the bytes needed for FiniteMultiply, plus\r\n  // one byte to the left in case of carry, plus DECPMAX+2 to the\r\n  // right for the final addition (up to full fhs + round & sticky)\r\n  #define FMALEN (ROUNDUP4(1+ (DECPMAX9*18+1) +DECPMAX+2))\r\n  uByte  acc[FMALEN];              // for multiplied coefficient in BCD\r\n                                   // .. and for final result\r\n  bcdnum mul;                      // for multiplication result\r\n  bcdnum fin;                      // for final operand, expanded\r\n  uByte  coe[ROUNDUP4(DECPMAX)];   // dff coefficient in BCD\r\n  bcdnum *hi, *lo;                 // bcdnum with higher/lower exponent\r\n  uInt   diffsign;                 // non-zero if signs differ\r\n  uInt   hipad;                    // pad digit for hi if needed\r\n  Int    padding;                  // excess exponent\r\n  uInt   carry;                    // +1 for ten's complement and during add\r\n  uByte  *ub, *uh, *ul;            // work\r\n  uInt   uiwork;                   // for macros\r\n\r\n  // handle all the special values [any special operand leads to a\r\n  // special result]\r\n  if (DFISSPECIAL(dfl) || DFISSPECIAL(dfr) || DFISSPECIAL(dff)) {\r\n    decFloat proxy;                // multiplication result proxy\r\n    // NaNs are handled as usual, giving priority to sNaNs\r\n    if (DFISSNAN(dfl) || DFISSNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n    if (DFISSNAN(dff)) return decNaNs(result, dff, NULL, set);\r\n    if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n    if (DFISNAN(dff)) return decNaNs(result, dff, NULL, set);\r\n    // One or more of the three is infinite\r\n    // infinity times zero is bad\r\n    decFloatZero(&proxy);\r\n    if (DFISINF(dfl)) {\r\n      if (DFISZERO(dfr)) return decInvalid(result, set);\r\n      decInfinity(&proxy, &proxy);\r\n      }\r\n     else if (DFISINF(dfr)) {\r\n      if (DFISZERO(dfl)) return decInvalid(result, set);\r\n      decInfinity(&proxy, &proxy);\r\n      }\r\n    // compute sign of multiplication and place in proxy\r\n    DFWORD(&proxy, 0)|=(DFWORD(dfl, 0)^DFWORD(dfr, 0))&DECFLOAT_Sign;\r\n    if (!DFISINF(dff)) return decFloatCopy(result, &proxy);\r\n    // dff is Infinite\r\n    if (!DFISINF(&proxy)) return decInfinity(result, dff);\r\n    // both sides of addition are infinite; different sign is bad\r\n    if ((DFWORD(dff, 0)&DECFLOAT_Sign)!=(DFWORD(&proxy, 0)&DECFLOAT_Sign))\r\n      return decInvalid(result, set);\r\n    return decFloatCopy(result, &proxy);\r\n    }\r\n\r\n  /* Here when all operands are finite */\r\n\r\n  // First multiply dfl*dfr\r\n  decFiniteMultiply(&mul, acc+1, dfl, dfr);\r\n  // The multiply is complete, exact and unbounded, and described in\r\n  // mul with the coefficient held in acc[1...]\r\n\r\n  // now add in dff; the algorithm is essentially the same as\r\n  // decFloatAdd, but the code is different because the code there\r\n  // is highly optimized for adding two numbers of the same size\r\n  fin.exponent=GETEXPUN(dff);           // get dff exponent and sign\r\n  fin.sign=DFWORD(dff, 0)&DECFLOAT_Sign;\r\n  diffsign=mul.sign^fin.sign;           // note if signs differ\r\n  fin.msd=coe;\r\n  fin.lsd=coe+DECPMAX-1;\r\n  GETCOEFF(dff, coe);                   // extract the coefficient\r\n\r\n  // now set hi and lo so that hi points to whichever of mul and fin\r\n  // has the higher exponent and lo points to the other [don't care,\r\n  // if the same].  One coefficient will be in acc, the other in coe.\r\n  if (mul.exponent>=fin.exponent) {\r\n    hi=&mul;\r\n    lo=&fin;\r\n    }\r\n   else {\r\n    hi=&fin;\r\n    lo=&mul;\r\n    }\r\n\r\n  // remove leading zeros on both operands; this will save time later\r\n  // and make testing for zero trivial (tests are safe because acc\r\n  // and coe are rounded up to uInts)\r\n  for (; UBTOUI(hi->msd)==0 && hi->msd+3<hi->lsd;) hi->msd+=4;\r\n  for (; *hi->msd==0 && hi->msd<hi->lsd;) hi->msd++;\r\n  for (; UBTOUI(lo->msd)==0 && lo->msd+3<lo->lsd;) lo->msd+=4;\r\n  for (; *lo->msd==0 && lo->msd<lo->lsd;) lo->msd++;\r\n\r\n  // if hi is zero then result will be lo (which has the smaller\r\n  // exponent), which also may need to be tested for zero for the\r\n  // weird IEEE 754 sign rules\r\n  if (*hi->msd==0) {                         // hi is zero\r\n    // \"When the sum of two operands with opposite signs is\r\n    // exactly zero, the sign of that sum shall be '+' in all\r\n    // rounding modes except round toward -Infinity, in which\r\n    // mode that sign shall be '-'.\"\r\n    if (diffsign) {\r\n      if (*lo->msd==0) {                     // lo is zero\r\n        lo->sign=0;\r\n        if (set->round==DEC_ROUND_FLOOR) lo->sign=DECFLOAT_Sign;\r\n        } // diffsign && lo=0\r\n      } // diffsign\r\n    return decFinalize(result, lo, set);     // may need clamping\r\n    } // numfl is zero\r\n  // [here, both are minimal length and hi is non-zero]\r\n  // (if lo is zero then padding with zeros may be needed, below)\r\n\r\n  // if signs differ, take the ten's complement of hi (zeros to the\r\n  // right do not matter because the complement of zero is zero); the\r\n  // +1 is done later, as part of the addition, inserted at the\r\n  // correct digit\r\n  hipad=0;\r\n  carry=0;\r\n  if (diffsign) {\r\n    hipad=9;\r\n    carry=1;\r\n    // exactly the correct number of digits must be inverted\r\n    for (uh=hi->msd; uh<hi->lsd-3; uh+=4) UBFROMUI(uh, 0x09090909-UBTOUI(uh));\r\n    for (; uh<=hi->lsd; uh++) *uh=(uByte)(0x09-*uh);\r\n    }\r\n\r\n  // ready to add; note that hi has no leading zeros so gap\r\n  // calculation does not have to be as pessimistic as in decFloatAdd\r\n  // (this is much more like the arbitrary-precision algorithm in\r\n  // Rexx and decNumber)\r\n\r\n  // padding is the number of zeros that would need to be added to hi\r\n  // for its lsd to be aligned with the lsd of lo\r\n  padding=hi->exponent-lo->exponent;\r\n  // printf(\"FMA pad %ld\\n\", (LI)padding);\r\n\r\n  // the result of the addition will be built into the accumulator,\r\n  // starting from the far right; this could be either hi or lo, and\r\n  // will be aligned\r\n  ub=acc+FMALEN-1;                 // where lsd of result will go\r\n  ul=lo->lsd;                      // lsd of rhs\r\n\r\n  if (padding!=0) {                // unaligned\r\n    // if the msd of lo is more than DECPMAX+2 digits to the right of\r\n    // the original msd of hi then it can be reduced to a single\r\n    // digit at the right place, as it stays clear of hi digits\r\n    // [it must be DECPMAX+2 because during a subtraction the msd\r\n    // could become 0 after a borrow from 1.000 to 0.9999...]\r\n\r\n    Int hilen=(Int)(hi->lsd-hi->msd+1); // length of hi\r\n    Int lolen=(Int)(lo->lsd-lo->msd+1); // and of lo\r\n\r\n    if (hilen+padding-lolen > DECPMAX+2) {   // can reduce lo to single\r\n      // make sure it is virtually at least DECPMAX from hi->msd, at\r\n      // least to right of hi->lsd (in case of destructive subtract),\r\n      // and separated by at least two digits from either of those\r\n      // (the tricky DOUBLE case is when hi is a 1 that will become a\r\n      // 0.9999... by subtraction:\r\n      //   hi:   1                                   E+16\r\n      //   lo:    .................1000000000000000  E-16\r\n      // which for the addition pads to:\r\n      //   hi:   1000000000000000000                 E-16\r\n      //   lo:    .................1000000000000000  E-16\r\n      Int newexp=MINI(hi->exponent, hi->exponent+hilen-DECPMAX)-3;\r\n\r\n      // printf(\"FMA reduce: %ld\\n\", (LI)reduce);\r\n      lo->lsd=lo->msd;                       // to single digit [maybe 0]\r\n      lo->exponent=newexp;                   // new lowest exponent\r\n      padding=hi->exponent-lo->exponent;     // recalculate\r\n      ul=lo->lsd;                            // .. and repoint\r\n      }\r\n\r\n    // padding is still > 0, but will fit in acc (less leading carry slot)\r\n    #if DECCHECK\r\n      if (padding<=0) printf(\"FMA low padding: %ld\\n\", (LI)padding);\r\n      if (hilen+padding+1>FMALEN)\r\n        printf(\"FMA excess hilen+padding: %ld+%ld \\n\", (LI)hilen, (LI)padding);\r\n      // printf(\"FMA padding: %ld\\n\", (LI)padding);\r\n    #endif\r\n\r\n    // padding digits can now be set in the result; one or more of\r\n    // these will come from lo; others will be zeros in the gap\r\n    for (; ul-3>=lo->msd && padding>3; padding-=4, ul-=4, ub-=4) {\r\n      UBFROMUI(ub-3, UBTOUI(ul-3));          // [cannot overlap]\r\n      }\r\n    for (; ul>=lo->msd && padding>0; padding--, ul--, ub--) *ub=*ul;\r\n    for (;padding>0; padding--, ub--) *ub=0; // mind the gap\r\n    }\r\n\r\n  // addition now complete to the right of the rightmost digit of hi\r\n  uh=hi->lsd;\r\n\r\n  // dow do the add from hi->lsd to the left\r\n  // [bytewise, because either operand can run out at any time]\r\n  // carry was set up depending on ten's complement above\r\n  // first assume both operands have some digits\r\n  for (;; ub--) {\r\n    if (uh<hi->msd || ul<lo->msd) break;\r\n    *ub=(uByte)(carry+(*uh--)+(*ul--));\r\n    carry=0;\r\n    if (*ub<10) continue;\r\n    *ub-=10;\r\n    carry=1;\r\n    } // both loop\r\n\r\n  if (ul<lo->msd) {           // to left of lo\r\n    for (;; ub--) {\r\n      if (uh<hi->msd) break;\r\n      *ub=(uByte)(carry+(*uh--));  // [+0]\r\n      carry=0;\r\n      if (*ub<10) continue;\r\n      *ub-=10;\r\n      carry=1;\r\n      } // hi loop\r\n    }\r\n   else {                     // to left of hi\r\n    for (;; ub--) {\r\n      if (ul<lo->msd) break;\r\n      *ub=(uByte)(carry+hipad+(*ul--));\r\n      carry=0;\r\n      if (*ub<10) continue;\r\n      *ub-=10;\r\n      carry=1;\r\n      } // lo loop\r\n    }\r\n\r\n  // addition complete -- now handle carry, borrow, etc.\r\n  // use lo to set up the num (its exponent is already correct, and\r\n  // sign usually is)\r\n  lo->msd=ub+1;\r\n  lo->lsd=acc+FMALEN-1;\r\n  // decShowNum(lo, \"lo\");\r\n  if (!diffsign) {                 // same-sign addition\r\n    if (carry) {                   // carry out\r\n      *ub=1;                       // place the 1 ..\r\n      lo->msd--;                   // .. and update\r\n      }\r\n    } // same sign\r\n   else {                          // signs differed (subtraction)\r\n    if (!carry) {                  // no carry out means hi<lo\r\n      // borrowed -- take ten's complement of the right digits\r\n      lo->sign=hi->sign;           // sign is lhs sign\r\n      for (ul=lo->msd; ul<lo->lsd-3; ul+=4) UBFROMUI(ul, 0x09090909-UBTOUI(ul));\r\n      for (; ul<=lo->lsd; ul++) *ul=(uByte)(0x09-*ul); // [leaves ul at lsd+1]\r\n      // complete the ten's complement by adding 1 [cannot overrun]\r\n      for (ul--; *ul==9; ul--) *ul=0;\r\n      *ul+=1;\r\n      } // borrowed\r\n     else {                        // carry out means hi>=lo\r\n      // sign to use is lo->sign\r\n      // all done except for the special IEEE 754 exact-zero-result\r\n      // rule (see above); while testing for zero, strip leading\r\n      // zeros (which will save decFinalize doing it)\r\n      for (; UBTOUI(lo->msd)==0 && lo->msd+3<lo->lsd;) lo->msd+=4;\r\n      for (; *lo->msd==0 && lo->msd<lo->lsd;) lo->msd++;\r\n      if (*lo->msd==0) {           // must be true zero (and diffsign)\r\n        lo->sign=0;                // assume +\r\n        if (set->round==DEC_ROUND_FLOOR) lo->sign=DECFLOAT_Sign;\r\n        }\r\n      // [else was not zero, might still have leading zeros]\r\n      } // subtraction gave positive result\r\n    } // diffsign\r\n\r\n  #if DECCHECK\r\n  // assert no left underrun\r\n  if (lo->msd<acc) {\r\n    printf(\"FMA underrun by %ld \\n\", (LI)(acc-lo->msd));\r\n    }\r\n  #endif\r\n\r\n  return decFinalize(result, lo, set);  // round, check, and lay out\r\n  } // decFloatFMA\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatFromInt -- initialise a decFloat from an Int               */\r\n/*                                                                    */\r\n/*   result gets the converted Int                                    */\r\n/*   n      is the Int to convert                                     */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* The result is Exact; no errors or exceptions are possible.         */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatFromInt32(decFloat *result, Int n) {\r\n  uInt u=(uInt)n;                       // copy as bits\r\n  uInt encode;                          // work\r\n  DFWORD(result, 0)=ZEROWORD;           // always\r\n  #if QUAD\r\n    DFWORD(result, 1)=0;\r\n    DFWORD(result, 2)=0;\r\n  #endif\r\n  if (n<0) {                            // handle -n with care\r\n    // [This can be done without the test, but is then slightly slower]\r\n    u=(~u)+1;\r\n    DFWORD(result, 0)|=DECFLOAT_Sign;\r\n    }\r\n  // Since the maximum value of u now is 2**31, only the low word of\r\n  // result is affected\r\n  encode=BIN2DPD[u%1000];\r\n  u/=1000;\r\n  encode|=BIN2DPD[u%1000]<<10;\r\n  u/=1000;\r\n  encode|=BIN2DPD[u%1000]<<20;\r\n  u/=1000;                              // now 0, 1, or 2\r\n  encode|=u<<30;\r\n  DFWORD(result, DECWORDS-1)=encode;\r\n  return result;\r\n  } // decFloatFromInt32\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatFromUInt -- initialise a decFloat from a uInt              */\r\n/*                                                                    */\r\n/*   result gets the converted uInt                                   */\r\n/*   n      is the uInt to convert                                    */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* The result is Exact; no errors or exceptions are possible.         */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatFromUInt32(decFloat *result, uInt u) {\r\n  uInt encode;                          // work\r\n  DFWORD(result, 0)=ZEROWORD;           // always\r\n  #if QUAD\r\n    DFWORD(result, 1)=0;\r\n    DFWORD(result, 2)=0;\r\n  #endif\r\n  encode=BIN2DPD[u%1000];\r\n  u/=1000;\r\n  encode|=BIN2DPD[u%1000]<<10;\r\n  u/=1000;\r\n  encode|=BIN2DPD[u%1000]<<20;\r\n  u/=1000;                              // now 0 -> 4\r\n  encode|=u<<30;\r\n  DFWORD(result, DECWORDS-1)=encode;\r\n  DFWORD(result, DECWORDS-2)|=u>>2;     // rarely non-zero\r\n  return result;\r\n  } // decFloatFromUInt32\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatInvert -- logical digitwise INVERT of a decFloat           */\r\n/*                                                                    */\r\n/*   result gets the result of INVERTing df                           */\r\n/*   df     is the decFloat to invert                                 */\r\n/*   set    is the context                                            */\r\n/*   returns result, which will be canonical with sign=0              */\r\n/*                                                                    */\r\n/* The operand must be positive, finite with exponent q=0, and        */\r\n/* comprise just zeros and ones; if not, Invalid operation results.   */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatInvert(decFloat *result, const decFloat *df,\r\n                          decContext *set) {\r\n  uInt sourhi=DFWORD(df, 0);            // top word of dfs\r\n\r\n  if (!DFISUINT01(df) || !DFISCC01(df)) return decInvalid(result, set);\r\n  // the operand is a finite integer (q=0)\r\n  #if DOUBLE\r\n   DFWORD(result, 0)=ZEROWORD|((~sourhi)&0x04009124);\r\n   DFWORD(result, 1)=(~DFWORD(df, 1))   &0x49124491;\r\n  #elif QUAD\r\n   DFWORD(result, 0)=ZEROWORD|((~sourhi)&0x04000912);\r\n   DFWORD(result, 1)=(~DFWORD(df, 1))   &0x44912449;\r\n   DFWORD(result, 2)=(~DFWORD(df, 2))   &0x12449124;\r\n   DFWORD(result, 3)=(~DFWORD(df, 3))   &0x49124491;\r\n  #endif\r\n  return result;\r\n  } // decFloatInvert\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatIs -- decFloat tests (IsSigned, etc.)                      */\r\n/*                                                                    */\r\n/*   df is the decFloat to test                                       */\r\n/*   returns 0 or 1 in a uInt                                         */\r\n/*                                                                    */\r\n/* Many of these could be macros, but having them as real functions   */\r\n/* is a little cleaner (and they can be referred to here by the       */\r\n/* generic names)                                                     */\r\n/* ------------------------------------------------------------------ */\r\nuInt decFloatIsCanonical(const decFloat *df) {\r\n  if (DFISSPECIAL(df)) {\r\n    if (DFISINF(df)) {\r\n      if (DFWORD(df, 0)&ECONMASK) return 0;  // exponent continuation\r\n      if (!DFISCCZERO(df)) return 0;         // coefficient continuation\r\n      return 1;\r\n      }\r\n    // is a NaN\r\n    if (DFWORD(df, 0)&ECONNANMASK) return 0; // exponent continuation\r\n    if (DFISCCZERO(df)) return 1;            // coefficient continuation\r\n    // drop through to check payload\r\n    }\r\n  { // declare block\r\n  #if DOUBLE\r\n    uInt sourhi=DFWORD(df, 0);\r\n    uInt sourlo=DFWORD(df, 1);\r\n    if (CANONDPDOFF(sourhi, 8)\r\n     && CANONDPDTWO(sourhi, sourlo, 30)\r\n     && CANONDPDOFF(sourlo, 20)\r\n     && CANONDPDOFF(sourlo, 10)\r\n     && CANONDPDOFF(sourlo, 0)) return 1;\r\n  #elif QUAD\r\n    uInt sourhi=DFWORD(df, 0);\r\n    uInt sourmh=DFWORD(df, 1);\r\n    uInt sourml=DFWORD(df, 2);\r\n    uInt sourlo=DFWORD(df, 3);\r\n    if (CANONDPDOFF(sourhi, 4)\r\n     && CANONDPDTWO(sourhi, sourmh, 26)\r\n     && CANONDPDOFF(sourmh, 16)\r\n     && CANONDPDOFF(sourmh, 6)\r\n     && CANONDPDTWO(sourmh, sourml, 28)\r\n     && CANONDPDOFF(sourml, 18)\r\n     && CANONDPDOFF(sourml, 8)\r\n     && CANONDPDTWO(sourml, sourlo, 30)\r\n     && CANONDPDOFF(sourlo, 20)\r\n     && CANONDPDOFF(sourlo, 10)\r\n     && CANONDPDOFF(sourlo, 0)) return 1;\r\n  #endif\r\n  } // block\r\n  return 0;    // a declet is non-canonical\r\n  }\r\n\r\nuInt decFloatIsFinite(const decFloat *df) {\r\n  return !DFISSPECIAL(df);\r\n  }\r\nuInt decFloatIsInfinite(const decFloat *df) {\r\n  return DFISINF(df);\r\n  }\r\nuInt decFloatIsInteger(const decFloat *df) {\r\n  return DFISINT(df);\r\n  }\r\nuInt decFloatIsLogical(const decFloat *df) {\r\n  return DFISUINT01(df) & DFISCC01(df);\r\n  }\r\nuInt decFloatIsNaN(const decFloat *df) {\r\n  return DFISNAN(df);\r\n  }\r\nuInt decFloatIsNegative(const decFloat *df) {\r\n  return DFISSIGNED(df) && !DFISZERO(df) && !DFISNAN(df);\r\n  }\r\nuInt decFloatIsNormal(const decFloat *df) {\r\n  Int exp;                         // exponent\r\n  if (DFISSPECIAL(df)) return 0;\r\n  if (DFISZERO(df)) return 0;\r\n  // is finite and non-zero\r\n  exp=GETEXPUN(df)                 // get unbiased exponent ..\r\n     +decFloatDigits(df)-1;        // .. and make adjusted exponent\r\n  return (exp>=DECEMIN);           // < DECEMIN is subnormal\r\n  }\r\nuInt decFloatIsPositive(const decFloat *df) {\r\n  return !DFISSIGNED(df) && !DFISZERO(df) && !DFISNAN(df);\r\n  }\r\nuInt decFloatIsSignaling(const decFloat *df) {\r\n  return DFISSNAN(df);\r\n  }\r\nuInt decFloatIsSignalling(const decFloat *df) {\r\n  return DFISSNAN(df);\r\n  }\r\nuInt decFloatIsSigned(const decFloat *df) {\r\n  return DFISSIGNED(df);\r\n  }\r\nuInt decFloatIsSubnormal(const decFloat *df) {\r\n  if (DFISSPECIAL(df)) return 0;\r\n  // is finite\r\n  if (decFloatIsNormal(df)) return 0;\r\n  // it is <Nmin, but could be zero\r\n  if (DFISZERO(df)) return 0;\r\n  return 1;                                  // is subnormal\r\n  }\r\nuInt decFloatIsZero(const decFloat *df) {\r\n  return DFISZERO(df);\r\n  } // decFloatIs...\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatLogB -- return adjusted exponent, by 754 rules             */\r\n/*                                                                    */\r\n/*   result gets the adjusted exponent as an integer, or a NaN etc.   */\r\n/*   df     is the decFloat to be examined                            */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* Notable cases:                                                     */\r\n/*   A<0 -> Use |A|                                                   */\r\n/*   A=0 -> -Infinity (Division by zero)                              */\r\n/*   A=Infinite -> +Infinity (Exact)                                  */\r\n/*   A=1 exactly -> 0 (Exact)                                         */\r\n/*   NaNs are propagated as usual                                     */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatLogB(decFloat *result, const decFloat *df,\r\n                        decContext *set) {\r\n  Int ae;                                    // adjusted exponent\r\n  if (DFISNAN(df)) return decNaNs(result, df, NULL, set);\r\n  if (DFISINF(df)) {\r\n    DFWORD(result, 0)=0;                     // need +ve\r\n    return decInfinity(result, result);      // canonical +Infinity\r\n    }\r\n  if (DFISZERO(df)) {\r\n    set->status|=DEC_Division_by_zero;       // as per 754\r\n    DFWORD(result, 0)=DECFLOAT_Sign;         // make negative\r\n    return decInfinity(result, result);      // canonical -Infinity\r\n    }\r\n  ae=GETEXPUN(df)                       // get unbiased exponent ..\r\n    +decFloatDigits(df)-1;              // .. and make adjusted exponent\r\n  // ae has limited range (3 digits for DOUBLE and 4 for QUAD), so\r\n  // it is worth using a special case of decFloatFromInt32\r\n  DFWORD(result, 0)=ZEROWORD;           // always\r\n  if (ae<0) {\r\n    DFWORD(result, 0)|=DECFLOAT_Sign;   // -0 so far\r\n    ae=-ae;\r\n    }\r\n  #if DOUBLE\r\n    DFWORD(result, 1)=BIN2DPD[ae];      // a single declet\r\n  #elif QUAD\r\n    DFWORD(result, 1)=0;\r\n    DFWORD(result, 2)=0;\r\n    DFWORD(result, 3)=(ae/1000)<<10;    // is <10, so need no DPD encode\r\n    DFWORD(result, 3)|=BIN2DPD[ae%1000];\r\n  #endif\r\n  return result;\r\n  } // decFloatLogB\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatMax -- return maxnum of two operands                       */\r\n/*                                                                    */\r\n/*   result gets the chosen decFloat                                  */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* If just one operand is a quiet NaN it is ignored.                  */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatMax(decFloat *result,\r\n                       const decFloat *dfl, const decFloat *dfr,\r\n                       decContext *set) {\r\n  Int comp;\r\n  if (DFISNAN(dfl)) {\r\n    // sNaN or both NaNs leads to normal NaN processing\r\n    if (DFISNAN(dfr) || DFISSNAN(dfl)) return decNaNs(result, dfl, dfr, set);\r\n    return decCanonical(result, dfr);        // RHS is numeric\r\n    }\r\n  if (DFISNAN(dfr)) {\r\n    // sNaN leads to normal NaN processing (both NaN handled above)\r\n    if (DFISSNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n    return decCanonical(result, dfl);        // LHS is numeric\r\n    }\r\n  // Both operands are numeric; numeric comparison needed -- use\r\n  // total order for a well-defined choice (and +0 > -0)\r\n  comp=decNumCompare(dfl, dfr, 1);\r\n  if (comp>=0) return decCanonical(result, dfl);\r\n  return decCanonical(result, dfr);\r\n  } // decFloatMax\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatMaxMag -- return maxnummag of two operands                 */\r\n/*                                                                    */\r\n/*   result gets the chosen decFloat                                  */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* Returns according to the magnitude comparisons if both numeric and */\r\n/* unequal, otherwise returns maxnum                                  */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatMaxMag(decFloat *result,\r\n                       const decFloat *dfl, const decFloat *dfr,\r\n                       decContext *set) {\r\n  Int comp;\r\n  decFloat absl, absr;\r\n  if (DFISNAN(dfl) || DFISNAN(dfr)) return decFloatMax(result, dfl, dfr, set);\r\n\r\n  decFloatCopyAbs(&absl, dfl);\r\n  decFloatCopyAbs(&absr, dfr);\r\n  comp=decNumCompare(&absl, &absr, 0);\r\n  if (comp>0) return decCanonical(result, dfl);\r\n  if (comp<0) return decCanonical(result, dfr);\r\n  return decFloatMax(result, dfl, dfr, set);\r\n  } // decFloatMaxMag\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatMin -- return minnum of two operands                       */\r\n/*                                                                    */\r\n/*   result gets the chosen decFloat                                  */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* If just one operand is a quiet NaN it is ignored.                  */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatMin(decFloat *result,\r\n                       const decFloat *dfl, const decFloat *dfr,\r\n                       decContext *set) {\r\n  Int comp;\r\n  if (DFISNAN(dfl)) {\r\n    // sNaN or both NaNs leads to normal NaN processing\r\n    if (DFISNAN(dfr) || DFISSNAN(dfl)) return decNaNs(result, dfl, dfr, set);\r\n    return decCanonical(result, dfr);        // RHS is numeric\r\n    }\r\n  if (DFISNAN(dfr)) {\r\n    // sNaN leads to normal NaN processing (both NaN handled above)\r\n    if (DFISSNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n    return decCanonical(result, dfl);        // LHS is numeric\r\n    }\r\n  // Both operands are numeric; numeric comparison needed -- use\r\n  // total order for a well-defined choice (and +0 > -0)\r\n  comp=decNumCompare(dfl, dfr, 1);\r\n  if (comp<=0) return decCanonical(result, dfl);\r\n  return decCanonical(result, dfr);\r\n  } // decFloatMin\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatMinMag -- return minnummag of two operands                 */\r\n/*                                                                    */\r\n/*   result gets the chosen decFloat                                  */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* Returns according to the magnitude comparisons if both numeric and */\r\n/* unequal, otherwise returns minnum                                  */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatMinMag(decFloat *result,\r\n                       const decFloat *dfl, const decFloat *dfr,\r\n                       decContext *set) {\r\n  Int comp;\r\n  decFloat absl, absr;\r\n  if (DFISNAN(dfl) || DFISNAN(dfr)) return decFloatMin(result, dfl, dfr, set);\r\n\r\n  decFloatCopyAbs(&absl, dfl);\r\n  decFloatCopyAbs(&absr, dfr);\r\n  comp=decNumCompare(&absl, &absr, 0);\r\n  if (comp<0) return decCanonical(result, dfl);\r\n  if (comp>0) return decCanonical(result, dfr);\r\n  return decFloatMin(result, dfl, dfr, set);\r\n  } // decFloatMinMag\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatMinus -- negate value, heeding NaNs, etc.                  */\r\n/*                                                                    */\r\n/*   result gets the canonicalized 0-df                               */\r\n/*   df     is the decFloat to minus                                  */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This has the same effect as 0-df where the exponent of the zero is */\r\n/* the same as that of df (if df is finite).                          */\r\n/* The effect is also the same as decFloatCopyNegate except that NaNs */\r\n/* are handled normally (the sign of a NaN is not affected, and an    */\r\n/* sNaN will signal), the result is canonical, and zero gets sign 0.  */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatMinus(decFloat *result, const decFloat *df,\r\n                         decContext *set) {\r\n  if (DFISNAN(df)) return decNaNs(result, df, NULL, set);\r\n  decCanonical(result, df);                       // copy and check\r\n  if (DFISZERO(df)) DFBYTE(result, 0)&=~0x80;     // turn off sign bit\r\n   else DFBYTE(result, 0)^=0x80;                  // flip sign bit\r\n  return result;\r\n  } // decFloatMinus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatMultiply -- multiply two decFloats                         */\r\n/*                                                                    */\r\n/*   result gets the result of multiplying dfl and dfr:               */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatMultiply(decFloat *result,\r\n                            const decFloat *dfl, const decFloat *dfr,\r\n                            decContext *set) {\r\n  bcdnum num;                      // for final conversion\r\n  uByte  bcdacc[DECPMAX9*18+1];    // for coefficent in BCD\r\n\r\n  if (DFISSPECIAL(dfl) || DFISSPECIAL(dfr)) { // either is special?\r\n    // NaNs are handled as usual\r\n    if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n    // infinity times zero is bad\r\n    if (DFISINF(dfl) && DFISZERO(dfr)) return decInvalid(result, set);\r\n    if (DFISINF(dfr) && DFISZERO(dfl)) return decInvalid(result, set);\r\n    // both infinite; return canonical infinity with computed sign\r\n    DFWORD(result, 0)=DFWORD(dfl, 0)^DFWORD(dfr, 0); // compute sign\r\n    return decInfinity(result, result);\r\n    }\r\n\r\n  /* Here when both operands are finite */\r\n  decFiniteMultiply(&num, bcdacc, dfl, dfr);\r\n  return decFinalize(result, &num, set); // round, check, and lay out\r\n  } // decFloatMultiply\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatNextMinus -- next towards -Infinity                        */\r\n/*                                                                    */\r\n/*   result gets the next lesser decFloat                             */\r\n/*   dfl    is the decFloat to start with                             */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This is 754 nextdown; Invalid is the only status possible (from    */\r\n/* an sNaN).                                                          */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatNextMinus(decFloat *result, const decFloat *dfl,\r\n                             decContext *set) {\r\n  decFloat delta;                       // tiny increment\r\n  uInt savestat;                        // saves status\r\n  enum rounding saveround;              // .. and mode\r\n\r\n  // +Infinity is the special case\r\n  if (DFISINF(dfl) && !DFISSIGNED(dfl)) {\r\n    DFSETNMAX(result);\r\n    return result;                      // [no status to set]\r\n    }\r\n  // other cases are effected by sutracting a tiny delta -- this\r\n  // should be done in a wider format as the delta is unrepresentable\r\n  // here (but can be done with normal add if the sign of zero is\r\n  // treated carefully, because no Inexactitude is interesting);\r\n  // rounding to -Infinity then pushes the result to next below\r\n  decFloatZero(&delta);                 // set up tiny delta\r\n  DFWORD(&delta, DECWORDS-1)=1;         // coefficient=1\r\n  DFWORD(&delta, 0)=DECFLOAT_Sign;      // Sign=1 + biased exponent=0\r\n  // set up for the directional round\r\n  saveround=set->round;                 // save mode\r\n  set->round=DEC_ROUND_FLOOR;           // .. round towards -Infinity\r\n  savestat=set->status;                 // save status\r\n  decFloatAdd(result, dfl, &delta, set);\r\n  // Add rules mess up the sign when going from +Ntiny to 0\r\n  if (DFISZERO(result)) DFWORD(result, 0)^=DECFLOAT_Sign; // correct\r\n  set->status&=DEC_Invalid_operation;   // preserve only sNaN status\r\n  set->status|=savestat;                // restore pending flags\r\n  set->round=saveround;                 // .. and mode\r\n  return result;\r\n  } // decFloatNextMinus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatNextPlus -- next towards +Infinity                         */\r\n/*                                                                    */\r\n/*   result gets the next larger decFloat                             */\r\n/*   dfl    is the decFloat to start with                             */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This is 754 nextup; Invalid is the only status possible (from      */\r\n/* an sNaN).                                                          */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatNextPlus(decFloat *result, const decFloat *dfl,\r\n                            decContext *set) {\r\n  uInt savestat;                        // saves status\r\n  enum rounding saveround;              // .. and mode\r\n  decFloat delta;                       // tiny increment\r\n\r\n  // -Infinity is the special case\r\n  if (DFISINF(dfl) && DFISSIGNED(dfl)) {\r\n    DFSETNMAX(result);\r\n    DFWORD(result, 0)|=DECFLOAT_Sign;   // make negative\r\n    return result;                      // [no status to set]\r\n    }\r\n  // other cases are effected by sutracting a tiny delta -- this\r\n  // should be done in a wider format as the delta is unrepresentable\r\n  // here (but can be done with normal add if the sign of zero is\r\n  // treated carefully, because no Inexactitude is interesting);\r\n  // rounding to +Infinity then pushes the result to next above\r\n  decFloatZero(&delta);                 // set up tiny delta\r\n  DFWORD(&delta, DECWORDS-1)=1;         // coefficient=1\r\n  DFWORD(&delta, 0)=0;                  // Sign=0 + biased exponent=0\r\n  // set up for the directional round\r\n  saveround=set->round;                 // save mode\r\n  set->round=DEC_ROUND_CEILING;         // .. round towards +Infinity\r\n  savestat=set->status;                 // save status\r\n  decFloatAdd(result, dfl, &delta, set);\r\n  // Add rules mess up the sign when going from -Ntiny to -0\r\n  if (DFISZERO(result)) DFWORD(result, 0)^=DECFLOAT_Sign; // correct\r\n  set->status&=DEC_Invalid_operation;   // preserve only sNaN status\r\n  set->status|=savestat;                // restore pending flags\r\n  set->round=saveround;                 // .. and mode\r\n  return result;\r\n  } // decFloatNextPlus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatNextToward -- next towards a decFloat                      */\r\n/*                                                                    */\r\n/*   result gets the next decFloat                                    */\r\n/*   dfl    is the decFloat to start with                             */\r\n/*   dfr    is the decFloat to move toward                            */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This is 754-1985 nextafter, as modified during revision (dropped   */\r\n/* from 754-2008); status may be set unless the result is a normal    */\r\n/* number.                                                            */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatNextToward(decFloat *result,\r\n                              const decFloat *dfl, const decFloat *dfr,\r\n                              decContext *set) {\r\n  decFloat delta;                       // tiny increment or decrement\r\n  decFloat pointone;                    // 1e-1\r\n  uInt  savestat;                       // saves status\r\n  enum  rounding saveround;             // .. and mode\r\n  uInt  deltatop;                       // top word for delta\r\n  Int   comp;                           // work\r\n\r\n  if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n  // Both are numeric, so Invalid no longer a possibility\r\n  comp=decNumCompare(dfl, dfr, 0);\r\n  if (comp==0) return decFloatCopySign(result, dfl, dfr); // equal\r\n  // unequal; do NextPlus or NextMinus but with different status rules\r\n\r\n  if (comp<0) { // lhs<rhs, do NextPlus, see above for commentary\r\n    if (DFISINF(dfl) && DFISSIGNED(dfl)) {   // -Infinity special case\r\n      DFSETNMAX(result);\r\n      DFWORD(result, 0)|=DECFLOAT_Sign;\r\n      return result;\r\n      }\r\n    saveround=set->round;                    // save mode\r\n    set->round=DEC_ROUND_CEILING;            // .. round towards +Infinity\r\n    deltatop=0;                              // positive delta\r\n    }\r\n   else { // lhs>rhs, do NextMinus, see above for commentary\r\n    if (DFISINF(dfl) && !DFISSIGNED(dfl)) {  // +Infinity special case\r\n      DFSETNMAX(result);\r\n      return result;\r\n      }\r\n    saveround=set->round;                    // save mode\r\n    set->round=DEC_ROUND_FLOOR;              // .. round towards -Infinity\r\n    deltatop=DECFLOAT_Sign;                  // negative delta\r\n    }\r\n  savestat=set->status;                      // save status\r\n  // Here, Inexact is needed where appropriate (and hence Underflow,\r\n  // etc.).  Therefore the tiny delta which is otherwise\r\n  // unrepresentable (see NextPlus and NextMinus) is constructed\r\n  // using the multiplication of FMA.\r\n  decFloatZero(&delta);                 // set up tiny delta\r\n  DFWORD(&delta, DECWORDS-1)=1;         // coefficient=1\r\n  DFWORD(&delta, 0)=deltatop;           // Sign + biased exponent=0\r\n  decFloatFromString(&pointone, \"1E-1\", set); // set up multiplier\r\n  decFloatFMA(result, &delta, &pointone, dfl, set);\r\n  // [Delta is truly tiny, so no need to correct sign of zero]\r\n  // use new status unless the result is normal\r\n  if (decFloatIsNormal(result)) set->status=savestat; // else goes forward\r\n  set->round=saveround;                 // restore mode\r\n  return result;\r\n  } // decFloatNextToward\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatOr -- logical digitwise OR of two decFloats                */\r\n/*                                                                    */\r\n/*   result gets the result of ORing dfl and dfr                      */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result, which will be canonical with sign=0              */\r\n/*                                                                    */\r\n/* The operands must be positive, finite with exponent q=0, and       */\r\n/* comprise just zeros and ones; if not, Invalid operation results.   */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatOr(decFloat *result,\r\n                       const decFloat *dfl, const decFloat *dfr,\r\n                       decContext *set) {\r\n  if (!DFISUINT01(dfl) || !DFISUINT01(dfr)\r\n   || !DFISCC01(dfl)   || !DFISCC01(dfr)) return decInvalid(result, set);\r\n  // the operands are positive finite integers (q=0) with just 0s and 1s\r\n  #if DOUBLE\r\n   DFWORD(result, 0)=ZEROWORD\r\n                   |((DFWORD(dfl, 0) | DFWORD(dfr, 0))&0x04009124);\r\n   DFWORD(result, 1)=(DFWORD(dfl, 1) | DFWORD(dfr, 1))&0x49124491;\r\n  #elif QUAD\r\n   DFWORD(result, 0)=ZEROWORD\r\n                   |((DFWORD(dfl, 0) | DFWORD(dfr, 0))&0x04000912);\r\n   DFWORD(result, 1)=(DFWORD(dfl, 1) | DFWORD(dfr, 1))&0x44912449;\r\n   DFWORD(result, 2)=(DFWORD(dfl, 2) | DFWORD(dfr, 2))&0x12449124;\r\n   DFWORD(result, 3)=(DFWORD(dfl, 3) | DFWORD(dfr, 3))&0x49124491;\r\n  #endif\r\n  return result;\r\n  } // decFloatOr\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatPlus -- add value to 0, heeding NaNs, etc.                 */\r\n/*                                                                    */\r\n/*   result gets the canonicalized 0+df                               */\r\n/*   df     is the decFloat to plus                                   */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This has the same effect as 0+df where the exponent of the zero is */\r\n/* the same as that of df (if df is finite).                          */\r\n/* The effect is also the same as decFloatCopy except that NaNs       */\r\n/* are handled normally (the sign of a NaN is not affected, and an    */\r\n/* sNaN will signal), the result is canonical, and zero gets sign 0.  */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatPlus(decFloat *result, const decFloat *df,\r\n                        decContext *set) {\r\n  if (DFISNAN(df)) return decNaNs(result, df, NULL, set);\r\n  decCanonical(result, df);                       // copy and check\r\n  if (DFISZERO(df)) DFBYTE(result, 0)&=~0x80;     // turn off sign bit\r\n  return result;\r\n  } // decFloatPlus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatQuantize -- quantize a decFloat                            */\r\n/*                                                                    */\r\n/*   result gets the result of quantizing dfl to match dfr            */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs), which sets the exponent     */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* Unless there is an error or the result is infinite, the exponent   */\r\n/* of result is guaranteed to be the same as that of dfr.             */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatQuantize(decFloat *result,\r\n                            const decFloat *dfl, const decFloat *dfr,\r\n                            decContext *set) {\r\n  Int   explb, exprb;         // left and right biased exponents\r\n  uByte *ulsd;                // local LSD pointer\r\n  uByte *ub, *uc;             // work\r\n  Int   drop;                 // ..\r\n  uInt  dpd;                  // ..\r\n  uInt  encode;               // encoding accumulator\r\n  uInt  sourhil, sourhir;     // top words from source decFloats\r\n  uInt  uiwork;               // for macros\r\n  #if QUAD\r\n  uShort uswork;              // ..\r\n  #endif\r\n  // the following buffer holds the coefficient for manipulation\r\n  uByte buf[4+DECPMAX*3+2*QUAD];   // + space for zeros to left or right\r\n  #if DECTRACE\r\n  bcdnum num;                      // for trace displays\r\n  #endif\r\n\r\n  /* Start decoding the arguments */\r\n  sourhil=DFWORD(dfl, 0);          // LHS top word\r\n  explb=DECCOMBEXP[sourhil>>26];   // get exponent high bits (in place)\r\n  sourhir=DFWORD(dfr, 0);          // RHS top word\r\n  exprb=DECCOMBEXP[sourhir>>26];\r\n\r\n  if (EXPISSPECIAL(explb | exprb)) { // either is special?\r\n    // NaNs are handled as usual\r\n    if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n    // one infinity but not both is bad\r\n    if (DFISINF(dfl)!=DFISINF(dfr)) return decInvalid(result, set);\r\n    // both infinite; return canonical infinity with sign of LHS\r\n    return decInfinity(result, dfl);\r\n    }\r\n\r\n  /* Here when both arguments are finite */\r\n  // complete extraction of the exponents [no need to unbias]\r\n  explb+=GETECON(dfl);             // + continuation\r\n  exprb+=GETECON(dfr);             // ..\r\n\r\n  // calculate the number of digits to drop from the coefficient\r\n  drop=exprb-explb;                // 0 if nothing to do\r\n  if (drop==0) return decCanonical(result, dfl); // return canonical\r\n\r\n  // the coefficient is needed; lay it out into buf, offset so zeros\r\n  // can be added before or after as needed -- an extra heading is\r\n  // added so can safely pad Quad DECPMAX-1 zeros to the left by\r\n  // fours\r\n  #define BUFOFF (buf+4+DECPMAX)\r\n  GETCOEFF(dfl, BUFOFF);           // decode from decFloat\r\n  // [now the msd is at BUFOFF and the lsd is at BUFOFF+DECPMAX-1]\r\n\r\n  #if DECTRACE\r\n  num.msd=BUFOFF;\r\n  num.lsd=BUFOFF+DECPMAX-1;\r\n  num.exponent=explb-DECBIAS;\r\n  num.sign=sourhil & DECFLOAT_Sign;\r\n  decShowNum(&num, \"dfl\");\r\n  #endif\r\n\r\n  if (drop>0) {                         // [most common case]\r\n    // (this code is very similar to that in decFloatFinalize, but\r\n    // has many differences so is duplicated here -- so any changes\r\n    // may need to be made there, too)\r\n    uByte *roundat;                          // -> re-round digit\r\n    uByte reround;                           // reround value\r\n    // printf(\"Rounding; drop=%ld\\n\", (LI)drop);\r\n\r\n    // there is at least one zero needed to the left, in all but one\r\n    // exceptional (all-nines) case, so place four zeros now; this is\r\n    // needed almost always and makes rounding all-nines by fours safe\r\n    UBFROMUI(BUFOFF-4, 0);\r\n\r\n    // Three cases here:\r\n    //   1. new LSD is in coefficient (almost always)\r\n    //   2. new LSD is digit to left of coefficient (so MSD is\r\n    //      round-for-reround digit)\r\n    //   3. new LSD is to left of case 2 (whole coefficient is sticky)\r\n    // Note that leading zeros can safely be treated as useful digits\r\n\r\n    // [duplicate check-stickies code to save a test]\r\n    // [by-digit check for stickies as runs of zeros are rare]\r\n    if (drop<DECPMAX) {                      // NB lengths not addresses\r\n      roundat=BUFOFF+DECPMAX-drop;\r\n      reround=*roundat;\r\n      for (ub=roundat+1; ub<BUFOFF+DECPMAX; ub++) {\r\n        if (*ub!=0) {                        // non-zero to be discarded\r\n          reround=DECSTICKYTAB[reround];     // apply sticky bit\r\n          break;                             // [remainder don't-care]\r\n          }\r\n        } // check stickies\r\n      ulsd=roundat-1;                        // set LSD\r\n      }\r\n     else {                                  // edge case\r\n      if (drop==DECPMAX) {\r\n        roundat=BUFOFF;\r\n        reround=*roundat;\r\n        }\r\n       else {\r\n        roundat=BUFOFF-1;\r\n        reround=0;\r\n        }\r\n      for (ub=roundat+1; ub<BUFOFF+DECPMAX; ub++) {\r\n        if (*ub!=0) {                        // non-zero to be discarded\r\n          reround=DECSTICKYTAB[reround];     // apply sticky bit\r\n          break;                             // [remainder don't-care]\r\n          }\r\n        } // check stickies\r\n      *BUFOFF=0;                             // make a coefficient of 0\r\n      ulsd=BUFOFF;                           // .. at the MSD place\r\n      }\r\n\r\n    if (reround!=0) {                        // discarding non-zero\r\n      uInt bump=0;\r\n      set->status|=DEC_Inexact;\r\n\r\n      // next decide whether to increment the coefficient\r\n      if (set->round==DEC_ROUND_HALF_EVEN) { // fastpath slowest case\r\n        if (reround>5) bump=1;               // >0.5 goes up\r\n         else if (reround==5)                // exactly 0.5000 ..\r\n          bump=*ulsd & 0x01;                 // .. up iff [new] lsd is odd\r\n        } // r-h-e\r\n       else switch (set->round) {\r\n        case DEC_ROUND_DOWN: {\r\n          // no change\r\n          break;} // r-d\r\n        case DEC_ROUND_HALF_DOWN: {\r\n          if (reround>5) bump=1;\r\n          break;} // r-h-d\r\n        case DEC_ROUND_HALF_UP: {\r\n          if (reround>=5) bump=1;\r\n          break;} // r-h-u\r\n        case DEC_ROUND_UP: {\r\n          if (reround>0) bump=1;\r\n          break;} // r-u\r\n        case DEC_ROUND_CEILING: {\r\n          // same as _UP for positive numbers, and as _DOWN for negatives\r\n          if (!(sourhil&DECFLOAT_Sign) && reround>0) bump=1;\r\n          break;} // r-c\r\n        case DEC_ROUND_FLOOR: {\r\n          // same as _UP for negative numbers, and as _DOWN for positive\r\n          // [negative reround cannot occur on 0]\r\n          if (sourhil&DECFLOAT_Sign && reround>0) bump=1;\r\n          break;} // r-f\r\n        case DEC_ROUND_05UP: {\r\n          if (reround>0) { // anything out there is 'sticky'\r\n            // bump iff lsd=0 or 5; this cannot carry so it could be\r\n            // effected immediately with no bump -- but the code\r\n            // is clearer if this is done the same way as the others\r\n            if (*ulsd==0 || *ulsd==5) bump=1;\r\n            }\r\n          break;} // r-r\r\n        default: {      // e.g., DEC_ROUND_MAX\r\n          set->status|=DEC_Invalid_context;\r\n          #if DECCHECK\r\n          printf(\"Unknown rounding mode: %ld\\n\", (LI)set->round);\r\n          #endif\r\n          break;}\r\n        } // switch (not r-h-e)\r\n      // printf(\"ReRound: %ld  bump: %ld\\n\", (LI)reround, (LI)bump);\r\n\r\n      if (bump!=0) {                         // need increment\r\n        // increment the coefficient; this could give 1000... (after\r\n        // the all nines case)\r\n        ub=ulsd;\r\n        for (; UBTOUI(ub-3)==0x09090909; ub-=4) UBFROMUI(ub-3, 0);\r\n        // now at most 3 digits left to non-9 (usually just the one)\r\n        for (; *ub==9; ub--) *ub=0;\r\n        *ub+=1;\r\n        // [the all-nines case will have carried one digit to the\r\n        // left of the original MSD -- just where it is needed]\r\n        } // bump needed\r\n      } // inexact rounding\r\n\r\n    // now clear zeros to the left so exactly DECPMAX digits will be\r\n    // available in the coefficent -- the first word to the left was\r\n    // cleared earlier for safe carry; now add any more needed\r\n    if (drop>4) {\r\n      UBFROMUI(BUFOFF-8, 0);                 // must be at least 5\r\n      for (uc=BUFOFF-12; uc>ulsd-DECPMAX-3; uc-=4) UBFROMUI(uc, 0);\r\n      }\r\n    } // need round (drop>0)\r\n\r\n   else { // drop<0; padding with -drop digits is needed\r\n    // This is the case where an error can occur if the padded\r\n    // coefficient will not fit; checking for this can be done in the\r\n    // same loop as padding for zeros if the no-hope and zero cases\r\n    // are checked first\r\n    if (-drop>DECPMAX-1) {                   // cannot fit unless 0\r\n      if (!ISCOEFFZERO(BUFOFF)) return decInvalid(result, set);\r\n      // a zero can have any exponent; just drop through and use it\r\n      ulsd=BUFOFF+DECPMAX-1;\r\n      }\r\n     else { // padding will fit (but may still be too long)\r\n      // final-word mask depends on endianess\r\n      #if DECLITEND\r\n      static const uInt dmask[]={0, 0x000000ff, 0x0000ffff, 0x00ffffff};\r\n      #else\r\n      static const uInt dmask[]={0, 0xff000000, 0xffff0000, 0xffffff00};\r\n      #endif\r\n      // note that here zeros to the right are added by fours, so in\r\n      // the Quad case this could write 36 zeros if the coefficient has\r\n      // fewer than three significant digits (hence the +2*QUAD for buf)\r\n      for (uc=BUFOFF+DECPMAX;; uc+=4) {\r\n        UBFROMUI(uc, 0);\r\n        if (UBTOUI(uc-DECPMAX)!=0) {              // could be bad\r\n          // if all four digits should be zero, definitely bad\r\n          if (uc<=BUFOFF+DECPMAX+(-drop)-4)\r\n            return decInvalid(result, set);\r\n          // must be a 1- to 3-digit sequence; check more carefully\r\n          if ((UBTOUI(uc-DECPMAX)&dmask[(-drop)%4])!=0)\r\n            return decInvalid(result, set);\r\n          break;    // no need for loop end test\r\n          }\r\n        if (uc>=BUFOFF+DECPMAX+(-drop)-4) break;  // done\r\n        }\r\n      ulsd=BUFOFF+DECPMAX+(-drop)-1;\r\n      } // pad and check leading zeros\r\n    } // drop<0\r\n\r\n  #if DECTRACE\r\n  num.msd=ulsd-DECPMAX+1;\r\n  num.lsd=ulsd;\r\n  num.exponent=explb-DECBIAS;\r\n  num.sign=sourhil & DECFLOAT_Sign;\r\n  decShowNum(&num, \"res\");\r\n  #endif\r\n\r\n  /*------------------------------------------------------------------*/\r\n  /* At this point the result is DECPMAX digits, ending at ulsd, so   */\r\n  /* fits the encoding exactly; there is no possibility of error      */\r\n  /*------------------------------------------------------------------*/\r\n  encode=((exprb>>DECECONL)<<4) + *(ulsd-DECPMAX+1); // make index\r\n  encode=DECCOMBFROM[encode];                // indexed by (0-2)*16+msd\r\n  // the exponent continuation can be extracted from the original RHS\r\n  encode|=sourhir & ECONMASK;\r\n  encode|=sourhil&DECFLOAT_Sign;             // add the sign from LHS\r\n\r\n  // finally encode the coefficient\r\n  // private macro to encode a declet; this version can be used\r\n  // because all coefficient digits exist\r\n  #define getDPD3q(dpd, n) ub=ulsd-(3*(n))-2;                   \\\r\n    dpd=BCD2DPD[(*ub*256)+(*(ub+1)*16)+*(ub+2)];\r\n\r\n  #if DOUBLE\r\n    getDPD3q(dpd, 4); encode|=dpd<<8;\r\n    getDPD3q(dpd, 3); encode|=dpd>>2;\r\n    DFWORD(result, 0)=encode;\r\n    encode=dpd<<30;\r\n    getDPD3q(dpd, 2); encode|=dpd<<20;\r\n    getDPD3q(dpd, 1); encode|=dpd<<10;\r\n    getDPD3q(dpd, 0); encode|=dpd;\r\n    DFWORD(result, 1)=encode;\r\n\r\n  #elif QUAD\r\n    getDPD3q(dpd,10); encode|=dpd<<4;\r\n    getDPD3q(dpd, 9); encode|=dpd>>6;\r\n    DFWORD(result, 0)=encode;\r\n    encode=dpd<<26;\r\n    getDPD3q(dpd, 8); encode|=dpd<<16;\r\n    getDPD3q(dpd, 7); encode|=dpd<<6;\r\n    getDPD3q(dpd, 6); encode|=dpd>>4;\r\n    DFWORD(result, 1)=encode;\r\n    encode=dpd<<28;\r\n    getDPD3q(dpd, 5); encode|=dpd<<18;\r\n    getDPD3q(dpd, 4); encode|=dpd<<8;\r\n    getDPD3q(dpd, 3); encode|=dpd>>2;\r\n    DFWORD(result, 2)=encode;\r\n    encode=dpd<<30;\r\n    getDPD3q(dpd, 2); encode|=dpd<<20;\r\n    getDPD3q(dpd, 1); encode|=dpd<<10;\r\n    getDPD3q(dpd, 0); encode|=dpd;\r\n    DFWORD(result, 3)=encode;\r\n  #endif\r\n  return result;\r\n  } // decFloatQuantize\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatReduce -- reduce finite coefficient to minimum length      */\r\n/*                                                                    */\r\n/*   result gets the reduced decFloat                                 */\r\n/*   df     is the source decFloat                                    */\r\n/*   set    is the context                                            */\r\n/*   returns result, which will be canonical                          */\r\n/*                                                                    */\r\n/* This removes all possible trailing zeros from the coefficient;     */\r\n/* some may remain when the number is very close to Nmax.             */\r\n/* Special values are unchanged and no status is set unless df=sNaN.  */\r\n/* Reduced zero has an exponent q=0.                                  */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatReduce(decFloat *result, const decFloat *df,\r\n                          decContext *set) {\r\n  bcdnum num;                           // work\r\n  uByte buf[DECPMAX], *ub;              // coefficient and pointer\r\n  if (df!=result) *result=*df;          // copy, if needed\r\n  if (DFISNAN(df)) return decNaNs(result, df, NULL, set);   // sNaN\r\n  // zeros and infinites propagate too\r\n  if (DFISINF(df)) return decInfinity(result, df);     // canonical\r\n  if (DFISZERO(df)) {\r\n    uInt sign=DFWORD(df, 0)&DECFLOAT_Sign;\r\n    decFloatZero(result);\r\n    DFWORD(result, 0)|=sign;\r\n    return result;                      // exponent dropped, sign OK\r\n    }\r\n  // non-zero finite\r\n  GETCOEFF(df, buf);\r\n  ub=buf+DECPMAX-1;                     // -> lsd\r\n  if (*ub) return result;               // no trailing zeros\r\n  for (ub--; *ub==0;) ub--;             // terminates because non-zero\r\n  // *ub is the first non-zero from the right\r\n  num.sign=DFWORD(df, 0)&DECFLOAT_Sign; // set up number...\r\n  num.exponent=GETEXPUN(df)+(Int)(buf+DECPMAX-1-ub); // adjusted exponent\r\n  num.msd=buf;\r\n  num.lsd=ub;\r\n  return decFinalize(result, &num, set);\r\n  } // decFloatReduce\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatRemainder -- integer divide and return remainder           */\r\n/*                                                                    */\r\n/*   result gets the remainder of dividing dfl by dfr:                */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatRemainder(decFloat *result,\r\n                             const decFloat *dfl, const decFloat *dfr,\r\n                             decContext *set) {\r\n  return decDivide(result, dfl, dfr, set, REMAINDER);\r\n  } // decFloatRemainder\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatRemainderNear -- integer divide to nearest and remainder   */\r\n/*                                                                    */\r\n/*   result gets the remainder of dividing dfl by dfr:                */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This is the IEEE remainder, where the nearest integer is used.     */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatRemainderNear(decFloat *result,\r\n                             const decFloat *dfl, const decFloat *dfr,\r\n                             decContext *set) {\r\n  return decDivide(result, dfl, dfr, set, REMNEAR);\r\n  } // decFloatRemainderNear\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatRotate -- rotate the coefficient of a decFloat left/right  */\r\n/*                                                                    */\r\n/*   result gets the result of rotating dfl                           */\r\n/*   dfl    is the source decFloat to rotate                          */\r\n/*   dfr    is the count of digits to rotate, an integer (with q=0)   */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* The digits of the coefficient of dfl are rotated to the left (if   */\r\n/* dfr is positive) or to the right (if dfr is negative) without      */\r\n/* adjusting the exponent or the sign of dfl.                         */\r\n/*                                                                    */\r\n/* dfr must be in the range -DECPMAX through +DECPMAX.                */\r\n/* NaNs are propagated as usual.  An infinite dfl is unaffected (but  */\r\n/* dfr must be valid).  No status is set unless dfr is invalid or an  */\r\n/* operand is an sNaN.  The result is canonical.                      */\r\n/* ------------------------------------------------------------------ */\r\n#define PHALF (ROUNDUP(DECPMAX/2, 4))   // half length, rounded up\r\ndecFloat * decFloatRotate(decFloat *result,\r\n                         const decFloat *dfl, const decFloat *dfr,\r\n                         decContext *set) {\r\n  Int rotate;                           // dfr as an Int\r\n  uByte buf[DECPMAX+PHALF];             // coefficient + half\r\n  uInt digits, savestat;                // work\r\n  bcdnum num;                           // ..\r\n  uByte *ub;                            // ..\r\n\r\n  if (DFISNAN(dfl)||DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n  if (!DFISINT(dfr)) return decInvalid(result, set);\r\n  digits=decFloatDigits(dfr);                    // calculate digits\r\n  if (digits>2) return decInvalid(result, set);  // definitely out of range\r\n  rotate=DPD2BIN[DFWORD(dfr, DECWORDS-1)&0x3ff]; // is in bottom declet\r\n  if (rotate>DECPMAX) return decInvalid(result, set); // too big\r\n  // [from here on no error or status change is possible]\r\n  if (DFISINF(dfl)) return decInfinity(result, dfl);  // canonical\r\n  // handle no-rotate cases\r\n  if (rotate==0 || rotate==DECPMAX) return decCanonical(result, dfl);\r\n  // a real rotate is needed: 0 < rotate < DECPMAX\r\n  // reduce the rotation to no more than half to reduce copying later\r\n  // (for QUAD in fact half + 2 digits)\r\n  if (DFISSIGNED(dfr)) rotate=-rotate;\r\n  if (abs(rotate)>PHALF) {\r\n    if (rotate<0) rotate=DECPMAX+rotate;\r\n     else rotate=rotate-DECPMAX;\r\n    }\r\n  // now lay out the coefficient, leaving room to the right or the\r\n  // left depending on the direction of rotation\r\n  ub=buf;\r\n  if (rotate<0) ub+=PHALF;    // rotate right, so space to left\r\n  GETCOEFF(dfl, ub);\r\n  // copy half the digits to left or right, and set num.msd\r\n  if (rotate<0) {\r\n    memcpy(buf, buf+DECPMAX, PHALF);\r\n    num.msd=buf+PHALF+rotate;\r\n    }\r\n   else {\r\n    memcpy(buf+DECPMAX, buf, PHALF);\r\n    num.msd=buf+rotate;\r\n    }\r\n  // fill in rest of num\r\n  num.lsd=num.msd+DECPMAX-1;\r\n  num.sign=DFWORD(dfl, 0)&DECFLOAT_Sign;\r\n  num.exponent=GETEXPUN(dfl);\r\n  savestat=set->status;                 // record\r\n  decFinalize(result, &num, set);\r\n  set->status=savestat;                 // restore\r\n  return result;\r\n  } // decFloatRotate\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatSameQuantum -- test decFloats for same quantum             */\r\n/*                                                                    */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   returns 1 if the operands have the same quantum, 0 otherwise     */\r\n/*                                                                    */\r\n/* No error is possible and no status results.                        */\r\n/* ------------------------------------------------------------------ */\r\nuInt decFloatSameQuantum(const decFloat *dfl, const decFloat *dfr) {\r\n  if (DFISSPECIAL(dfl) || DFISSPECIAL(dfr)) {\r\n    if (DFISNAN(dfl) && DFISNAN(dfr)) return 1;\r\n    if (DFISINF(dfl) && DFISINF(dfr)) return 1;\r\n    return 0;  // any other special mixture gives false\r\n    }\r\n  if (GETEXP(dfl)==GETEXP(dfr)) return 1; // biased exponents match\r\n  return 0;\r\n  } // decFloatSameQuantum\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatScaleB -- multiply by a power of 10, as per 754            */\r\n/*                                                                    */\r\n/*   result gets the result of the operation                          */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs), am integer (with q=0)       */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* This computes result=dfl x 10**dfr where dfr is an integer in the  */\r\n/* range +/-2*(emax+pmax), typically resulting from LogB.             */\r\n/* Underflow and Overflow (with Inexact) may occur.  NaNs propagate   */\r\n/* as usual.                                                          */\r\n/* ------------------------------------------------------------------ */\r\n#define SCALEBMAX 2*(DECEMAX+DECPMAX)   // D=800, Q=12356\r\ndecFloat * decFloatScaleB(decFloat *result,\r\n                          const decFloat *dfl, const decFloat *dfr,\r\n                          decContext *set) {\r\n  uInt digits;                          // work\r\n  Int  expr;                            // dfr as an Int\r\n\r\n  if (DFISNAN(dfl)||DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n  if (!DFISINT(dfr)) return decInvalid(result, set);\r\n  digits=decFloatDigits(dfr);                // calculate digits\r\n\r\n  #if DOUBLE\r\n  if (digits>3) return decInvalid(result, set);   // definitely out of range\r\n  expr=DPD2BIN[DFWORD(dfr, 1)&0x3ff];             // must be in bottom declet\r\n  #elif QUAD\r\n  if (digits>5) return decInvalid(result, set);   // definitely out of range\r\n  expr=DPD2BIN[DFWORD(dfr, 3)&0x3ff]              // in bottom 2 declets ..\r\n      +DPD2BIN[(DFWORD(dfr, 3)>>10)&0x3ff]*1000;  // ..\r\n  #endif\r\n  if (expr>SCALEBMAX) return decInvalid(result, set);  // oops\r\n  // [from now on no error possible]\r\n  if (DFISINF(dfl)) return decInfinity(result, dfl);   // canonical\r\n  if (DFISSIGNED(dfr)) expr=-expr;\r\n  // dfl is finite and expr is valid\r\n  *result=*dfl;                              // copy to target\r\n  return decFloatSetExponent(result, set, GETEXPUN(result)+expr);\r\n  } // decFloatScaleB\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatShift -- shift the coefficient of a decFloat left or right */\r\n/*                                                                    */\r\n/*   result gets the result of shifting dfl                           */\r\n/*   dfl    is the source decFloat to shift                           */\r\n/*   dfr    is the count of digits to shift, an integer (with q=0)    */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* The digits of the coefficient of dfl are shifted to the left (if   */\r\n/* dfr is positive) or to the right (if dfr is negative) without      */\r\n/* adjusting the exponent or the sign of dfl.                         */\r\n/*                                                                    */\r\n/* dfr must be in the range -DECPMAX through +DECPMAX.                */\r\n/* NaNs are propagated as usual.  An infinite dfl is unaffected (but  */\r\n/* dfr must be valid).  No status is set unless dfr is invalid or an  */\r\n/* operand is an sNaN.  The result is canonical.                      */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatShift(decFloat *result,\r\n                         const decFloat *dfl, const decFloat *dfr,\r\n                         decContext *set) {\r\n  Int    shift;                         // dfr as an Int\r\n  uByte  buf[DECPMAX*2];                // coefficient + padding\r\n  uInt   digits, savestat;              // work\r\n  bcdnum num;                           // ..\r\n  uInt   uiwork;                        // for macros\r\n\r\n  if (DFISNAN(dfl)||DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set);\r\n  if (!DFISINT(dfr)) return decInvalid(result, set);\r\n  digits=decFloatDigits(dfr);                     // calculate digits\r\n  if (digits>2) return decInvalid(result, set);   // definitely out of range\r\n  shift=DPD2BIN[DFWORD(dfr, DECWORDS-1)&0x3ff];   // is in bottom declet\r\n  if (shift>DECPMAX) return decInvalid(result, set);   // too big\r\n  // [from here on no error or status change is possible]\r\n\r\n  if (DFISINF(dfl)) return decInfinity(result, dfl); // canonical\r\n  // handle no-shift and all-shift (clear to zero) cases\r\n  if (shift==0) return decCanonical(result, dfl);\r\n  if (shift==DECPMAX) {                      // zero with sign\r\n    uByte sign=(uByte)(DFBYTE(dfl, 0)&0x80); // save sign bit\r\n    decFloatZero(result);                    // make +0\r\n    DFBYTE(result, 0)=(uByte)(DFBYTE(result, 0)|sign); // and set sign\r\n    // [cannot safely use CopySign]\r\n    return result;\r\n    }\r\n  // a real shift is needed: 0 < shift < DECPMAX\r\n  num.sign=DFWORD(dfl, 0)&DECFLOAT_Sign;\r\n  num.exponent=GETEXPUN(dfl);\r\n  num.msd=buf;\r\n  GETCOEFF(dfl, buf);\r\n  if (DFISSIGNED(dfr)) { // shift right\r\n    // edge cases are taken care of, so this is easy\r\n    num.lsd=buf+DECPMAX-shift-1;\r\n    }\r\n   else { // shift left -- zero padding needed to right\r\n    UBFROMUI(buf+DECPMAX, 0);           // 8 will handle most cases\r\n    UBFROMUI(buf+DECPMAX+4, 0);         // ..\r\n    if (shift>8) memset(buf+DECPMAX+8, 0, 8+QUAD*18); // all other cases\r\n    num.msd+=shift;\r\n    num.lsd=num.msd+DECPMAX-1;\r\n    }\r\n  savestat=set->status;                 // record\r\n  decFinalize(result, &num, set);\r\n  set->status=savestat;                 // restore\r\n  return result;\r\n  } // decFloatShift\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatSubtract -- subtract a decFloat from another               */\r\n/*                                                                    */\r\n/*   result gets the result of subtracting dfr from dfl:              */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatSubtract(decFloat *result,\r\n                            const decFloat *dfl, const decFloat *dfr,\r\n                            decContext *set) {\r\n  decFloat temp;\r\n  // NaNs must propagate without sign change\r\n  if (DFISNAN(dfr)) return decFloatAdd(result, dfl, dfr, set);\r\n  temp=*dfr;                                   // make a copy\r\n  DFBYTE(&temp, 0)^=0x80;                      // flip sign\r\n  return decFloatAdd(result, dfl, &temp, set); // and add to the lhs\r\n  } // decFloatSubtract\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatToInt -- round to 32-bit binary integer (4 flavours)       */\r\n/*                                                                    */\r\n/*   df    is the decFloat to round                                   */\r\n/*   set   is the context                                             */\r\n/*   round is the rounding mode to use                                */\r\n/*   returns a uInt or an Int, rounded according to the name          */\r\n/*                                                                    */\r\n/* Invalid will always be signaled if df is a NaN, is Infinite, or is */\r\n/* outside the range of the target; Inexact will not be signaled for  */\r\n/* simple rounding unless 'Exact' appears in the name.                */\r\n/* ------------------------------------------------------------------ */\r\nuInt decFloatToUInt32(const decFloat *df, decContext *set,\r\n                      enum rounding round) {\r\n  return decToInt32(df, set, round, 0, 1);}\r\n\r\nuInt decFloatToUInt32Exact(const decFloat *df, decContext *set,\r\n                           enum rounding round) {\r\n  return decToInt32(df, set, round, 1, 1);}\r\n\r\nInt decFloatToInt32(const decFloat *df, decContext *set,\r\n                    enum rounding round) {\r\n  return (Int)decToInt32(df, set, round, 0, 0);}\r\n\r\nInt decFloatToInt32Exact(const decFloat *df, decContext *set,\r\n                         enum rounding round) {\r\n  return (Int)decToInt32(df, set, round, 1, 0);}\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatToIntegral -- round to integral value (two flavours)       */\r\n/*                                                                    */\r\n/*   result gets the result                                           */\r\n/*   df     is the decFloat to round                                  */\r\n/*   set    is the context                                            */\r\n/*   round  is the rounding mode to use                               */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* No exceptions, even Inexact, are raised except for sNaN input, or  */\r\n/* if 'Exact' appears in the name.                                    */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatToIntegralValue(decFloat *result, const decFloat *df,\r\n                                   decContext *set, enum rounding round) {\r\n  return decToIntegral(result, df, set, round, 0);}\r\n\r\ndecFloat * decFloatToIntegralExact(decFloat *result, const decFloat *df,\r\n                                   decContext *set) {\r\n  return decToIntegral(result, df, set, set->round, 1);}\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatXor -- logical digitwise XOR of two decFloats              */\r\n/*                                                                    */\r\n/*   result gets the result of XORing dfl and dfr                     */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs)                              */\r\n/*   set    is the context                                            */\r\n/*   returns result, which will be canonical with sign=0              */\r\n/*                                                                    */\r\n/* The operands must be positive, finite with exponent q=0, and       */\r\n/* comprise just zeros and ones; if not, Invalid operation results.   */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatXor(decFloat *result,\r\n                       const decFloat *dfl, const decFloat *dfr,\r\n                       decContext *set) {\r\n  if (!DFISUINT01(dfl) || !DFISUINT01(dfr)\r\n   || !DFISCC01(dfl)   || !DFISCC01(dfr)) return decInvalid(result, set);\r\n  // the operands are positive finite integers (q=0) with just 0s and 1s\r\n  #if DOUBLE\r\n   DFWORD(result, 0)=ZEROWORD\r\n                   |((DFWORD(dfl, 0) ^ DFWORD(dfr, 0))&0x04009124);\r\n   DFWORD(result, 1)=(DFWORD(dfl, 1) ^ DFWORD(dfr, 1))&0x49124491;\r\n  #elif QUAD\r\n   DFWORD(result, 0)=ZEROWORD\r\n                   |((DFWORD(dfl, 0) ^ DFWORD(dfr, 0))&0x04000912);\r\n   DFWORD(result, 1)=(DFWORD(dfl, 1) ^ DFWORD(dfr, 1))&0x44912449;\r\n   DFWORD(result, 2)=(DFWORD(dfl, 2) ^ DFWORD(dfr, 2))&0x12449124;\r\n   DFWORD(result, 3)=(DFWORD(dfl, 3) ^ DFWORD(dfr, 3))&0x49124491;\r\n  #endif\r\n  return result;\r\n  } // decFloatXor\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decInvalid -- set Invalid_operation result                         */\r\n/*                                                                    */\r\n/*   result gets a canonical NaN                                      */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* status has Invalid_operation added                                 */\r\n/* ------------------------------------------------------------------ */\r\nstatic decFloat *decInvalid(decFloat *result, decContext *set) {\r\n  decFloatZero(result);\r\n  DFWORD(result, 0)=DECFLOAT_qNaN;\r\n  set->status|=DEC_Invalid_operation;\r\n  return result;\r\n  } // decInvalid\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decInfinity -- set canonical Infinity with sign from a decFloat    */\r\n/*                                                                    */\r\n/*   result gets a canonical Infinity                                 */\r\n/*   df     is source decFloat (only the sign is used)                */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* df may be the same as result                                       */\r\n/* ------------------------------------------------------------------ */\r\nstatic decFloat *decInfinity(decFloat *result, const decFloat *df) {\r\n  uInt sign=DFWORD(df, 0);         // save source signword\r\n  decFloatZero(result);            // clear everything\r\n  DFWORD(result, 0)=DECFLOAT_Inf | (sign & DECFLOAT_Sign);\r\n  return result;\r\n  } // decInfinity\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNaNs -- handle NaN argument(s)                                  */\r\n/*                                                                    */\r\n/*   result gets the result of handling dfl and dfr, one or both of   */\r\n/*          which is a NaN                                            */\r\n/*   dfl    is the first decFloat (lhs)                               */\r\n/*   dfr    is the second decFloat (rhs) -- may be NULL for a single- */\r\n/*          operand operation                                         */\r\n/*   set    is the context                                            */\r\n/*   returns result                                                   */\r\n/*                                                                    */\r\n/* Called when one or both operands is a NaN, and propagates the      */\r\n/* appropriate result to res.  When an sNaN is found, it is changed   */\r\n/* to a qNaN and Invalid operation is set.                            */\r\n/* ------------------------------------------------------------------ */\r\nstatic decFloat *decNaNs(decFloat *result,\r\n                         const decFloat *dfl, const decFloat *dfr,\r\n                         decContext *set) {\r\n  // handle sNaNs first\r\n  if (dfr!=NULL && DFISSNAN(dfr) && !DFISSNAN(dfl)) dfl=dfr; // use RHS\r\n  if (DFISSNAN(dfl)) {\r\n    decCanonical(result, dfl);          // propagate canonical sNaN\r\n    DFWORD(result, 0)&=~(DECFLOAT_qNaN ^ DECFLOAT_sNaN); // quiet\r\n    set->status|=DEC_Invalid_operation;\r\n    return result;\r\n    }\r\n  // one or both is a quiet NaN\r\n  if (!DFISNAN(dfl)) dfl=dfr;           // RHS must be NaN, use it\r\n  return decCanonical(result, dfl);     // propagate canonical qNaN\r\n  } // decNaNs\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumCompare -- numeric comparison of two decFloats               */\r\n/*                                                                    */\r\n/*   dfl    is the left-hand decFloat, which is not a NaN             */\r\n/*   dfr    is the right-hand decFloat, which is not a NaN            */\r\n/*   tot    is 1 for total order compare, 0 for simple numeric        */\r\n/*   returns -1, 0, or +1 for dfl<dfr, dfl=dfr, dfl>dfr               */\r\n/*                                                                    */\r\n/* No error is possible; status and mode are unchanged.               */\r\n/* ------------------------------------------------------------------ */\r\nstatic Int decNumCompare(const decFloat *dfl, const decFloat *dfr, Flag tot) {\r\n  Int   sigl, sigr;                     // LHS and RHS non-0 signums\r\n  Int   shift;                          // shift needed to align operands\r\n  uByte *ub, *uc;                       // work\r\n  uInt  uiwork;                         // for macros\r\n  // buffers +2 if Quad (36 digits), need double plus 4 for safe padding\r\n  uByte bufl[DECPMAX*2+QUAD*2+4];       // for LHS coefficient + padding\r\n  uByte bufr[DECPMAX*2+QUAD*2+4];       // for RHS coefficient + padding\r\n\r\n  sigl=1;\r\n  if (DFISSIGNED(dfl)) {\r\n    if (!DFISSIGNED(dfr)) {             // -LHS +RHS\r\n      if (DFISZERO(dfl) && DFISZERO(dfr) && !tot) return 0;\r\n      return -1;                        // RHS wins\r\n      }\r\n    sigl=-1;\r\n    }\r\n  if (DFISSIGNED(dfr)) {\r\n    if (!DFISSIGNED(dfl)) {             // +LHS -RHS\r\n      if (DFISZERO(dfl) && DFISZERO(dfr) && !tot) return 0;\r\n      return +1;                        // LHS wins\r\n      }\r\n    }\r\n\r\n  // signs are the same; operand(s) could be zero\r\n  sigr=-sigl;                           // sign to return if abs(RHS) wins\r\n\r\n  if (DFISINF(dfl)) {\r\n    if (DFISINF(dfr)) return 0;         // both infinite & same sign\r\n    return sigl;                        // inf > n\r\n    }\r\n  if (DFISINF(dfr)) return sigr;        // n < inf [dfl is finite]\r\n\r\n  // here, both are same sign and finite; calculate their offset\r\n  shift=GETEXP(dfl)-GETEXP(dfr);        // [0 means aligned]\r\n  // [bias can be ignored -- the absolute exponent is not relevant]\r\n\r\n  if (DFISZERO(dfl)) {\r\n    if (!DFISZERO(dfr)) return sigr;    // LHS=0, RHS!=0\r\n    // both are zero, return 0 if both same exponent or numeric compare\r\n    if (shift==0 || !tot) return 0;\r\n    if (shift>0) return sigl;\r\n    return sigr;                        // [shift<0]\r\n    }\r\n   else {                               // LHS!=0\r\n    if (DFISZERO(dfr)) return sigl;     // LHS!=0, RHS=0\r\n    }\r\n  // both are known to be non-zero at this point\r\n\r\n  // if the exponents are so different that the coefficients do not\r\n  // overlap (by even one digit) then a full comparison is not needed\r\n  if (abs(shift)>=DECPMAX) {            // no overlap\r\n    // coefficients are known to be non-zero\r\n    if (shift>0) return sigl;\r\n    return sigr;                        // [shift<0]\r\n    }\r\n\r\n  // decode the coefficients\r\n  // (shift both right two if Quad to make a multiple of four)\r\n  #if QUAD\r\n    UBFROMUI(bufl, 0);\r\n    UBFROMUI(bufr, 0);\r\n  #endif\r\n  GETCOEFF(dfl, bufl+QUAD*2);           // decode from decFloat\r\n  GETCOEFF(dfr, bufr+QUAD*2);           // ..\r\n  if (shift==0) {                       // aligned; common and easy\r\n    // all multiples of four, here\r\n    for (ub=bufl, uc=bufr; ub<bufl+DECPMAX+QUAD*2; ub+=4, uc+=4) {\r\n      uInt ui=UBTOUI(ub);\r\n      if (ui==UBTOUI(uc)) continue;     // so far so same\r\n      // about to find a winner; go by bytes in case little-endian\r\n      for (;; ub++, uc++) {\r\n        if (*ub>*uc) return sigl;       // difference found\r\n        if (*ub<*uc) return sigr;       // ..\r\n        }\r\n      }\r\n    } // aligned\r\n   else if (shift>0) {                  // lhs to left\r\n    ub=bufl;                            // RHS pointer\r\n    // pad bufl so right-aligned; most shifts will fit in 8\r\n    UBFROMUI(bufl+DECPMAX+QUAD*2, 0);   // add eight zeros\r\n    UBFROMUI(bufl+DECPMAX+QUAD*2+4, 0); // ..\r\n    if (shift>8) {\r\n      // more than eight; fill the rest, and also worth doing the\r\n      // lead-in by fours\r\n      uByte *up;                        // work\r\n      uByte *upend=bufl+DECPMAX+QUAD*2+shift;\r\n      for (up=bufl+DECPMAX+QUAD*2+8; up<upend; up+=4) UBFROMUI(up, 0);\r\n      // [pads up to 36 in all for Quad]\r\n      for (;; ub+=4) {\r\n        if (UBTOUI(ub)!=0) return sigl;\r\n        if (ub+4>bufl+shift-4) break;\r\n        }\r\n      }\r\n    // check remaining leading digits\r\n    for (; ub<bufl+shift; ub++) if (*ub!=0) return sigl;\r\n    // now start the overlapped part; bufl has been padded, so the\r\n    // comparison can go for the full length of bufr, which is a\r\n    // multiple of 4 bytes\r\n    for (uc=bufr; ; uc+=4, ub+=4) {\r\n      uInt ui=UBTOUI(ub);\r\n      if (ui!=UBTOUI(uc)) {             // mismatch found\r\n        for (;; uc++, ub++) {           // check from left [little-endian?]\r\n          if (*ub>*uc) return sigl;     // difference found\r\n          if (*ub<*uc) return sigr;     // ..\r\n          }\r\n        } // mismatch\r\n      if (uc==bufr+QUAD*2+DECPMAX-4) break; // all checked\r\n      }\r\n    } // shift>0\r\n\r\n   else { // shift<0) .. RHS is to left of LHS; mirror shift>0\r\n    uc=bufr;                            // RHS pointer\r\n    // pad bufr so right-aligned; most shifts will fit in 8\r\n    UBFROMUI(bufr+DECPMAX+QUAD*2, 0);   // add eight zeros\r\n    UBFROMUI(bufr+DECPMAX+QUAD*2+4, 0); // ..\r\n    if (shift<-8) {\r\n      // more than eight; fill the rest, and also worth doing the\r\n      // lead-in by fours\r\n      uByte *up;                        // work\r\n      uByte *upend=bufr+DECPMAX+QUAD*2-shift;\r\n      for (up=bufr+DECPMAX+QUAD*2+8; up<upend; up+=4) UBFROMUI(up, 0);\r\n      // [pads up to 36 in all for Quad]\r\n      for (;; uc+=4) {\r\n        if (UBTOUI(uc)!=0) return sigr;\r\n        if (uc+4>bufr-shift-4) break;\r\n        }\r\n      }\r\n    // check remaining leading digits\r\n    for (; uc<bufr-shift; uc++) if (*uc!=0) return sigr;\r\n    // now start the overlapped part; bufr has been padded, so the\r\n    // comparison can go for the full length of bufl, which is a\r\n    // multiple of 4 bytes\r\n    for (ub=bufl; ; ub+=4, uc+=4) {\r\n      uInt ui=UBTOUI(ub);\r\n      if (ui!=UBTOUI(uc)) {             // mismatch found\r\n        for (;; ub++, uc++) {           // check from left [little-endian?]\r\n          if (*ub>*uc) return sigl;     // difference found\r\n          if (*ub<*uc) return sigr;     // ..\r\n          }\r\n        } // mismatch\r\n      if (ub==bufl+QUAD*2+DECPMAX-4) break; // all checked\r\n      }\r\n    } // shift<0\r\n\r\n  // Here when compare equal\r\n  if (!tot) return 0;                   // numerically equal\r\n  // total ordering .. exponent matters\r\n  if (shift>0) return sigl;             // total order by exponent\r\n  if (shift<0) return sigr;             // ..\r\n  return 0;\r\n  } // decNumCompare\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decToInt32 -- local routine to effect ToInteger conversions        */\r\n/*                                                                    */\r\n/*   df     is the decFloat to convert                                */\r\n/*   set    is the context                                            */\r\n/*   rmode  is the rounding mode to use                               */\r\n/*   exact  is 1 if Inexact should be signalled                       */\r\n/*   unsign is 1 if the result a uInt, 0 if an Int (cast to uInt)     */\r\n/*   returns 32-bit result as a uInt                                  */\r\n/*                                                                    */\r\n/* Invalid is set is df is a NaN, is infinite, or is out-of-range; in */\r\n/* these cases 0 is returned.                                         */\r\n/* ------------------------------------------------------------------ */\r\nstatic uInt decToInt32(const decFloat *df, decContext *set,\r\n                       enum rounding rmode, Flag exact, Flag unsign) {\r\n  Int  exp;                        // exponent\r\n  uInt sourhi, sourpen, sourlo;    // top word from source decFloat ..\r\n  uInt hi, lo;                     // .. penultimate, least, etc.\r\n  decFloat zero, result;           // work\r\n  Int  i;                          // ..\r\n\r\n  /* Start decoding the argument */\r\n  sourhi=DFWORD(df, 0);                 // top word\r\n  exp=DECCOMBEXP[sourhi>>26];           // get exponent high bits (in place)\r\n  if (EXPISSPECIAL(exp)) {              // is special?\r\n    set->status|=DEC_Invalid_operation; // signal\r\n    return 0;\r\n    }\r\n\r\n  /* Here when the argument is finite */\r\n  if (GETEXPUN(df)==0) result=*df;      // already a true integer\r\n   else {                               // need to round to integer\r\n    enum rounding saveround;            // saver\r\n    uInt savestatus;                    // ..\r\n    saveround=set->round;               // save rounding mode ..\r\n    savestatus=set->status;             // .. and status\r\n    set->round=rmode;                   // set mode\r\n    decFloatZero(&zero);                // make 0E+0\r\n    set->status=0;                      // clear\r\n    decFloatQuantize(&result, df, &zero, set); // [this may fail]\r\n    set->round=saveround;               // restore rounding mode ..\r\n    if (exact) set->status|=savestatus; // include Inexact\r\n     else set->status=savestatus;       // .. or just original status\r\n    }\r\n\r\n  // only the last four declets of the coefficient can contain\r\n  // non-zero; check for others (and also NaN or Infinity from the\r\n  // Quantize) first (see DFISZERO for explanation):\r\n  // decFloatShow(&result, \"sofar\");\r\n  #if DOUBLE\r\n  if ((DFWORD(&result, 0)&0x1c03ff00)!=0\r\n   || (DFWORD(&result, 0)&0x60000000)==0x60000000) {\r\n  #elif QUAD\r\n  if ((DFWORD(&result, 2)&0xffffff00)!=0\r\n   ||  DFWORD(&result, 1)!=0\r\n   || (DFWORD(&result, 0)&0x1c003fff)!=0\r\n   || (DFWORD(&result, 0)&0x60000000)==0x60000000) {\r\n  #endif\r\n    set->status|=DEC_Invalid_operation; // Invalid or out of range\r\n    return 0;\r\n    }\r\n  // get last twelve digits of the coefficent into hi & ho, base\r\n  // 10**9 (see GETCOEFFBILL):\r\n  sourlo=DFWORD(&result, DECWORDS-1);\r\n  lo=DPD2BIN0[sourlo&0x3ff]\r\n    +DPD2BINK[(sourlo>>10)&0x3ff]\r\n    +DPD2BINM[(sourlo>>20)&0x3ff];\r\n  sourpen=DFWORD(&result, DECWORDS-2);\r\n  hi=DPD2BIN0[((sourpen<<2) | (sourlo>>30))&0x3ff];\r\n\r\n  // according to request, check range carefully\r\n  if (unsign) {\r\n    if (hi>4 || (hi==4 && lo>294967295) || (hi+lo!=0 && DFISSIGNED(&result))) {\r\n      set->status|=DEC_Invalid_operation; // out of range\r\n      return 0;\r\n      }\r\n    return hi*BILLION+lo;\r\n    }\r\n  // signed\r\n  if (hi>2 || (hi==2 && lo>147483647)) {\r\n    // handle the usual edge case\r\n    if (lo==147483648 && hi==2 && DFISSIGNED(&result)) return 0x80000000;\r\n    set->status|=DEC_Invalid_operation; // truly out of range\r\n    return 0;\r\n    }\r\n  i=hi*BILLION+lo;\r\n  if (DFISSIGNED(&result)) i=-i;\r\n  return (uInt)i;\r\n  } // decToInt32\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decToIntegral -- local routine to effect ToIntegral value          */\r\n/*                                                                    */\r\n/*   result gets the result                                           */\r\n/*   df     is the decFloat to round                                  */\r\n/*   set    is the context                                            */\r\n/*   rmode  is the rounding mode to use                               */\r\n/*   exact  is 1 if Inexact should be signalled                       */\r\n/*   returns result                                                   */\r\n/* ------------------------------------------------------------------ */\r\nstatic decFloat * decToIntegral(decFloat *result, const decFloat *df,\r\n                                decContext *set, enum rounding rmode,\r\n                                Flag exact) {\r\n  Int  exp;                        // exponent\r\n  uInt sourhi;                     // top word from source decFloat\r\n  enum rounding saveround;         // saver\r\n  uInt savestatus;                 // ..\r\n  decFloat zero;                   // work\r\n\r\n  /* Start decoding the argument */\r\n  sourhi=DFWORD(df, 0);            // top word\r\n  exp=DECCOMBEXP[sourhi>>26];      // get exponent high bits (in place)\r\n\r\n  if (EXPISSPECIAL(exp)) {         // is special?\r\n    // NaNs are handled as usual\r\n    if (DFISNAN(df)) return decNaNs(result, df, NULL, set);\r\n    // must be infinite; return canonical infinity with sign of df\r\n    return decInfinity(result, df);\r\n    }\r\n\r\n  /* Here when the argument is finite */\r\n  // complete extraction of the exponent\r\n  exp+=GETECON(df)-DECBIAS;             // .. + continuation and unbias\r\n\r\n  if (exp>=0) return decCanonical(result, df); // already integral\r\n\r\n  saveround=set->round;                 // save rounding mode ..\r\n  savestatus=set->status;               // .. and status\r\n  set->round=rmode;                     // set mode\r\n  decFloatZero(&zero);                  // make 0E+0\r\n  decFloatQuantize(result, df, &zero, set); // 'integrate'; cannot fail\r\n  set->round=saveround;                 // restore rounding mode ..\r\n  if (!exact) set->status=savestatus;   // .. and status, unless exact\r\n  return result;\r\n  } // decToIntegral\r\n"
  },
  {
    "path": "vendor/decNumber/decCommon.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* decCommon.c -- common code for all three fixed-size types          */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2010.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is included in the package as decNumber.pdf.  This   */\r\n/* document is also available in HTML, together with specifications,  */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This module comprises code that is shared between all the formats  */\r\n/* (decSingle, decDouble, and decQuad); it includes set and extract   */\r\n/* of format components, widening, narrowing, and string conversions. */\r\n/*                                                                    */\r\n/* Unlike decNumber, parameterization takes place at compile time     */\r\n/* rather than at runtime.  The parameters are set in the decDouble.c */\r\n/* (etc.) files, which then include this one to produce the compiled  */\r\n/* code.  The functions here, therefore, are code shared between      */\r\n/* multiple formats.                                                  */\r\n/* ------------------------------------------------------------------ */\r\n// Names here refer to decFloat rather than to decDouble, etc., and\r\n// the functions are in strict alphabetical order.\r\n// Constants, tables, and debug function(s) are included only for QUAD\r\n// (which will always be compiled if DOUBLE or SINGLE are used).\r\n//\r\n// Whenever a decContext is used, only the status may be set (using\r\n// OR) or the rounding mode read; all other fields are ignored and\r\n// untouched.\r\n\r\n// names for simpler testing and default context\r\n#if DECPMAX==7\r\n  #define SINGLE     1\r\n  #define DOUBLE     0\r\n  #define QUAD       0\r\n  #define DEFCONTEXT DEC_INIT_DECIMAL32\r\n#elif DECPMAX==16\r\n  #define SINGLE     0\r\n  #define DOUBLE     1\r\n  #define QUAD       0\r\n  #define DEFCONTEXT DEC_INIT_DECIMAL64\r\n#elif DECPMAX==34\r\n  #define SINGLE     0\r\n  #define DOUBLE     0\r\n  #define QUAD       1\r\n  #define DEFCONTEXT DEC_INIT_DECIMAL128\r\n#else\r\n  #error Unexpected DECPMAX value\r\n#endif\r\n\r\n/* Assertions */\r\n\r\n#if DECPMAX!=7 && DECPMAX!=16 && DECPMAX!=34\r\n  #error Unexpected Pmax (DECPMAX) value for this module\r\n#endif\r\n\r\n// Assert facts about digit characters, etc.\r\n#if ('9'&0x0f)!=9\r\n  #error This module assumes characters are of the form 0b....nnnn\r\n  // where .... are don't care 4 bits and nnnn is 0000 through 1001\r\n#endif\r\n#if ('9'&0xf0)==('.'&0xf0)\r\n  #error This module assumes '.' has a different mask than a digit\r\n#endif\r\n\r\n// Assert ToString lay-out conditions\r\n#if DECSTRING<DECPMAX+9\r\n  #error ToString needs at least 8 characters for lead-in and dot\r\n#endif\r\n#if DECPMAX+DECEMAXD+5 > DECSTRING\r\n  #error Exponent form can be too long for ToString to lay out safely\r\n#endif\r\n#if DECEMAXD > 4\r\n  #error Exponent form is too long for ToString to lay out\r\n  // Note: code for up to 9 digits exists in archives [decOct]\r\n#endif\r\n\r\n/* Private functions used here and possibly in decBasic.c, etc. */\r\nstatic decFloat * decFinalize(decFloat *, bcdnum *, decContext *);\r\nstatic Flag decBiStr(const char *, const char *, const char *);\r\n\r\n/* Macros and private tables; those which are not format-dependent    */\r\n/* are only included if decQuad is being built.                       */\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* Combination field lookup tables (uInts to save measurable work)    */\r\n/*                                                                    */\r\n/*   DECCOMBEXP  - 2 most-significant-bits of exponent (00, 01, or    */\r\n/*                 10), shifted left for format, or DECFLOAT_Inf/NaN  */\r\n/*   DECCOMBWEXP - The same, for the next-wider format (unless QUAD)  */\r\n/*   DECCOMBMSD  - 4-bit most-significant-digit                       */\r\n/*                 [0 if the index is a special (Infinity or NaN)]    */\r\n/*   DECCOMBFROM - 5-bit combination field from EXP top bits and MSD  */\r\n/*                 (placed in uInt so no shift is needed)             */\r\n/*                                                                    */\r\n/* DECCOMBEXP, DECCOMBWEXP, and DECCOMBMSD are indexed by the sign    */\r\n/*   and 5-bit combination field (0-63, the second half of the table  */\r\n/*   identical to the first half)                                     */\r\n/* DECCOMBFROM is indexed by expTopTwoBits*16 + msd                   */\r\n/*                                                                    */\r\n/* DECCOMBMSD and DECCOMBFROM are not format-dependent and so are     */\r\n/* only included once, when QUAD is being built                       */\r\n/* ------------------------------------------------------------------ */\r\nstatic const uInt DECCOMBEXP[64]={\r\n  0, 0, 0, 0, 0, 0, 0, 0,\r\n  1<<DECECONL, 1<<DECECONL, 1<<DECECONL, 1<<DECECONL,\r\n  1<<DECECONL, 1<<DECECONL, 1<<DECECONL, 1<<DECECONL,\r\n  2<<DECECONL, 2<<DECECONL, 2<<DECECONL, 2<<DECECONL,\r\n  2<<DECECONL, 2<<DECECONL, 2<<DECECONL, 2<<DECECONL,\r\n  0,           0,           1<<DECECONL, 1<<DECECONL,\r\n  2<<DECECONL, 2<<DECECONL, DECFLOAT_Inf, DECFLOAT_NaN,\r\n  0, 0, 0, 0, 0, 0, 0, 0,\r\n  1<<DECECONL, 1<<DECECONL, 1<<DECECONL, 1<<DECECONL,\r\n  1<<DECECONL, 1<<DECECONL, 1<<DECECONL, 1<<DECECONL,\r\n  2<<DECECONL, 2<<DECECONL, 2<<DECECONL, 2<<DECECONL,\r\n  2<<DECECONL, 2<<DECECONL, 2<<DECECONL, 2<<DECECONL,\r\n  0,           0,           1<<DECECONL, 1<<DECECONL,\r\n  2<<DECECONL, 2<<DECECONL, DECFLOAT_Inf, DECFLOAT_NaN};\r\n#if !QUAD\r\nstatic const uInt DECCOMBWEXP[64]={\r\n  0, 0, 0, 0, 0, 0, 0, 0,\r\n  1<<DECWECONL, 1<<DECWECONL, 1<<DECWECONL, 1<<DECWECONL,\r\n  1<<DECWECONL, 1<<DECWECONL, 1<<DECWECONL, 1<<DECWECONL,\r\n  2<<DECWECONL, 2<<DECWECONL, 2<<DECWECONL, 2<<DECWECONL,\r\n  2<<DECWECONL, 2<<DECWECONL, 2<<DECWECONL, 2<<DECWECONL,\r\n  0,            0,            1<<DECWECONL, 1<<DECWECONL,\r\n  2<<DECWECONL, 2<<DECWECONL, DECFLOAT_Inf, DECFLOAT_NaN,\r\n  0, 0, 0, 0, 0, 0, 0, 0,\r\n  1<<DECWECONL, 1<<DECWECONL, 1<<DECWECONL, 1<<DECWECONL,\r\n  1<<DECWECONL, 1<<DECWECONL, 1<<DECWECONL, 1<<DECWECONL,\r\n  2<<DECWECONL, 2<<DECWECONL, 2<<DECWECONL, 2<<DECWECONL,\r\n  2<<DECWECONL, 2<<DECWECONL, 2<<DECWECONL, 2<<DECWECONL,\r\n  0,            0,            1<<DECWECONL, 1<<DECWECONL,\r\n  2<<DECWECONL, 2<<DECWECONL, DECFLOAT_Inf, DECFLOAT_NaN};\r\n#endif\r\n\r\n#if QUAD\r\nconst uInt DECCOMBMSD[64]={\r\n  0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,\r\n  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 9, 8, 9, 0, 0,\r\n  0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,\r\n  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 9, 8, 9, 0, 0};\r\n\r\nconst uInt DECCOMBFROM[48]={\r\n  0x00000000, 0x04000000, 0x08000000, 0x0C000000, 0x10000000, 0x14000000,\r\n  0x18000000, 0x1C000000, 0x60000000, 0x64000000, 0x00000000, 0x00000000,\r\n  0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x20000000, 0x24000000,\r\n  0x28000000, 0x2C000000, 0x30000000, 0x34000000, 0x38000000, 0x3C000000,\r\n  0x68000000, 0x6C000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,\r\n  0x00000000, 0x00000000, 0x40000000, 0x44000000, 0x48000000, 0x4C000000,\r\n  0x50000000, 0x54000000, 0x58000000, 0x5C000000, 0x70000000, 0x74000000,\r\n  0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000};\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* Request and include the tables to use for conversions              */\r\n/* ------------------------------------------------------------------ */\r\n#define DEC_BCD2DPD  1        // 0-0x999 -> DPD\r\n#define DEC_BIN2DPD  1        // 0-999 -> DPD\r\n#define DEC_BIN2BCD8 1        // 0-999 -> ddd, len\r\n#define DEC_DPD2BCD8 1        // DPD -> ddd, len\r\n#define DEC_DPD2BIN  1        // DPD -> 0-999\r\n#define DEC_DPD2BINK 1        // DPD -> 0-999000\r\n#define DEC_DPD2BINM 1        // DPD -> 0-999000000\r\n#include \"decDPD.h\"           // source of the lookup tables\r\n\r\n#endif\r\n\r\n/* ----------------------------------------------------------------- */\r\n/* decBiStr -- compare string with pairwise options                  */\r\n/*                                                                   */\r\n/*   targ is the string to compare                                   */\r\n/*   str1 is one of the strings to compare against (length may be 0) */\r\n/*   str2 is the other; it must be the same length as str1           */\r\n/*                                                                   */\r\n/*   returns 1 if strings compare equal, (that is, targ is the same  */\r\n/*   length as str1 and str2, and each character of targ is in one   */\r\n/*   of str1 or str2 in the corresponding position), or 0 otherwise  */\r\n/*                                                                   */\r\n/* This is used for generic caseless compare, including the awkward  */\r\n/* case of the Turkish dotted and dotless Is.  Use as (for example): */\r\n/*   if (decBiStr(test, \"mike\", \"MIKE\")) ...                         */\r\n/* ----------------------------------------------------------------- */\r\nstatic Flag decBiStr(const char *targ, const char *str1, const char *str2) {\r\n  for (;;targ++, str1++, str2++) {\r\n    if (*targ!=*str1 && *targ!=*str2) return 0;\r\n    // *targ has a match in one (or both, if terminator)\r\n    if (*targ=='\\0') break;\r\n    } // forever\r\n  return 1;\r\n  } // decBiStr\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFinalize -- adjust and store a final result                     */\r\n/*                                                                    */\r\n/*  df  is the decFloat format number which gets the final result     */\r\n/*  num is the descriptor of the number to be checked and encoded     */\r\n/*         [its values, including the coefficient, may be modified]   */\r\n/*  set is the context to use                                         */\r\n/*  returns df                                                        */\r\n/*                                                                    */\r\n/* The num descriptor may point to a bcd8 string of any length; this  */\r\n/* string may have leading insignificant zeros.  If it has more than  */\r\n/* DECPMAX digits then the final digit can be a round-for-reround     */\r\n/* digit (i.e., it may include a sticky bit residue).                 */\r\n/*                                                                    */\r\n/* The exponent (q) may be one of the codes for a special value and   */\r\n/* can be up to 999999999 for conversion from string.                 */\r\n/*                                                                    */\r\n/* No error is possible, but Inexact, Underflow, and/or Overflow may  */\r\n/* be set.                                                            */\r\n/* ------------------------------------------------------------------ */\r\n// Constant whose size varies with format; also the check for surprises\r\nstatic uByte allnines[DECPMAX]=\r\n#if SINGLE\r\n  {9, 9, 9, 9, 9, 9, 9};\r\n#elif DOUBLE\r\n  {9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9};\r\n#elif QUAD\r\n  {9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,\r\n   9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9};\r\n#endif\r\n\r\nstatic decFloat * decFinalize(decFloat *df, bcdnum *num,\r\n                              decContext *set) {\r\n  uByte *ub;                  // work\r\n  uInt   dpd;                 // ..\r\n  uInt   uiwork;              // for macros\r\n  uByte *umsd=num->msd;       // local copy\r\n  uByte *ulsd=num->lsd;       // ..\r\n  uInt   encode;              // encoding accumulator\r\n  Int    length;              // coefficient length\r\n\r\n  #if DECCHECK\r\n  Int clen=ulsd-umsd+1;\r\n  #if QUAD\r\n    #define COEXTRA 2                        // extra-long coefficent\r\n  #else\r\n    #define COEXTRA 0\r\n  #endif\r\n  if (clen<1 || clen>DECPMAX*3+2+COEXTRA)\r\n    printf(\"decFinalize: suspect coefficient [length=%ld]\\n\", (LI)clen);\r\n  if (num->sign!=0 && num->sign!=DECFLOAT_Sign)\r\n    printf(\"decFinalize: bad sign [%08lx]\\n\", (LI)num->sign);\r\n  if (!EXPISSPECIAL(num->exponent)\r\n      && (num->exponent>1999999999 || num->exponent<-1999999999))\r\n    printf(\"decFinalize: improbable exponent [%ld]\\n\", (LI)num->exponent);\r\n  // decShowNum(num, \"final\");\r\n  #endif\r\n\r\n  // A special will have an 'exponent' which is very positive and a\r\n  // coefficient < DECPMAX\r\n  length=(uInt)(ulsd-umsd+1);                // coefficient length\r\n\r\n  if (!NUMISSPECIAL(num)) {\r\n    Int   drop;                              // digits to be dropped\r\n    // skip leading insignificant zeros to calculate an exact length\r\n    // [this is quite expensive]\r\n    if (*umsd==0) {\r\n      for (; umsd+3<ulsd && UBTOUI(umsd)==0;) umsd+=4;\r\n      for (; *umsd==0 && umsd<ulsd;) umsd++;\r\n      length=ulsd-umsd+1;                    // recalculate\r\n      }\r\n    drop=MAXI(length-DECPMAX, DECQTINY-num->exponent);\r\n    // drop can now be > digits for bottom-clamp (subnormal) cases\r\n    if (drop>0) {                            // rounding needed\r\n      // (decFloatQuantize has very similar code to this, so any\r\n      // changes may need to be made there, too)\r\n      uByte *roundat;                        // -> re-round digit\r\n      uByte reround;                         // reround value\r\n      // printf(\"Rounding; drop=%ld\\n\", (LI)drop);\r\n\r\n      num->exponent+=drop;                   // always update exponent\r\n\r\n      // Three cases here:\r\n      //   1. new LSD is in coefficient (almost always)\r\n      //   2. new LSD is digit to left of coefficient (so MSD is\r\n      //      round-for-reround digit)\r\n      //   3. new LSD is to left of case 2 (whole coefficient is sticky)\r\n      // [duplicate check-stickies code to save a test]\r\n      // [by-digit check for stickies as runs of zeros are rare]\r\n      if (drop<length) {                     // NB lengths not addresses\r\n        roundat=umsd+length-drop;\r\n        reround=*roundat;\r\n        for (ub=roundat+1; ub<=ulsd; ub++) {\r\n          if (*ub!=0) {                      // non-zero to be discarded\r\n            reround=DECSTICKYTAB[reround];   // apply sticky bit\r\n            break;                           // [remainder don't-care]\r\n            }\r\n          } // check stickies\r\n        ulsd=roundat-1;                      // new LSD\r\n        }\r\n       else {                                // edge case\r\n        if (drop==length) {\r\n          roundat=umsd;\r\n          reround=*roundat;\r\n          }\r\n         else {\r\n          roundat=umsd-1;\r\n          reround=0;\r\n          }\r\n        for (ub=roundat+1; ub<=ulsd; ub++) {\r\n          if (*ub!=0) {                      // non-zero to be discarded\r\n            reround=DECSTICKYTAB[reround];   // apply sticky bit\r\n            break;                           // [remainder don't-care]\r\n            }\r\n          } // check stickies\r\n        *umsd=0;                             // coefficient is a 0\r\n        ulsd=umsd;                           // ..\r\n        }\r\n\r\n      if (reround!=0) {                      // discarding non-zero\r\n        uInt bump=0;\r\n        set->status|=DEC_Inexact;\r\n        // if adjusted exponent [exp+digits-1] is < EMIN then num is\r\n        // subnormal -- so raise Underflow\r\n        if (num->exponent<DECEMIN && (num->exponent+(ulsd-umsd+1)-1)<DECEMIN)\r\n          set->status|=DEC_Underflow;\r\n\r\n        // next decide whether increment of the coefficient is needed\r\n        if (set->round==DEC_ROUND_HALF_EVEN) {    // fastpath slowest case\r\n          if (reround>5) bump=1;                  // >0.5 goes up\r\n           else if (reround==5)                   // exactly 0.5000 ..\r\n            bump=*ulsd & 0x01;                    // .. up iff [new] lsd is odd\r\n          } // r-h-e\r\n         else switch (set->round) {\r\n          case DEC_ROUND_DOWN: {\r\n            // no change\r\n            break;} // r-d\r\n          case DEC_ROUND_HALF_DOWN: {\r\n            if (reround>5) bump=1;\r\n            break;} // r-h-d\r\n          case DEC_ROUND_HALF_UP: {\r\n            if (reround>=5) bump=1;\r\n            break;} // r-h-u\r\n          case DEC_ROUND_UP: {\r\n            if (reround>0) bump=1;\r\n            break;} // r-u\r\n          case DEC_ROUND_CEILING: {\r\n            // same as _UP for positive numbers, and as _DOWN for negatives\r\n            if (!num->sign && reround>0) bump=1;\r\n            break;} // r-c\r\n          case DEC_ROUND_FLOOR: {\r\n            // same as _UP for negative numbers, and as _DOWN for positive\r\n            // [negative reround cannot occur on 0]\r\n            if (num->sign && reround>0) bump=1;\r\n            break;} // r-f\r\n          case DEC_ROUND_05UP: {\r\n            if (reround>0) { // anything out there is 'sticky'\r\n              // bump iff lsd=0 or 5; this cannot carry so it could be\r\n              // effected immediately with no bump -- but the code\r\n              // is clearer if this is done the same way as the others\r\n              if (*ulsd==0 || *ulsd==5) bump=1;\r\n              }\r\n            break;} // r-r\r\n          default: {      // e.g., DEC_ROUND_MAX\r\n            set->status|=DEC_Invalid_context;\r\n            #if DECCHECK\r\n            printf(\"Unknown rounding mode: %ld\\n\", (LI)set->round);\r\n            #endif\r\n            break;}\r\n          } // switch (not r-h-e)\r\n        // printf(\"ReRound: %ld  bump: %ld\\n\", (LI)reround, (LI)bump);\r\n\r\n        if (bump!=0) {                       // need increment\r\n          // increment the coefficient; this might end up with 1000...\r\n          // (after the all nines case)\r\n          ub=ulsd;\r\n          for(; ub-3>=umsd && UBTOUI(ub-3)==0x09090909; ub-=4)  {\r\n            UBFROMUI(ub-3, 0);               // to 00000000\r\n            }\r\n          // [note ub could now be to left of msd, and it is not safe\r\n          // to write to the left of the msd]\r\n          // now at most 3 digits left to non-9 (usually just the one)\r\n          for (; ub>=umsd; *ub=0, ub--) {\r\n            if (*ub==9) continue;            // carry\r\n            *ub+=1;\r\n            break;\r\n            }\r\n          if (ub<umsd) {                     // had all-nines\r\n            *umsd=1;                         // coefficient to 1000...\r\n            // usually the 1000... coefficient can be used as-is\r\n            if ((ulsd-umsd+1)==DECPMAX) {\r\n              num->exponent++;\r\n              }\r\n             else {\r\n              // if coefficient is shorter than Pmax then num is\r\n              // subnormal, so extend it; this is safe as drop>0\r\n              // (or, if the coefficient was supplied above, it could\r\n              // not be 9); this may make the result normal.\r\n              ulsd++;\r\n              *ulsd=0;\r\n              // [exponent unchanged]\r\n              #if DECCHECK\r\n              if (num->exponent!=DECQTINY) // sanity check\r\n                printf(\"decFinalize: bad all-nines extend [^%ld, %ld]\\n\",\r\n                       (LI)num->exponent, (LI)(ulsd-umsd+1));\r\n              #endif\r\n              } // subnormal extend\r\n            } // had all-nines\r\n          } // bump needed\r\n        } // inexact rounding\r\n\r\n      length=ulsd-umsd+1;               // recalculate (may be <DECPMAX)\r\n      } // need round (drop>0)\r\n\r\n    // The coefficient will now fit and has final length unless overflow\r\n    // decShowNum(num, \"rounded\");\r\n\r\n    // if exponent is >=emax may have to clamp, overflow, or fold-down\r\n    if (num->exponent>DECEMAX-(DECPMAX-1)) { // is edge case\r\n      // printf(\"overflow checks...\\n\");\r\n      if (*ulsd==0 && ulsd==umsd) {     // have zero\r\n        num->exponent=DECEMAX-(DECPMAX-1); // clamp to max\r\n        }\r\n       else if ((num->exponent+length-1)>DECEMAX) { // > Nmax\r\n        // Overflow -- these could go straight to encoding, here, but\r\n        // instead num is adjusted to keep the code cleaner\r\n        Flag needmax=0;                 // 1 for finite result\r\n        set->status|=(DEC_Overflow | DEC_Inexact);\r\n        switch (set->round) {\r\n          case DEC_ROUND_DOWN: {\r\n            needmax=1;                  // never Infinity\r\n            break;} // r-d\r\n          case DEC_ROUND_05UP: {\r\n            needmax=1;                  // never Infinity\r\n            break;} // r-05\r\n          case DEC_ROUND_CEILING: {\r\n            if (num->sign) needmax=1;   // Infinity iff non-negative\r\n            break;} // r-c\r\n          case DEC_ROUND_FLOOR: {\r\n            if (!num->sign) needmax=1;  // Infinity iff negative\r\n            break;} // r-f\r\n          default: break;               // Infinity in all other cases\r\n          }\r\n        if (!needmax) {                 // easy .. set Infinity\r\n          num->exponent=DECFLOAT_Inf;\r\n          *umsd=0;                      // be clean: coefficient to 0\r\n          ulsd=umsd;                    // ..\r\n          }\r\n         else {                         // return Nmax\r\n          umsd=allnines;                // use constant array\r\n          ulsd=allnines+DECPMAX-1;\r\n          num->exponent=DECEMAX-(DECPMAX-1);\r\n          }\r\n        }\r\n       else { // no overflow but non-zero and may have to fold-down\r\n        Int shift=num->exponent-(DECEMAX-(DECPMAX-1));\r\n        if (shift>0) {                  // fold-down needed\r\n          // fold down needed; must copy to buffer in order to pad\r\n          // with zeros safely; fortunately this is not the worst case\r\n          // path because cannot have had a round\r\n          uByte buffer[ROUNDUP(DECPMAX+3, 4)]; // [+3 allows uInt padding]\r\n          uByte *s=umsd;                // source\r\n          uByte *t=buffer;              // safe target\r\n          uByte *tlsd=buffer+(ulsd-umsd)+shift; // target LSD\r\n          // printf(\"folddown shift=%ld\\n\", (LI)shift);\r\n          for (; s<=ulsd; s+=4, t+=4) UBFROMUI(t, UBTOUI(s));\r\n          for (t=tlsd-shift+1; t<=tlsd; t+=4) UBFROMUI(t, 0);  // pad 0s\r\n          num->exponent-=shift;\r\n          umsd=buffer;\r\n          ulsd=tlsd;\r\n          }\r\n        } // fold-down?\r\n      length=ulsd-umsd+1;               // recalculate length\r\n      } // high-end edge case\r\n    } // finite number\r\n\r\n  /*------------------------------------------------------------------*/\r\n  /* At this point the result will properly fit the decFloat          */\r\n  /* encoding, and it can be encoded with no possibility of error     */\r\n  /*------------------------------------------------------------------*/\r\n  // Following code does not alter coefficient (could be allnines array)\r\n\r\n  // fast path possible when DECPMAX digits\r\n  if (length==DECPMAX) {\r\n    return decFloatFromBCD(df, num->exponent, umsd, num->sign);\r\n    } // full-length\r\n\r\n  // slower path when not a full-length number; must care about length\r\n  // [coefficient length here will be < DECPMAX]\r\n  if (!NUMISSPECIAL(num)) {             // is still finite\r\n    // encode the combination field and exponent continuation\r\n    uInt uexp=(uInt)(num->exponent+DECBIAS); // biased exponent\r\n    uInt code=(uexp>>DECECONL)<<4;      // top two bits of exp\r\n    // [msd==0]\r\n    // look up the combination field and make high word\r\n    encode=DECCOMBFROM[code];           // indexed by (0-2)*16+msd\r\n    encode|=(uexp<<(32-6-DECECONL)) & 0x03ffffff; // exponent continuation\r\n    }\r\n   else encode=num->exponent;           // special [already in word]\r\n  encode|=num->sign;                    // add sign\r\n\r\n  // private macro to extract a declet, n (where 0<=n<DECLETS and 0\r\n  // refers to the declet from the least significant three digits)\r\n  // and put the corresponding DPD code into dpd.  Access to umsd and\r\n  // ulsd (pointers to the most and least significant digit of the\r\n  // variable-length coefficient) is assumed, along with use of a\r\n  // working pointer, uInt *ub.\r\n  // As not full-length then chances are there are many leading zeros\r\n  // [and there may be a partial triad]\r\n  #define getDPDt(dpd, n) ub=ulsd-(3*(n))-2;                          \\\r\n    if (ub<umsd-2) dpd=0;                                             \\\r\n     else if (ub>=umsd) dpd=BCD2DPD[(*ub*256)+(*(ub+1)*16)+*(ub+2)];  \\\r\n     else {dpd=*(ub+2); if (ub+1==umsd) dpd+=*(ub+1)*16; dpd=BCD2DPD[dpd];}\r\n\r\n  // place the declets in the encoding words and copy to result (df),\r\n  // according to endianness; in all cases complete the sign word\r\n  // first\r\n  #if DECPMAX==7\r\n    getDPDt(dpd, 1);\r\n    encode|=dpd<<10;\r\n    getDPDt(dpd, 0);\r\n    encode|=dpd;\r\n    DFWORD(df, 0)=encode;     // just the one word\r\n\r\n  #elif DECPMAX==16\r\n    getDPDt(dpd, 4); encode|=dpd<<8;\r\n    getDPDt(dpd, 3); encode|=dpd>>2;\r\n    DFWORD(df, 0)=encode;\r\n    encode=dpd<<30;\r\n    getDPDt(dpd, 2); encode|=dpd<<20;\r\n    getDPDt(dpd, 1); encode|=dpd<<10;\r\n    getDPDt(dpd, 0); encode|=dpd;\r\n    DFWORD(df, 1)=encode;\r\n\r\n  #elif DECPMAX==34\r\n    getDPDt(dpd,10); encode|=dpd<<4;\r\n    getDPDt(dpd, 9); encode|=dpd>>6;\r\n    DFWORD(df, 0)=encode;\r\n\r\n    encode=dpd<<26;\r\n    getDPDt(dpd, 8); encode|=dpd<<16;\r\n    getDPDt(dpd, 7); encode|=dpd<<6;\r\n    getDPDt(dpd, 6); encode|=dpd>>4;\r\n    DFWORD(df, 1)=encode;\r\n\r\n    encode=dpd<<28;\r\n    getDPDt(dpd, 5); encode|=dpd<<18;\r\n    getDPDt(dpd, 4); encode|=dpd<<8;\r\n    getDPDt(dpd, 3); encode|=dpd>>2;\r\n    DFWORD(df, 2)=encode;\r\n\r\n    encode=dpd<<30;\r\n    getDPDt(dpd, 2); encode|=dpd<<20;\r\n    getDPDt(dpd, 1); encode|=dpd<<10;\r\n    getDPDt(dpd, 0); encode|=dpd;\r\n    DFWORD(df, 3)=encode;\r\n  #endif\r\n\r\n  // printf(\"Status: %08lx\\n\", (LI)set->status);\r\n  // decFloatShow(df, \"final2\");\r\n  return df;\r\n  } // decFinalize\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatFromBCD -- set decFloat from exponent, BCD8, and sign      */\r\n/*                                                                    */\r\n/*  df is the target decFloat                                         */\r\n/*  exp is the in-range unbiased exponent, q, or a special value in   */\r\n/*    the form returned by decFloatGetExponent                        */\r\n/*  bcdar holds DECPMAX digits to set the coefficient from, one       */\r\n/*    digit in each byte (BCD8 encoding); the first (MSD) is ignored  */\r\n/*    if df is a NaN; all are ignored if df is infinite.              */\r\n/*    All bytes must be in 0-9; results are undefined otherwise.      */\r\n/*  sig is DECFLOAT_Sign to set the sign bit, 0 otherwise             */\r\n/*  returns df, which will be canonical                               */\r\n/*                                                                    */\r\n/* No error is possible, and no status will be set.                   */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatFromBCD(decFloat *df, Int exp, const uByte *bcdar,\r\n                           Int sig) {\r\n  uInt encode, dpd;                     // work\r\n  const uByte *ub;                      // ..\r\n\r\n  if (EXPISSPECIAL(exp)) encode=exp|sig;// specials already encoded\r\n   else {                               // is finite\r\n    // encode the combination field and exponent continuation\r\n    uInt uexp=(uInt)(exp+DECBIAS);      // biased exponent\r\n    uInt code=(uexp>>DECECONL)<<4;      // top two bits of exp\r\n    code+=bcdar[0];                     // add msd\r\n    // look up the combination field and make high word\r\n    encode=DECCOMBFROM[code]|sig;       // indexed by (0-2)*16+msd\r\n    encode|=(uexp<<(32-6-DECECONL)) & 0x03ffffff; // exponent continuation\r\n    }\r\n\r\n  // private macro to extract a declet, n (where 0<=n<DECLETS and 0\r\n  // refers to the declet from the least significant three digits)\r\n  // and put the corresponding DPD code into dpd.\r\n  // Use of a working pointer, uInt *ub, is assumed.\r\n\r\n  #define getDPDb(dpd, n) ub=bcdar+DECPMAX-1-(3*(n))-2;     \\\r\n    dpd=BCD2DPD[(*ub*256)+(*(ub+1)*16)+*(ub+2)];\r\n\r\n  // place the declets in the encoding words and copy to result (df),\r\n  // according to endianness; in all cases complete the sign word\r\n  // first\r\n  #if DECPMAX==7\r\n    getDPDb(dpd, 1);\r\n    encode|=dpd<<10;\r\n    getDPDb(dpd, 0);\r\n    encode|=dpd;\r\n    DFWORD(df, 0)=encode;     // just the one word\r\n\r\n  #elif DECPMAX==16\r\n    getDPDb(dpd, 4); encode|=dpd<<8;\r\n    getDPDb(dpd, 3); encode|=dpd>>2;\r\n    DFWORD(df, 0)=encode;\r\n    encode=dpd<<30;\r\n    getDPDb(dpd, 2); encode|=dpd<<20;\r\n    getDPDb(dpd, 1); encode|=dpd<<10;\r\n    getDPDb(dpd, 0); encode|=dpd;\r\n    DFWORD(df, 1)=encode;\r\n\r\n  #elif DECPMAX==34\r\n    getDPDb(dpd,10); encode|=dpd<<4;\r\n    getDPDb(dpd, 9); encode|=dpd>>6;\r\n    DFWORD(df, 0)=encode;\r\n\r\n    encode=dpd<<26;\r\n    getDPDb(dpd, 8); encode|=dpd<<16;\r\n    getDPDb(dpd, 7); encode|=dpd<<6;\r\n    getDPDb(dpd, 6); encode|=dpd>>4;\r\n    DFWORD(df, 1)=encode;\r\n\r\n    encode=dpd<<28;\r\n    getDPDb(dpd, 5); encode|=dpd<<18;\r\n    getDPDb(dpd, 4); encode|=dpd<<8;\r\n    getDPDb(dpd, 3); encode|=dpd>>2;\r\n    DFWORD(df, 2)=encode;\r\n\r\n    encode=dpd<<30;\r\n    getDPDb(dpd, 2); encode|=dpd<<20;\r\n    getDPDb(dpd, 1); encode|=dpd<<10;\r\n    getDPDb(dpd, 0); encode|=dpd;\r\n    DFWORD(df, 3)=encode;\r\n  #endif\r\n  // decFloatShow(df, \"fromB\");\r\n  return df;\r\n  } // decFloatFromBCD\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatFromPacked -- set decFloat from exponent and packed BCD    */\r\n/*                                                                    */\r\n/*  df is the target decFloat                                         */\r\n/*  exp is the in-range unbiased exponent, q, or a special value in   */\r\n/*    the form returned by decFloatGetExponent                        */\r\n/*  packed holds DECPMAX packed decimal digits plus a sign nibble     */\r\n/*    (all 6 codes are OK); the first (MSD) is ignored if df is a NaN */\r\n/*    and all except sign are ignored if df is infinite.  For DOUBLE  */\r\n/*    and QUAD the first (pad) nibble is also ignored in all cases.   */\r\n/*    All coefficient nibbles must be in 0-9 and sign in A-F; results */\r\n/*    are undefined otherwise.                                        */\r\n/*  returns df, which will be canonical                               */\r\n/*                                                                    */\r\n/* No error is possible, and no status will be set.                   */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatFromPacked(decFloat *df, Int exp, const uByte *packed) {\r\n  uByte bcdar[DECPMAX+2];               // work [+1 for pad, +1 for sign]\r\n  const uByte *ip;                      // ..\r\n  uByte *op;                            // ..\r\n  Int   sig=0;                          // sign\r\n\r\n  // expand coefficient and sign to BCDAR\r\n  #if SINGLE\r\n  op=bcdar+1;                           // no pad digit\r\n  #else\r\n  op=bcdar;                             // first (pad) digit ignored\r\n  #endif\r\n  for (ip=packed; ip<packed+((DECPMAX+2)/2); ip++) {\r\n    *op++=*ip>>4;\r\n    *op++=(uByte)(*ip&0x0f);            // [final nibble is sign]\r\n    }\r\n  op--;                                 // -> sign byte\r\n  if (*op==DECPMINUS || *op==DECPMINUSALT) sig=DECFLOAT_Sign;\r\n\r\n  if (EXPISSPECIAL(exp)) {              // Infinity or NaN\r\n    if (!EXPISINF(exp)) bcdar[1]=0;     // a NaN: ignore MSD\r\n     else memset(bcdar+1, 0, DECPMAX);  // Infinite: coefficient to 0\r\n    }\r\n  return decFloatFromBCD(df, exp, bcdar+1, sig);\r\n  } // decFloatFromPacked\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatFromPackedChecked -- set from exponent and packed; checked */\r\n/*                                                                    */\r\n/*  df is the target decFloat                                         */\r\n/*  exp is the in-range unbiased exponent, q, or a special value in   */\r\n/*    the form returned by decFloatGetExponent                        */\r\n/*  packed holds DECPMAX packed decimal digits plus a sign nibble     */\r\n/*    (all 6 codes are OK); the first (MSD) must be 0 if df is a NaN  */\r\n/*    and all digits must be 0 if df is infinite.  For DOUBLE and     */\r\n/*    QUAD the first (pad) nibble must be 0.                          */\r\n/*    All coefficient nibbles must be in 0-9 and sign in A-F.         */\r\n/*  returns df, which will be canonical or NULL if any of the         */\r\n/*    requirements are not met (if this case df is unchanged); that   */\r\n/*    is, the input data must be as returned by decFloatToPacked,     */\r\n/*    except that all six sign codes are acccepted.                   */\r\n/*                                                                    */\r\n/* No status will be set.                                             */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatFromPackedChecked(decFloat *df, Int exp,\r\n                                     const uByte *packed) {\r\n  uByte bcdar[DECPMAX+2];               // work [+1 for pad, +1 for sign]\r\n  const uByte *ip;                      // ..\r\n  uByte *op;                            // ..\r\n  Int   sig=0;                          // sign\r\n\r\n  // expand coefficient and sign to BCDAR\r\n  #if SINGLE\r\n  op=bcdar+1;                           // no pad digit\r\n  #else\r\n  op=bcdar;                             // first (pad) digit here\r\n  #endif\r\n  for (ip=packed; ip<packed+((DECPMAX+2)/2); ip++) {\r\n    *op=*ip>>4;\r\n    if (*op>9) return NULL;\r\n    op++;\r\n    *op=(uByte)(*ip&0x0f);              // [final nibble is sign]\r\n    if (*op>9 && ip<packed+((DECPMAX+2)/2)-1) return NULL;\r\n    op++;\r\n    }\r\n  op--;                                 // -> sign byte\r\n  if (*op<=9) return NULL;              // bad sign\r\n  if (*op==DECPMINUS || *op==DECPMINUSALT) sig=DECFLOAT_Sign;\r\n\r\n  #if !SINGLE\r\n  if (bcdar[0]!=0) return NULL;         // bad pad nibble\r\n  #endif\r\n\r\n  if (EXPISNAN(exp)) {                  // a NaN\r\n    if (bcdar[1]!=0) return NULL;       // bad msd\r\n    } // NaN\r\n   else if (EXPISINF(exp)) {            // is infinite\r\n    Int i;\r\n    for (i=0; i<DECPMAX; i++) {\r\n      if (bcdar[i+1]!=0) return NULL;   // should be all zeros\r\n      }\r\n    } // infinity\r\n   else {                               // finite\r\n    // check the exponent is in range\r\n    if (exp>DECEMAX-DECPMAX+1) return NULL;\r\n    if (exp<DECEMIN-DECPMAX+1) return NULL;\r\n    }\r\n  return decFloatFromBCD(df, exp, bcdar+1, sig);\r\n  } // decFloatFromPacked\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatFromString -- conversion from numeric string               */\r\n/*                                                                    */\r\n/*  result  is the decFloat format number which gets the result of    */\r\n/*          the conversion                                            */\r\n/*  *string is the character string which should contain a valid      */\r\n/*          number (which may be a special value), \\0-terminated      */\r\n/*          If there are too many significant digits in the           */\r\n/*          coefficient it will be rounded.                           */\r\n/*  set     is the context                                            */\r\n/*  returns result                                                    */\r\n/*                                                                    */\r\n/* The length of the coefficient and the size of the exponent are     */\r\n/* checked by this routine, so the correct error (Underflow or        */\r\n/* Overflow) can be reported or rounding applied, as necessary.       */\r\n/*                                                                    */\r\n/* There is no limit to the coefficient length for finite inputs;     */\r\n/* NaN payloads must be integers with no more than DECPMAX-1 digits.  */\r\n/* Exponents may have up to nine significant digits.                  */\r\n/*                                                                    */\r\n/* If bad syntax is detected, the result will be a quiet NaN.         */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatFromString(decFloat *result, const char *string,\r\n                              decContext *set) {\r\n  Int    digits;                   // count of digits in coefficient\r\n  const  char *dotchar=NULL;       // where dot was found [NULL if none]\r\n  const  char *cfirst=string;      // -> first character of decimal part\r\n  const  char *c;                  // work\r\n  uByte *ub;                       // ..\r\n  uInt   uiwork;                   // for macros\r\n  bcdnum num;                      // collects data for finishing\r\n  uInt   error=DEC_Conversion_syntax;      // assume the worst\r\n  uByte  buffer[ROUNDUP(DECSTRING+11, 8)]; // room for most coefficents,\r\n                                           // some common rounding, +3, & pad\r\n  #if DECTRACE\r\n  // printf(\"FromString %s ...\\n\", string);\r\n  #endif\r\n\r\n  for(;;) {                             // once-only 'loop'\r\n    num.sign=0;                         // assume non-negative\r\n    num.msd=buffer;                     // MSD is here always\r\n\r\n    // detect and validate the coefficient, including any leading,\r\n    // trailing, or embedded '.'\r\n    // [could test four-at-a-time here (saving 10% for decQuads),\r\n    // but that risks storage violation because the position of the\r\n    // terminator is unknown]\r\n    for (c=string;; c++) {              // -> input character\r\n      if (((unsigned)(*c-'0'))<=9) continue; // '0' through '9' is good\r\n      if (*c=='\\0') break;              // most common non-digit\r\n      if (*c=='.') {\r\n        if (dotchar!=NULL) break;       // not first '.'\r\n        dotchar=c;                      // record offset into decimal part\r\n        continue;}\r\n      if (c==string) {                  // first in string...\r\n        if (*c=='-') {                  // valid - sign\r\n          cfirst++;\r\n          num.sign=DECFLOAT_Sign;\r\n          continue;}\r\n        if (*c=='+') {                  // valid + sign\r\n          cfirst++;\r\n          continue;}\r\n        }\r\n      // *c is not a digit, terminator, or a valid +, -, or '.'\r\n      break;\r\n      } // c loop\r\n\r\n    digits=(uInt)(c-cfirst);            // digits (+1 if a dot)\r\n\r\n    if (digits>0) {                     // had digits and/or dot\r\n      const char *clast=c-1;            // note last coefficient char position\r\n      Int exp=0;                        // exponent accumulator\r\n      if (*c!='\\0') {                   // something follows the coefficient\r\n        uInt edig;                      // unsigned work\r\n        // had some digits and more to come; expect E[+|-]nnn now\r\n        const char *firstexp;           // exponent first non-zero\r\n        if (*c!='E' && *c!='e') break;\r\n        c++;                            // to (optional) sign\r\n        if (*c=='-' || *c=='+') c++;    // step over sign (c=clast+2)\r\n        if (*c=='\\0') break;            // no digits!  (e.g., '1.2E')\r\n        for (; *c=='0';) c++;           // skip leading zeros [even last]\r\n        firstexp=c;                     // remember start [maybe '\\0']\r\n        // gather exponent digits\r\n        edig=(uInt)*c-(uInt)'0';\r\n        if (edig<=9) {                  // [check not bad or terminator]\r\n          exp+=edig;                    // avoid initial X10\r\n          c++;\r\n          for (;; c++) {\r\n            edig=(uInt)*c-(uInt)'0';\r\n            if (edig>9) break;\r\n            exp=exp*10+edig;\r\n            }\r\n          }\r\n        // if not now on the '\\0', *c must not be a digit\r\n        if (*c!='\\0') break;\r\n\r\n        // (this next test must be after the syntax checks)\r\n        // if definitely more than the possible digits for format then\r\n        // the exponent may have wrapped, so simply set it to a certain\r\n        // over/underflow value\r\n        if (c>firstexp+DECEMAXD) exp=DECEMAX*2;\r\n        if (*(clast+2)=='-') exp=-exp;  // was negative\r\n        } // exponent part\r\n\r\n      if (dotchar!=NULL) {              // had a '.'\r\n        digits--;                       // remove from digits count\r\n        if (digits==0) break;           // was dot alone: bad syntax\r\n        exp-=(Int)(clast-dotchar);      // adjust exponent\r\n        // [the '.' can now be ignored]\r\n        }\r\n      num.exponent=exp;                 // exponent is good; store it\r\n\r\n      // Here when whole string has been inspected and syntax is good\r\n      // cfirst->first digit or dot, clast->last digit or dot\r\n      error=0;                          // no error possible now\r\n\r\n      // if the number of digits in the coefficient will fit in buffer\r\n      // then it can simply be converted to bcd8 and copied -- decFinalize\r\n      // will take care of leading zeros and rounding; the buffer is big\r\n      // enough for all canonical coefficients, including 0.00000nn...\r\n      ub=buffer;\r\n      if (digits<=(Int)(sizeof(buffer)-3)) { // [-3 allows by-4s copy]\r\n        c=cfirst;\r\n        if (dotchar!=NULL) {                 // a dot to worry about\r\n          if (*(c+1)=='.') {                 // common canonical case\r\n            *ub++=(uByte)(*c-'0');           // copy leading digit\r\n            c+=2;                            // prepare to handle rest\r\n            }\r\n           else for (; c<=clast;) {          // '.' could be anywhere\r\n            // as usual, go by fours when safe; NB it has been asserted\r\n            // that a '.' does not have the same mask as a digit\r\n            if (c<=clast-3                             // safe for four\r\n             && (UBTOUI(c)&0xf0f0f0f0)==CHARMASK) {    // test four\r\n              UBFROMUI(ub, UBTOUI(c)&0x0f0f0f0f);      // to BCD8\r\n              ub+=4;\r\n              c+=4;\r\n              continue;\r\n              }\r\n            if (*c=='.') {                   // found the dot\r\n              c++;                           // step over it ..\r\n              break;                         // .. and handle the rest\r\n              }\r\n            *ub++=(uByte)(*c++-'0');\r\n            }\r\n          } // had dot\r\n        // Now no dot; do this by fours (where safe)\r\n        for (; c<=clast-3; c+=4, ub+=4) UBFROMUI(ub, UBTOUI(c)&0x0f0f0f0f);\r\n        for (; c<=clast; c++, ub++) *ub=(uByte)(*c-'0');\r\n        num.lsd=buffer+digits-1;             // record new LSD\r\n        } // fits\r\n\r\n       else {                                // too long for buffer\r\n        // [This is a rare and unusual case; arbitrary-length input]\r\n        // strip leading zeros [but leave final 0 if all 0's]\r\n        if (*cfirst=='.') cfirst++;          // step past dot at start\r\n        if (*cfirst=='0') {                  // [cfirst always -> digit]\r\n          for (; cfirst<clast; cfirst++) {\r\n            if (*cfirst!='0') {              // non-zero found\r\n              if (*cfirst=='.') continue;    // [ignore]\r\n              break;                         // done\r\n              }\r\n            digits--;                        // 0 stripped\r\n            } // cfirst\r\n          } // at least one leading 0\r\n\r\n        // the coefficient is now as short as possible, but may still\r\n        // be too long; copy up to Pmax+1 digits to the buffer, then\r\n        // just record any non-zeros (set round-for-reround digit)\r\n        for (c=cfirst; c<=clast && ub<=buffer+DECPMAX; c++) {\r\n          // (see commentary just above)\r\n          if (c<=clast-3                          // safe for four\r\n           && (UBTOUI(c)&0xf0f0f0f0)==CHARMASK) { // four digits\r\n            UBFROMUI(ub, UBTOUI(c)&0x0f0f0f0f);   // to BCD8\r\n            ub+=4;\r\n            c+=3;                            // [will become 4]\r\n            continue;\r\n            }\r\n          if (*c=='.') continue;             // [ignore]\r\n          *ub++=(uByte)(*c-'0');\r\n          }\r\n        ub--;                                // -> LSD\r\n        for (; c<=clast; c++) {              // inspect remaining chars\r\n          if (*c!='0') {                     // sticky bit needed\r\n            if (*c=='.') continue;           // [ignore]\r\n            *ub=DECSTICKYTAB[*ub];           // update round-for-reround\r\n            break;                           // no need to look at more\r\n            }\r\n          }\r\n        num.lsd=ub;                          // record LSD\r\n        // adjust exponent for dropped digits\r\n        num.exponent+=digits-(Int)(ub-buffer+1);\r\n        } // too long for buffer\r\n      } // digits and/or dot\r\n\r\n     else {                             // no digits or dot were found\r\n      // only Infinities and NaNs are allowed, here\r\n      if (*c=='\\0') break;              // nothing there is bad\r\n      buffer[0]=0;                      // default a coefficient of 0\r\n      num.lsd=buffer;                   // ..\r\n      if (decBiStr(c, \"infinity\", \"INFINITY\")\r\n       || decBiStr(c, \"inf\", \"INF\")) num.exponent=DECFLOAT_Inf;\r\n       else {                           // should be a NaN\r\n        num.exponent=DECFLOAT_qNaN;     // assume quiet NaN\r\n        if (*c=='s' || *c=='S') {       // probably an sNaN\r\n          num.exponent=DECFLOAT_sNaN;   // effect the 's'\r\n          c++;                          // and step over it\r\n          }\r\n        if (*c!='N' && *c!='n') break;  // check caseless \"NaN\"\r\n        c++;\r\n        if (*c!='a' && *c!='A') break;  // ..\r\n        c++;\r\n        if (*c!='N' && *c!='n') break;  // ..\r\n        c++;\r\n        // now either nothing, or nnnn payload (no dots), expected\r\n        // -> start of integer, and skip leading 0s [including plain 0]\r\n        for (cfirst=c; *cfirst=='0';) cfirst++;\r\n        if (*cfirst!='\\0') {            // not empty or all-0, payload\r\n          // payload found; check all valid digits and copy to buffer as bcd8\r\n          ub=buffer;\r\n          for (c=cfirst;; c++, ub++) {\r\n            if ((unsigned)(*c-'0')>9) break; // quit if not 0-9\r\n            if (c-cfirst==DECPMAX-1) break;  // too many digits\r\n            *ub=(uByte)(*c-'0');        // good bcd8\r\n            }\r\n          if (*c!='\\0') break;          // not all digits, or too many\r\n          num.lsd=ub-1;                 // record new LSD\r\n          }\r\n        } // NaN or sNaN\r\n      error=0;                          // syntax is OK\r\n      } // digits=0 (special expected)\r\n    break;                              // drop out\r\n    }                                   // [for(;;) once-loop]\r\n\r\n  // decShowNum(&num, \"fromStr\");\r\n\r\n  if (error!=0) {\r\n    set->status|=error;\r\n    num.exponent=DECFLOAT_qNaN;         // set up quiet NaN\r\n    num.sign=0;                         // .. with 0 sign\r\n    buffer[0]=0;                        // .. and coefficient\r\n    num.lsd=buffer;                     // ..\r\n    // decShowNum(&num, \"oops\");\r\n    }\r\n\r\n  // decShowNum(&num, \"dffs\");\r\n  decFinalize(result, &num, set);       // round, check, and lay out\r\n  // decFloatShow(result, \"fromString\");\r\n  return result;\r\n  } // decFloatFromString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatFromWider -- conversion from next-wider format             */\r\n/*                                                                    */\r\n/*  result  is the decFloat format number which gets the result of    */\r\n/*          the conversion                                            */\r\n/*  wider   is the decFloatWider format number which will be narrowed */\r\n/*  set     is the context                                            */\r\n/*  returns result                                                    */\r\n/*                                                                    */\r\n/* Narrowing can cause rounding, overflow, etc., but not Invalid      */\r\n/* operation (sNaNs are copied and do not signal).                    */\r\n/* ------------------------------------------------------------------ */\r\n// narrow-to is not possible for decQuad format numbers; simply omit\r\n#if !QUAD\r\ndecFloat * decFloatFromWider(decFloat *result, const decFloatWider *wider,\r\n                             decContext *set) {\r\n  bcdnum num;                           // collects data for finishing\r\n  uByte  bcdar[DECWPMAX];               // room for wider coefficient\r\n  uInt   widerhi=DFWWORD(wider, 0);     // top word\r\n  Int    exp;\r\n\r\n  GETWCOEFF(wider, bcdar);\r\n\r\n  num.msd=bcdar;                        // MSD is here always\r\n  num.lsd=bcdar+DECWPMAX-1;             // LSD is here always\r\n  num.sign=widerhi&0x80000000;          // extract sign [DECFLOAT_Sign=Neg]\r\n\r\n  // decode the wider combination field to exponent\r\n  exp=DECCOMBWEXP[widerhi>>26];         // decode from wider combination field\r\n  // if it is a special there's nothing to do unless sNaN; if it's\r\n  // finite then add the (wider) exponent continuation and unbias\r\n  if (EXPISSPECIAL(exp)) exp=widerhi&0x7e000000; // include sNaN selector\r\n   else exp+=GETWECON(wider)-DECWBIAS;\r\n  num.exponent=exp;\r\n\r\n  // decShowNum(&num, \"dffw\");\r\n  return decFinalize(result, &num, set);// round, check, and lay out\r\n  } // decFloatFromWider\r\n#endif\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatGetCoefficient -- get coefficient as BCD8                  */\r\n/*                                                                    */\r\n/*  df is the decFloat from which to extract the coefficient          */\r\n/*  bcdar is where DECPMAX bytes will be written, one BCD digit in    */\r\n/*    each byte (BCD8 encoding); if df is a NaN the first byte will   */\r\n/*    be zero, and if it is infinite they will all be zero            */\r\n/*  returns the sign of the coefficient (DECFLOAT_Sign if negative,   */\r\n/*    0 otherwise)                                                    */\r\n/*                                                                    */\r\n/* No error is possible, and no status will be set.  If df is a       */\r\n/* special value the array is set to zeros (for Infinity) or to the   */\r\n/* payload of a qNaN or sNaN.                                         */\r\n/* ------------------------------------------------------------------ */\r\nInt decFloatGetCoefficient(const decFloat *df, uByte *bcdar) {\r\n  if (DFISINF(df)) memset(bcdar, 0, DECPMAX);\r\n   else {\r\n    GETCOEFF(df, bcdar);           // use macro\r\n    if (DFISNAN(df)) bcdar[0]=0;   // MSD needs correcting\r\n    }\r\n  return GETSIGN(df);\r\n  } // decFloatGetCoefficient\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatGetExponent -- get unbiased exponent                       */\r\n/*                                                                    */\r\n/*  df is the decFloat from which to extract the exponent             */\r\n/*  returns the exponent, q.                                          */\r\n/*                                                                    */\r\n/* No error is possible, and no status will be set.  If df is a       */\r\n/* special value the first seven bits of the decFloat are returned,   */\r\n/* left adjusted and with the first (sign) bit set to 0 (followed by  */\r\n/* 25 0 bits).  e.g., -sNaN would return 0x7e000000 (DECFLOAT_sNaN).  */\r\n/* ------------------------------------------------------------------ */\r\nInt decFloatGetExponent(const decFloat *df) {\r\n  if (DFISSPECIAL(df)) return DFWORD(df, 0)&0x7e000000;\r\n  return GETEXPUN(df);\r\n  } // decFloatGetExponent\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatSetCoefficient -- set coefficient from BCD8                */\r\n/*                                                                    */\r\n/*  df is the target decFloat (and source of exponent/special value)  */\r\n/*  bcdar holds DECPMAX digits to set the coefficient from, one       */\r\n/*    digit in each byte (BCD8 encoding); the first (MSD) is ignored  */\r\n/*    if df is a NaN; all are ignored if df is infinite.              */\r\n/*  sig is DECFLOAT_Sign to set the sign bit, 0 otherwise             */\r\n/*  returns df, which will be canonical                               */\r\n/*                                                                    */\r\n/* No error is possible, and no status will be set.                   */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatSetCoefficient(decFloat *df, const uByte *bcdar,\r\n                                  Int sig) {\r\n  uInt exp;                        // for exponent\r\n  uByte bcdzero[DECPMAX];          // for infinities\r\n\r\n  // Exponent/special code is extracted from df\r\n  if (DFISSPECIAL(df)) {\r\n    exp=DFWORD(df, 0)&0x7e000000;\r\n    if (DFISINF(df)) {\r\n      memset(bcdzero, 0, DECPMAX);\r\n      return decFloatFromBCD(df, exp, bcdzero, sig);\r\n      }\r\n    }\r\n   else exp=GETEXPUN(df);\r\n  return decFloatFromBCD(df, exp, bcdar, sig);\r\n  } // decFloatSetCoefficient\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatSetExponent -- set exponent or special value               */\r\n/*                                                                    */\r\n/*  df  is the target decFloat (and source of coefficient/payload)    */\r\n/*  set is the context for reporting status                           */\r\n/*  exp is the unbiased exponent, q, or a special value in the form   */\r\n/*    returned by decFloatGetExponent                                 */\r\n/*  returns df, which will be canonical                               */\r\n/*                                                                    */\r\n/* No error is possible, but Overflow or Underflow might occur.       */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatSetExponent(decFloat *df, decContext *set, Int exp) {\r\n  uByte  bcdcopy[DECPMAX];         // for coefficient\r\n  bcdnum num;                      // work\r\n  num.exponent=exp;\r\n  num.sign=decFloatGetCoefficient(df, bcdcopy); // extract coefficient\r\n  if (DFISSPECIAL(df)) {           // MSD or more needs correcting\r\n    if (DFISINF(df)) memset(bcdcopy, 0, DECPMAX);\r\n    bcdcopy[0]=0;\r\n    }\r\n  num.msd=bcdcopy;\r\n  num.lsd=bcdcopy+DECPMAX-1;\r\n  return decFinalize(df, &num, set);\r\n  } // decFloatSetExponent\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatRadix -- returns the base (10)                             */\r\n/*                                                                    */\r\n/*   df is any decFloat of this format                                */\r\n/* ------------------------------------------------------------------ */\r\nuInt decFloatRadix(const decFloat *df) {\r\n  if (df) return 10;                         // to placate compiler\r\n  return 10;\r\n  } // decFloatRadix\r\n\r\n/* The following function is not available if DECPRINT=0              */\r\n#if DECPRINT\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatShow -- printf a decFloat in hexadecimal and decimal       */\r\n/*   df  is the decFloat to show                                      */\r\n/*   tag is a tag string displayed with the number                    */\r\n/*                                                                    */\r\n/* This is a debug aid; the precise format of the string may change.  */\r\n/* ------------------------------------------------------------------ */\r\nvoid decFloatShow(const decFloat *df, const char *tag) {\r\n  char hexbuf[DECBYTES*2+DECBYTES/4+1]; // NB blank after every fourth\r\n  char buff[DECSTRING];                 // for value in decimal\r\n  Int i, j=0;\r\n\r\n  for (i=0; i<DECBYTES; i++) {\r\n    #if DECLITEND\r\n      sprintf(&hexbuf[j], \"%02x\", df->bytes[DECBYTES-1-i]);\r\n    #else\r\n      sprintf(&hexbuf[j], \"%02x\", df->bytes[i]);\r\n    #endif\r\n    j+=2;\r\n    // the next line adds blank (and terminator) after final pair, too\r\n    if ((i+1)%4==0) {strcpy(&hexbuf[j], \" \"); j++;}\r\n    }\r\n  decFloatToString(df, buff);\r\n  printf(\">%s> %s [big-endian]  %s\\n\", tag, hexbuf, buff);\r\n  return;\r\n  } // decFloatShow\r\n#endif\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatToBCD -- get sign, exponent, and BCD8 from a decFloat      */\r\n/*                                                                    */\r\n/*  df is the source decFloat                                         */\r\n/*  exp will be set to the unbiased exponent, q, or to a special      */\r\n/*    value in the form returned by decFloatGetExponent               */\r\n/*  bcdar is where DECPMAX bytes will be written, one BCD digit in    */\r\n/*    each byte (BCD8 encoding); if df is a NaN the first byte will   */\r\n/*    be zero, and if it is infinite they will all be zero            */\r\n/*  returns the sign of the coefficient (DECFLOAT_Sign if negative,   */\r\n/*    0 otherwise)                                                    */\r\n/*                                                                    */\r\n/* No error is possible, and no status will be set.                   */\r\n/* ------------------------------------------------------------------ */\r\nInt decFloatToBCD(const decFloat *df, Int *exp, uByte *bcdar) {\r\n  if (DFISINF(df)) {\r\n    memset(bcdar, 0, DECPMAX);\r\n    *exp=DFWORD(df, 0)&0x7e000000;\r\n    }\r\n   else {\r\n    GETCOEFF(df, bcdar);           // use macro\r\n    if (DFISNAN(df)) {\r\n      bcdar[0]=0;                  // MSD needs correcting\r\n      *exp=DFWORD(df, 0)&0x7e000000;\r\n      }\r\n     else {                        // finite\r\n      *exp=GETEXPUN(df);\r\n      }\r\n    }\r\n  return GETSIGN(df);\r\n  } // decFloatToBCD\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatToEngString -- conversion to numeric string, engineering   */\r\n/*                                                                    */\r\n/*  df is the decFloat format number to convert                       */\r\n/*  string is the string where the result will be laid out            */\r\n/*                                                                    */\r\n/* string must be at least DECPMAX+9 characters (the worst case is    */\r\n/* \"-0.00000nnn...nnn\\0\", which is as long as the exponent form when  */\r\n/* DECEMAXD<=4); this condition is asserted above                     */\r\n/*                                                                    */\r\n/* No error is possible, and no status will be set                    */\r\n/* ------------------------------------------------------------------ */\r\nchar * decFloatToEngString(const decFloat *df, char *string){\r\n  uInt msd;                        // coefficient MSD\r\n  Int  exp;                        // exponent top two bits or full\r\n  uInt comb;                       // combination field\r\n  char *cstart;                    // coefficient start\r\n  char *c;                         // output pointer in string\r\n  char *s, *t;                     // .. (source, target)\r\n  Int  pre, e;                     // work\r\n  const uByte *u;                  // ..\r\n  uInt  uiwork;                    // for macros [one compiler needs\r\n                                   // volatile here to avoid bug, but\r\n                                   // that doubles execution time]\r\n\r\n  // Source words; macro handles endianness\r\n  uInt sourhi=DFWORD(df, 0);       // word with sign\r\n  #if DECPMAX==16\r\n  uInt sourlo=DFWORD(df, 1);\r\n  #elif DECPMAX==34\r\n  uInt sourmh=DFWORD(df, 1);\r\n  uInt sourml=DFWORD(df, 2);\r\n  uInt sourlo=DFWORD(df, 3);\r\n  #endif\r\n\r\n  c=string;                        // where result will go\r\n  if (((Int)sourhi)<0) *c++='-';   // handle sign\r\n  comb=sourhi>>26;                 // sign+combination field\r\n  msd=DECCOMBMSD[comb];            // decode the combination field\r\n  exp=DECCOMBEXP[comb];            // ..\r\n\r\n  if (EXPISSPECIAL(exp)) {         // special\r\n    if (exp==DECFLOAT_Inf) {       // infinity\r\n      strcpy(c,   \"Inf\");\r\n      strcpy(c+3, \"inity\");\r\n      return string;               // easy\r\n      }\r\n    if (sourhi&0x02000000) *c++='s'; // sNaN\r\n    strcpy(c, \"NaN\");              // complete word\r\n    c+=3;                          // step past\r\n    // quick exit if the payload is zero\r\n    #if DECPMAX==7\r\n    if ((sourhi&0x000fffff)==0) return string;\r\n    #elif DECPMAX==16\r\n    if (sourlo==0 && (sourhi&0x0003ffff)==0) return string;\r\n    #elif DECPMAX==34\r\n    if (sourlo==0 && sourml==0 && sourmh==0\r\n     && (sourhi&0x00003fff)==0) return string;\r\n    #endif\r\n    // otherwise drop through to add integer; set correct exp etc.\r\n    exp=0; msd=0;                  // setup for following code\r\n    }\r\n   else { // complete exponent; top two bits are in place\r\n    exp+=GETECON(df)-DECBIAS;      // .. + continuation and unbias\r\n    }\r\n\r\n  /* convert the digits of the significand to characters */\r\n  cstart=c;                        // save start of coefficient\r\n  if (msd) *c++=(char)('0'+(char)msd);  // non-zero most significant digit\r\n\r\n  // Decode the declets.  After extracting each declet, it is\r\n  // decoded to a 4-uByte sequence by table lookup; the four uBytes\r\n  // are the three encoded BCD8 digits followed by a 1-byte length\r\n  // (significant digits, except that 000 has length 0).  This allows\r\n  // us to left-align the first declet with non-zero content, then\r\n  // the remaining ones are full 3-char length.  Fixed-length copies\r\n  // are used because variable-length memcpy causes a subroutine call\r\n  // in at least two compilers.  (The copies are length 4 for speed\r\n  // and are safe because the last item in the array is of length\r\n  // three and has the length byte following.)\r\n  #define dpd2char(dpdin) u=&DPD2BCD8[((dpdin)&0x3ff)*4];        \\\r\n         if (c!=cstart) {UBFROMUI(c, UBTOUI(u)|CHARMASK); c+=3;} \\\r\n          else if (*(u+3)) {                                     \\\r\n           UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); c+=*(u+3);}\r\n\r\n  #if DECPMAX==7\r\n  dpd2char(sourhi>>10);                 // declet 1\r\n  dpd2char(sourhi);                     // declet 2\r\n\r\n  #elif DECPMAX==16\r\n  dpd2char(sourhi>>8);                  // declet 1\r\n  dpd2char((sourhi<<2) | (sourlo>>30)); // declet 2\r\n  dpd2char(sourlo>>20);                 // declet 3\r\n  dpd2char(sourlo>>10);                 // declet 4\r\n  dpd2char(sourlo);                     // declet 5\r\n\r\n  #elif DECPMAX==34\r\n  dpd2char(sourhi>>4);                  // declet 1\r\n  dpd2char((sourhi<<6) | (sourmh>>26)); // declet 2\r\n  dpd2char(sourmh>>16);                 // declet 3\r\n  dpd2char(sourmh>>6);                  // declet 4\r\n  dpd2char((sourmh<<4) | (sourml>>28)); // declet 5\r\n  dpd2char(sourml>>18);                 // declet 6\r\n  dpd2char(sourml>>8);                  // declet 7\r\n  dpd2char((sourml<<2) | (sourlo>>30)); // declet 8\r\n  dpd2char(sourlo>>20);                 // declet 9\r\n  dpd2char(sourlo>>10);                 // declet 10\r\n  dpd2char(sourlo);                     // declet 11\r\n  #endif\r\n\r\n  if (c==cstart) *c++='0';         // all zeros, empty -- make \"0\"\r\n\r\n  if (exp==0) {                    // integer or NaN case -- easy\r\n    *c='\\0';                       // terminate\r\n    return string;\r\n    }\r\n  /* non-0 exponent */\r\n\r\n  e=0;                             // assume no E\r\n  pre=(Int)(c-cstart)+exp;         // length+exp  [c->LSD+1]\r\n  // [here, pre-exp is the digits count (==1 for zero)]\r\n\r\n  if (exp>0 || pre<-5) {           // need exponential form\r\n    e=pre-1;                       // calculate E value\r\n    pre=1;                         // assume one digit before '.'\r\n    if (e!=0) {                    // engineering: may need to adjust\r\n      Int adj;                     // adjustment\r\n      // The C remainder operator is undefined for negative numbers, so\r\n      // a positive remainder calculation must be used here\r\n      if (e<0) {\r\n        adj=(-e)%3;\r\n        if (adj!=0) adj=3-adj;\r\n        }\r\n       else { // e>0\r\n        adj=e%3;\r\n        }\r\n      e=e-adj;\r\n      // if dealing with zero still produce an exponent which is a\r\n      // multiple of three, as expected, but there will only be the\r\n      // one zero before the E, still.  Otherwise note the padding.\r\n      if (!DFISZERO(df)) pre+=adj;\r\n       else {  // is zero\r\n        if (adj!=0) {              // 0.00Esnn needed\r\n          e=e+3;\r\n          pre=-(2-adj);\r\n          }\r\n        } // zero\r\n      } // engineering adjustment\r\n    } // exponential form\r\n  // printf(\"e=%ld pre=%ld exp=%ld\\n\", (LI)e, (LI)pre, (LI)exp);\r\n\r\n  /* modify the coefficient, adding 0s, '.', and E+nn as needed */\r\n  if (pre>0) {                     // ddd.ddd (plain), perhaps with E\r\n                                   // or dd00 padding for engineering\r\n    char *dotat=cstart+pre;\r\n    if (dotat<c) {                      // if embedded dot needed...\r\n      // move by fours; there must be space for junk at the end\r\n      // because there is still space for exponent\r\n      s=dotat+ROUNDDOWN4(c-dotat);      // source\r\n      t=s+1;                            // target\r\n      // open the gap [cannot use memcpy]\r\n      for (; s>=dotat; s-=4, t-=4) UBFROMUI(t, UBTOUI(s));\r\n      *dotat='.';\r\n      c++;                              // length increased by one\r\n      } // need dot?\r\n     else for (; c<dotat; c++) *c='0';  // pad for engineering\r\n    } // pre>0\r\n   else {\r\n    /* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (may have\r\n       E, but only for 0.00E+3 kind of case -- with plenty of spare\r\n       space in this case */\r\n    pre=-pre+2;                         // gap width, including \"0.\"\r\n    t=cstart+ROUNDDOWN4(c-cstart)+pre;  // preferred first target point\r\n    // backoff if too far to the right\r\n    if (t>string+DECSTRING-5) t=string+DECSTRING-5; // adjust to fit\r\n    // now shift the entire coefficient to the right, being careful not\r\n    // to access to the left of string [cannot use memcpy]\r\n    for (s=t-pre; s>=string; s-=4, t-=4) UBFROMUI(t, UBTOUI(s));\r\n    // for Quads and Singles there may be a character or two left...\r\n    s+=3;                               // where next would come from\r\n    for(; s>=cstart; s--, t--) *(t+3)=*(s);\r\n    // now have fill 0. through 0.00000; use overlaps to avoid tests\r\n    if (pre>=4) {\r\n      memcpy(cstart+pre-4, \"0000\", 4);\r\n      memcpy(cstart, \"0.00\", 4);\r\n      }\r\n     else { // 2 or 3\r\n      *(cstart+pre-1)='0';\r\n      memcpy(cstart, \"0.\", 2);\r\n      }\r\n    c+=pre;                             // to end\r\n    }\r\n\r\n  // finally add the E-part, if needed; it will never be 0, and has\r\n  // a maximum length of 3 or 4 digits (asserted above)\r\n  if (e!=0) {\r\n    memcpy(c, \"E+\", 2);                 // starts with E, assume +\r\n    c++;\r\n    if (e<0) {\r\n      *c='-';                           // oops, need '-'\r\n      e=-e;                             // uInt, please\r\n      }\r\n    c++;\r\n    // Three-character exponents are easy; 4-character a little trickier\r\n    #if DECEMAXD<=3\r\n      u=&BIN2BCD8[e*4];                 // -> 3 digits + length byte\r\n      // copy fixed 4 characters [is safe], starting at non-zero\r\n      // and with character mask to convert BCD to char\r\n      UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK);\r\n      c+=*(u+3);                        // bump pointer appropriately\r\n    #elif DECEMAXD==4\r\n      if (e<1000) {                     // 3 (or fewer) digits case\r\n        u=&BIN2BCD8[e*4];               // -> 3 digits + length byte\r\n        UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); // [as above]\r\n        c+=*(u+3);                      // bump pointer appropriately\r\n        }\r\n       else {                           // 4-digits\r\n        Int thou=((e>>3)*1049)>>17;     // e/1000\r\n        Int rem=e-(1000*thou);          // e%1000\r\n        *c++=(char)('0'+(char)thou);    // the thousands digit\r\n        u=&BIN2BCD8[rem*4];             // -> 3 digits + length byte\r\n        UBFROMUI(c, UBTOUI(u)|CHARMASK);// copy fixed 3+1 characters [is safe]\r\n        c+=3;                           // bump pointer, always 3 digits\r\n        }\r\n    #endif\r\n    }\r\n  *c='\\0';                              // terminate\r\n  //printf(\"res %s\\n\", string);\r\n  return string;\r\n  } // decFloatToEngString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatToPacked -- convert decFloat to Packed decimal + exponent  */\r\n/*                                                                    */\r\n/*  df is the source decFloat                                         */\r\n/*  exp will be set to the unbiased exponent, q, or to a special      */\r\n/*    value in the form returned by decFloatGetExponent               */\r\n/*  packed is where DECPMAX nibbles will be written with the sign as  */\r\n/*    final nibble (0x0c for +, 0x0d for -); a NaN has a first nibble */\r\n/*    of zero, and an infinity is all zeros. decDouble and decQuad    */\r\n/*    have a additional leading zero nibble, leading to result        */\r\n/*    lengths of 4, 9, and 18 bytes.                                  */\r\n/*  returns the sign of the coefficient (DECFLOAT_Sign if negative,   */\r\n/*    0 otherwise)                                                    */\r\n/*                                                                    */\r\n/* No error is possible, and no status will be set.                   */\r\n/* ------------------------------------------------------------------ */\r\nInt decFloatToPacked(const decFloat *df, Int *exp, uByte *packed) {\r\n  uByte bcdar[DECPMAX+2];          // work buffer\r\n  uByte *ip=bcdar, *op=packed;     // work pointers\r\n  if (DFISINF(df)) {\r\n    memset(bcdar, 0, DECPMAX+2);\r\n    *exp=DECFLOAT_Inf;\r\n    }\r\n   else {\r\n    GETCOEFF(df, bcdar+1);         // use macro\r\n    if (DFISNAN(df)) {\r\n      bcdar[1]=0;                  // MSD needs clearing\r\n      *exp=DFWORD(df, 0)&0x7e000000;\r\n      }\r\n     else {                        // finite\r\n      *exp=GETEXPUN(df);\r\n      }\r\n    }\r\n  // now pack; coefficient currently at bcdar+1\r\n  #if SINGLE\r\n    ip++;                          // ignore first byte\r\n  #else\r\n    *ip=0;                         // need leading zero\r\n  #endif\r\n  // set final byte to Packed BCD sign value\r\n  bcdar[DECPMAX+1]=(DFISSIGNED(df) ? DECPMINUS : DECPPLUS);\r\n  // pack an even number of bytes...\r\n  for (; op<packed+((DECPMAX+2)/2); op++, ip+=2) {\r\n    *op=(uByte)((*ip<<4)+*(ip+1));\r\n    }\r\n  return (bcdar[DECPMAX+1]==DECPMINUS ? DECFLOAT_Sign : 0);\r\n  } // decFloatToPacked\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatToString -- conversion to numeric string                   */\r\n/*                                                                    */\r\n/*  df is the decFloat format number to convert                       */\r\n/*  string is the string where the result will be laid out            */\r\n/*                                                                    */\r\n/* string must be at least DECPMAX+9 characters (the worst case is    */\r\n/* \"-0.00000nnn...nnn\\0\", which is as long as the exponent form when  */\r\n/* DECEMAXD<=4); this condition is asserted above                     */\r\n/*                                                                    */\r\n/* No error is possible, and no status will be set                    */\r\n/* ------------------------------------------------------------------ */\r\nchar * decFloatToString(const decFloat *df, char *string){\r\n  uInt msd;                        // coefficient MSD\r\n  Int  exp;                        // exponent top two bits or full\r\n  uInt comb;                       // combination field\r\n  char *cstart;                    // coefficient start\r\n  char *c;                         // output pointer in string\r\n  char *s, *t;                     // .. (source, target)\r\n  Int  pre, e;                     // work\r\n  const uByte *u;                  // ..\r\n  uInt  uiwork;                    // for macros [one compiler needs\r\n                                   // volatile here to avoid bug, but\r\n                                   // that doubles execution time]\r\n\r\n  // Source words; macro handles endianness\r\n  uInt sourhi=DFWORD(df, 0);       // word with sign\r\n  #if DECPMAX==16\r\n  uInt sourlo=DFWORD(df, 1);\r\n  #elif DECPMAX==34\r\n  uInt sourmh=DFWORD(df, 1);\r\n  uInt sourml=DFWORD(df, 2);\r\n  uInt sourlo=DFWORD(df, 3);\r\n  #endif\r\n\r\n  c=string;                        // where result will go\r\n  if (((Int)sourhi)<0) *c++='-';   // handle sign\r\n  comb=sourhi>>26;                 // sign+combination field\r\n  msd=DECCOMBMSD[comb];            // decode the combination field\r\n  exp=DECCOMBEXP[comb];            // ..\r\n\r\n  if (!EXPISSPECIAL(exp)) {        // finite\r\n    // complete exponent; top two bits are in place\r\n    exp+=GETECON(df)-DECBIAS;      // .. + continuation and unbias\r\n    }\r\n   else {                          // IS special\r\n    if (exp==DECFLOAT_Inf) {       // infinity\r\n      strcpy(c, \"Infinity\");\r\n      return string;               // easy\r\n      }\r\n    if (sourhi&0x02000000) *c++='s'; // sNaN\r\n    strcpy(c, \"NaN\");              // complete word\r\n    c+=3;                          // step past\r\n    // quick exit if the payload is zero\r\n    #if DECPMAX==7\r\n    if ((sourhi&0x000fffff)==0) return string;\r\n    #elif DECPMAX==16\r\n    if (sourlo==0 && (sourhi&0x0003ffff)==0) return string;\r\n    #elif DECPMAX==34\r\n    if (sourlo==0 && sourml==0 && sourmh==0\r\n     && (sourhi&0x00003fff)==0) return string;\r\n    #endif\r\n    // otherwise drop through to add integer; set correct exp etc.\r\n    exp=0; msd=0;                  // setup for following code\r\n    }\r\n\r\n  /* convert the digits of the significand to characters */\r\n  cstart=c;                        // save start of coefficient\r\n  if (msd) *c++=(char)('0'+(char)msd);  // non-zero most significant digit\r\n\r\n  // Decode the declets.  After extracting each declet, it is\r\n  // decoded to a 4-uByte sequence by table lookup; the four uBytes\r\n  // are the three encoded BCD8 digits followed by a 1-byte length\r\n  // (significant digits, except that 000 has length 0).  This allows\r\n  // us to left-align the first declet with non-zero content, then\r\n  // the remaining ones are full 3-char length.  Fixed-length copies\r\n  // are used because variable-length memcpy causes a subroutine call\r\n  // in at least two compilers.  (The copies are length 4 for speed\r\n  // and are safe because the last item in the array is of length\r\n  // three and has the length byte following.)\r\n  #define dpd2char(dpdin) u=&DPD2BCD8[((dpdin)&0x3ff)*4];        \\\r\n         if (c!=cstart) {UBFROMUI(c, UBTOUI(u)|CHARMASK); c+=3;} \\\r\n          else if (*(u+3)) {                                     \\\r\n           UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); c+=*(u+3);}\r\n\r\n  #if DECPMAX==7\r\n  dpd2char(sourhi>>10);                 // declet 1\r\n  dpd2char(sourhi);                     // declet 2\r\n\r\n  #elif DECPMAX==16\r\n  dpd2char(sourhi>>8);                  // declet 1\r\n  dpd2char((sourhi<<2) | (sourlo>>30)); // declet 2\r\n  dpd2char(sourlo>>20);                 // declet 3\r\n  dpd2char(sourlo>>10);                 // declet 4\r\n  dpd2char(sourlo);                     // declet 5\r\n\r\n  #elif DECPMAX==34\r\n  dpd2char(sourhi>>4);                  // declet 1\r\n  dpd2char((sourhi<<6) | (sourmh>>26)); // declet 2\r\n  dpd2char(sourmh>>16);                 // declet 3\r\n  dpd2char(sourmh>>6);                  // declet 4\r\n  dpd2char((sourmh<<4) | (sourml>>28)); // declet 5\r\n  dpd2char(sourml>>18);                 // declet 6\r\n  dpd2char(sourml>>8);                  // declet 7\r\n  dpd2char((sourml<<2) | (sourlo>>30)); // declet 8\r\n  dpd2char(sourlo>>20);                 // declet 9\r\n  dpd2char(sourlo>>10);                 // declet 10\r\n  dpd2char(sourlo);                     // declet 11\r\n  #endif\r\n\r\n  if (c==cstart) *c++='0';         // all zeros, empty -- make \"0\"\r\n\r\n  //[This fast path is valid but adds 3-5 cycles to worst case length]\r\n  //if (exp==0) {                  // integer or NaN case -- easy\r\n  //  *c='\\0';                     // terminate\r\n  //  return string;\r\n  //  }\r\n\r\n  e=0;                             // assume no E\r\n  pre=(Int)(c-cstart)+exp;         // length+exp  [c->LSD+1]\r\n  // [here, pre-exp is the digits count (==1 for zero)]\r\n\r\n  if (exp>0 || pre<-5) {           // need exponential form\r\n    e=pre-1;                       // calculate E value\r\n    pre=1;                         // assume one digit before '.'\r\n    } // exponential form\r\n\r\n  /* modify the coefficient, adding 0s, '.', and E+nn as needed */\r\n  if (pre>0) {                     // ddd.ddd (plain), perhaps with E\r\n    char *dotat=cstart+pre;\r\n    if (dotat<c) {                      // if embedded dot needed...\r\n      // [memmove is a disaster, here]\r\n      // move by fours; there must be space for junk at the end\r\n      // because exponent is still possible\r\n      s=dotat+ROUNDDOWN4(c-dotat);      // source\r\n      t=s+1;                            // target\r\n      // open the gap [cannot use memcpy]\r\n      for (; s>=dotat; s-=4, t-=4) UBFROMUI(t, UBTOUI(s));\r\n      *dotat='.';\r\n      c++;                              // length increased by one\r\n      } // need dot?\r\n\r\n    // finally add the E-part, if needed; it will never be 0, and has\r\n    // a maximum length of 3 or 4 digits (asserted above)\r\n    if (e!=0) {\r\n      memcpy(c, \"E+\", 2);               // starts with E, assume +\r\n      c++;\r\n      if (e<0) {\r\n        *c='-';                         // oops, need '-'\r\n        e=-e;                           // uInt, please\r\n        }\r\n      c++;\r\n      // Three-character exponents are easy; 4-character a little trickier\r\n      #if DECEMAXD<=3\r\n        u=&BIN2BCD8[e*4];               // -> 3 digits + length byte\r\n        // copy fixed 4 characters [is safe], starting at non-zero\r\n        // and with character mask to convert BCD to char\r\n        UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK);\r\n        c+=*(u+3);                      // bump pointer appropriately\r\n      #elif DECEMAXD==4\r\n        if (e<1000) {                   // 3 (or fewer) digits case\r\n          u=&BIN2BCD8[e*4];             // -> 3 digits + length byte\r\n          UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); // [as above]\r\n          c+=*(u+3);                    // bump pointer appropriately\r\n          }\r\n         else {                         // 4-digits\r\n          Int thou=((e>>3)*1049)>>17;   // e/1000\r\n          Int rem=e-(1000*thou);        // e%1000\r\n          *c++=(char)('0'+(char)thou);  // the thousands digit\r\n          u=&BIN2BCD8[rem*4];           // -> 3 digits + length byte\r\n          UBFROMUI(c, UBTOUI(u)|CHARMASK); // copy fixed 3+1 characters [is safe]\r\n          c+=3;                         // bump pointer, always 3 digits\r\n          }\r\n      #endif\r\n      }\r\n    *c='\\0';                            // add terminator\r\n    //printf(\"res %s\\n\", string);\r\n    return string;\r\n    } // pre>0\r\n\r\n  /* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (can never have E) */\r\n  // Surprisingly, this is close to being the worst-case path, so the\r\n  // shift is done by fours; this is a little tricky because the\r\n  // rightmost character to be written must not be beyond where the\r\n  // rightmost terminator could be -- so backoff to not touch\r\n  // terminator position if need be (this can make exact alignments\r\n  // for full Doubles, but in some cases needs care not to access too\r\n  // far to the left)\r\n\r\n  pre=-pre+2;                           // gap width, including \"0.\"\r\n  t=cstart+ROUNDDOWN4(c-cstart)+pre;    // preferred first target point\r\n  // backoff if too far to the right\r\n  if (t>string+DECSTRING-5) t=string+DECSTRING-5; // adjust to fit\r\n  // now shift the entire coefficient to the right, being careful not\r\n  // to access to the left of string [cannot use memcpy]\r\n  for (s=t-pre; s>=string; s-=4, t-=4) UBFROMUI(t, UBTOUI(s));\r\n  // for Quads and Singles there may be a character or two left...\r\n  s+=3;                                 // where next would come from\r\n  for(; s>=cstart; s--, t--) *(t+3)=*(s);\r\n  // now have fill 0. through 0.00000; use overlaps to avoid tests\r\n  if (pre>=4) {\r\n    memcpy(cstart+pre-4, \"0000\", 4);\r\n    memcpy(cstart, \"0.00\", 4);\r\n    }\r\n   else { // 2 or 3\r\n    *(cstart+pre-1)='0';\r\n    memcpy(cstart, \"0.\", 2);\r\n    }\r\n  *(c+pre)='\\0';                        // terminate\r\n  return string;\r\n  } // decFloatToString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatToWider -- conversion to next-wider format                 */\r\n/*                                                                    */\r\n/*  source  is the decFloat format number which gets the result of    */\r\n/*          the conversion                                            */\r\n/*  wider   is the decFloatWider format number which will be narrowed */\r\n/*  returns wider                                                     */\r\n/*                                                                    */\r\n/* Widening is always exact; no status is set (sNaNs are copied and   */\r\n/* do not signal).  The result will be canonical if the source is,    */\r\n/* and may or may not be if the source is not.                        */\r\n/* ------------------------------------------------------------------ */\r\n// widening is not possible for decQuad format numbers; simply omit\r\n#if !QUAD\r\ndecFloatWider * decFloatToWider(const decFloat *source, decFloatWider *wider) {\r\n  uInt msd;\r\n\r\n  /* Construct and copy the sign word */\r\n  if (DFISSPECIAL(source)) {\r\n    // copy sign, combination, and first bit of exponent (sNaN selector)\r\n    DFWWORD(wider, 0)=DFWORD(source, 0)&0xfe000000;\r\n    msd=0;\r\n    }\r\n   else { // is finite number\r\n    uInt exp=GETEXPUN(source)+DECWBIAS; // get unbiased exponent and rebias\r\n    uInt code=(exp>>DECWECONL)<<29;     // set two bits of exp [msd=0]\r\n    code|=(exp<<(32-6-DECWECONL)) & 0x03ffffff; // add exponent continuation\r\n    code|=DFWORD(source, 0)&0x80000000; // add sign\r\n    DFWWORD(wider, 0)=code;             // .. and place top word in wider\r\n    msd=GETMSD(source);                 // get source coefficient MSD [0-9]\r\n    }\r\n  /* Copy the coefficient and clear any 'unused' words to left */\r\n  #if SINGLE\r\n    DFWWORD(wider, 1)=(DFWORD(source, 0)&0x000fffff)|(msd<<20);\r\n  #elif DOUBLE\r\n    DFWWORD(wider, 2)=(DFWORD(source, 0)&0x0003ffff)|(msd<<18);\r\n    DFWWORD(wider, 3)=DFWORD(source, 1);\r\n    DFWWORD(wider, 1)=0;\r\n  #endif\r\n  return wider;\r\n  } // decFloatToWider\r\n#endif\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatVersion -- return package version string                   */\r\n/*                                                                    */\r\n/*  returns a constant string describing this package                 */\r\n/* ------------------------------------------------------------------ */\r\nconst char *decFloatVersion(void) {\r\n  return DECVERSION;\r\n  } // decFloatVersion\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFloatZero -- set to canonical (integer) zero                    */\r\n/*                                                                    */\r\n/*  df is the decFloat format number to integer +0 (q=0, c=+0)        */\r\n/*  returns df                                                        */\r\n/*                                                                    */\r\n/* No error is possible, and no status can be set.                    */\r\n/* ------------------------------------------------------------------ */\r\ndecFloat * decFloatZero(decFloat *df){\r\n  DFWORD(df, 0)=ZEROWORD;     // set appropriate top word\r\n  #if DOUBLE || QUAD\r\n    DFWORD(df, 1)=0;\r\n    #if QUAD\r\n      DFWORD(df, 2)=0;\r\n      DFWORD(df, 3)=0;\r\n    #endif\r\n  #endif\r\n  // decFloatShow(df, \"zero\");\r\n  return df;\r\n  } // decFloatZero\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* Private generic function (not format-specific) for development use */\r\n/* ------------------------------------------------------------------ */\r\n// This is included once only, for all to use\r\n#if QUAD && (DECCHECK || DECTRACE)\r\n  /* ---------------------------------------------------------------- */\r\n  /* decShowNum -- display bcd8 number in debug form                  */\r\n  /*                                                                  */\r\n  /*   num is the bcdnum to display                                   */\r\n  /*   tag is a string to label the display                           */\r\n  /* ---------------------------------------------------------------- */\r\n  void decShowNum(const bcdnum *num, const char *tag) {\r\n    const char *csign=\"+\";              // sign character\r\n    uByte *ub;                          // work\r\n    uInt  uiwork;                       // for macros\r\n    if (num->sign==DECFLOAT_Sign) csign=\"-\";\r\n\r\n    printf(\">%s> \", tag);\r\n    if (num->exponent==DECFLOAT_Inf) printf(\"%sInfinity\", csign);\r\n    else if (num->exponent==DECFLOAT_qNaN) printf(\"%sqNaN\", csign);\r\n    else if (num->exponent==DECFLOAT_sNaN) printf(\"%ssNaN\", csign);\r\n    else {                              // finite\r\n     char qbuf[10];                     // for right-aligned q\r\n     char *c;                           // work\r\n     const uByte *u;                    // ..\r\n     Int e=num->exponent;               // .. exponent\r\n     strcpy(qbuf, \"q=\");\r\n     c=&qbuf[2];                        // where exponent will go\r\n     // lay out the exponent\r\n     if (e<0) {\r\n       *c++='-';                        // add '-'\r\n       e=-e;                            // uInt, please\r\n       }\r\n     #if DECEMAXD>4\r\n       #error Exponent form is too long for ShowNum to lay out\r\n     #endif\r\n     if (e==0) *c++='0';                // 0-length case\r\n      else if (e<1000) {                // 3 (or fewer) digits case\r\n       u=&BIN2BCD8[e*4];                // -> 3 digits + length byte\r\n       UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); // [as above]\r\n       c+=*(u+3);                       // bump pointer appropriately\r\n       }\r\n      else {                            // 4-digits\r\n       Int thou=((e>>3)*1049)>>17;      // e/1000\r\n       Int rem=e-(1000*thou);           // e%1000\r\n       *c++=(char)('0'+(char)thou);     // the thousands digit\r\n       u=&BIN2BCD8[rem*4];              // -> 3 digits + length byte\r\n       UBFROMUI(c, UBTOUI(u)|CHARMASK); // copy fixed 3+1 characters [is safe]\r\n       c+=3;                            // bump pointer, always 3 digits\r\n       }\r\n     *c='\\0';                           // add terminator\r\n     printf(\"%7s c=%s\", qbuf, csign);\r\n     }\r\n\r\n    if (!EXPISSPECIAL(num->exponent) || num->msd!=num->lsd || *num->lsd!=0) {\r\n      for (ub=num->msd; ub<=num->lsd; ub++) { // coefficient...\r\n        printf(\"%1x\", *ub);\r\n        if ((num->lsd-ub)%3==0 && ub!=num->lsd) printf(\" \"); // 4-space\r\n        }\r\n      }\r\n    printf(\"\\n\");\r\n    } // decShowNum\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decContext.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Context module                                             */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2009.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This module comprises the routines for handling arithmetic         */\r\n/* context structures.                                                */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#include <string.h>           // for strcmp\r\n#include <stdio.h>            // for printf if DECCHECK\r\n#include \"decContext.h\"       // context and base types\r\n#include \"decNumberLocal.h\"   // decNumber local types, etc.\r\n\r\n/* compile-time endian tester [assumes sizeof(Int)>1] */\r\nstatic  const  Int mfcone=1;                       // constant 1\r\nstatic  const  Flag *mfctop=(const Flag *)&mfcone; // -> top byte\r\n#define LITEND *mfctop        // named flag; 1=little-endian\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* round-for-reround digits                                           */\r\n/* ------------------------------------------------------------------ */\r\nconst uByte DECSTICKYTAB[10]={1,1,2,3,4,6,6,7,8,9}; /* used if sticky */\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* Powers of ten (powers[n]==10**n, 0<=n<=9)                          */\r\n/* ------------------------------------------------------------------ */\r\nconst uInt DECPOWERS[10]={1, 10, 100, 1000, 10000, 100000, 1000000,\r\n                          10000000, 100000000, 1000000000};\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextClearStatus -- clear bits in current status              */\r\n/*                                                                    */\r\n/*  context is the context structure to be queried                    */\r\n/*  mask indicates the bits to be cleared (the status bit that        */\r\n/*    corresponds to each 1 bit in the mask is cleared)               */\r\n/*  returns context                                                   */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecContext *decContextClearStatus(decContext *context, uInt mask) {\r\n  context->status&=~mask;\r\n  return context;\r\n  } // decContextClearStatus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextDefault -- initialize a context structure                */\r\n/*                                                                    */\r\n/*  context is the structure to be initialized                        */\r\n/*  kind selects the required set of default values, one of:          */\r\n/*      DEC_INIT_BASE       -- select ANSI X3-274 defaults            */\r\n/*      DEC_INIT_DECIMAL32  -- select IEEE 754 defaults, 32-bit       */\r\n/*      DEC_INIT_DECIMAL64  -- select IEEE 754 defaults, 64-bit       */\r\n/*      DEC_INIT_DECIMAL128 -- select IEEE 754 defaults, 128-bit      */\r\n/*      For any other value a valid context is returned, but with     */\r\n/*      Invalid_operation set in the status field.                    */\r\n/*  returns a context structure with the appropriate initial values.  */\r\n/* ------------------------------------------------------------------ */\r\ndecContext * decContextDefault(decContext *context, Int kind) {\r\n  // set defaults...\r\n  context->digits=9;                         // 9 digits\r\n  context->emax=DEC_MAX_EMAX;                // 9-digit exponents\r\n  context->emin=DEC_MIN_EMIN;                // .. balanced\r\n  context->round=DEC_ROUND_HALF_UP;          // 0.5 rises\r\n  context->traps=DEC_Errors;                 // all but informational\r\n  context->status=0;                         // cleared\r\n  context->clamp=0;                          // no clamping\r\n  #if DECSUBSET\r\n  context->extended=0;                       // cleared\r\n  #endif\r\n  switch (kind) {\r\n    case DEC_INIT_BASE:\r\n      // [use defaults]\r\n      break;\r\n    case DEC_INIT_DECIMAL32:\r\n      context->digits=7;                     // digits\r\n      context->emax=96;                      // Emax\r\n      context->emin=-95;                     // Emin\r\n      context->round=DEC_ROUND_HALF_EVEN;    // 0.5 to nearest even\r\n      context->traps=0;                      // no traps set\r\n      context->clamp=1;                      // clamp exponents\r\n      #if DECSUBSET\r\n      context->extended=1;                   // set\r\n      #endif\r\n      break;\r\n    case DEC_INIT_DECIMAL64:\r\n      context->digits=16;                    // digits\r\n      context->emax=384;                     // Emax\r\n      context->emin=-383;                    // Emin\r\n      context->round=DEC_ROUND_HALF_EVEN;    // 0.5 to nearest even\r\n      context->traps=0;                      // no traps set\r\n      context->clamp=1;                      // clamp exponents\r\n      #if DECSUBSET\r\n      context->extended=1;                   // set\r\n      #endif\r\n      break;\r\n    case DEC_INIT_DECIMAL128:\r\n      context->digits=34;                    // digits\r\n      context->emax=6144;                    // Emax\r\n      context->emin=-6143;                   // Emin\r\n      context->round=DEC_ROUND_HALF_EVEN;    // 0.5 to nearest even\r\n      context->traps=0;                      // no traps set\r\n      context->clamp=1;                      // clamp exponents\r\n      #if DECSUBSET\r\n      context->extended=1;                   // set\r\n      #endif\r\n      break;\r\n\r\n    default:                                 // invalid Kind\r\n      // use defaults, and ..\r\n      decContextSetStatus(context, DEC_Invalid_operation); // trap\r\n    }\r\n\r\n  return context;} // decContextDefault\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextGetRounding -- return current rounding mode              */\r\n/*                                                                    */\r\n/*  context is the context structure to be queried                    */\r\n/*  returns the rounding mode                                         */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\nenum rounding decContextGetRounding(decContext *context) {\r\n  return context->round;\r\n  } // decContextGetRounding\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextGetStatus -- return current status                       */\r\n/*                                                                    */\r\n/*  context is the context structure to be queried                    */\r\n/*  returns status                                                    */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\nuInt decContextGetStatus(decContext *context) {\r\n  return context->status;\r\n  } // decContextGetStatus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextRestoreStatus -- restore bits in current status          */\r\n/*                                                                    */\r\n/*  context is the context structure to be updated                    */\r\n/*  newstatus is the source for the bits to be restored               */\r\n/*  mask indicates the bits to be restored (the status bit that       */\r\n/*    corresponds to each 1 bit in the mask is set to the value of    */\r\n/*    the correspnding bit in newstatus)                              */\r\n/*  returns context                                                   */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecContext *decContextRestoreStatus(decContext *context,\r\n                                    uInt newstatus, uInt mask) {\r\n  context->status&=~mask;               // clear the selected bits\r\n  context->status|=(mask&newstatus);    // or in the new bits\r\n  return context;\r\n  } // decContextRestoreStatus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextSaveStatus -- save bits in current status                */\r\n/*                                                                    */\r\n/*  context is the context structure to be queried                    */\r\n/*  mask indicates the bits to be saved (the status bits that         */\r\n/*    correspond to each 1 bit in the mask are saved)                 */\r\n/*  returns the AND of the mask and the current status                */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\nuInt decContextSaveStatus(decContext *context, uInt mask) {\r\n  return context->status&mask;\r\n  } // decContextSaveStatus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextSetRounding -- set current rounding mode                 */\r\n/*                                                                    */\r\n/*  context is the context structure to be updated                    */\r\n/*  newround is the value which will replace the current mode         */\r\n/*  returns context                                                   */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecContext *decContextSetRounding(decContext *context,\r\n                                  enum rounding newround) {\r\n  context->round=newround;\r\n  return context;\r\n  } // decContextSetRounding\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextSetStatus -- set status and raise trap if appropriate    */\r\n/*                                                                    */\r\n/*  context is the context structure to be updated                    */\r\n/*  status  is the DEC_ exception code                                */\r\n/*  returns the context structure                                     */\r\n/*                                                                    */\r\n/* Control may never return from this routine, if there is a signal   */\r\n/* handler and it takes a long jump.                                  */\r\n/* ------------------------------------------------------------------ */\r\ndecContext * decContextSetStatus(decContext *context, uInt status) {\r\n  context->status|=status;\r\n  if (status & context->traps) raise(SIGFPE);\r\n  return context;} // decContextSetStatus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextSetStatusFromString -- set status from a string + trap   */\r\n/*                                                                    */\r\n/*  context is the context structure to be updated                    */\r\n/*  string is a string exactly equal to one that might be returned    */\r\n/*            by decContextStatusToString                             */\r\n/*                                                                    */\r\n/*  The status bit corresponding to the string is set, and a trap     */\r\n/*  is raised if appropriate.                                         */\r\n/*                                                                    */\r\n/*  returns the context structure, unless the string is equal to      */\r\n/*    DEC_Condition_MU or is not recognized.  In these cases NULL is  */\r\n/*    returned.                                                       */\r\n/* ------------------------------------------------------------------ */\r\ndecContext * decContextSetStatusFromString(decContext *context,\r\n                                           const char *string) {\r\n  if (strcmp(string, DEC_Condition_CS)==0)\r\n    return decContextSetStatus(context, DEC_Conversion_syntax);\r\n  if (strcmp(string, DEC_Condition_DZ)==0)\r\n    return decContextSetStatus(context, DEC_Division_by_zero);\r\n  if (strcmp(string, DEC_Condition_DI)==0)\r\n    return decContextSetStatus(context, DEC_Division_impossible);\r\n  if (strcmp(string, DEC_Condition_DU)==0)\r\n    return decContextSetStatus(context, DEC_Division_undefined);\r\n  if (strcmp(string, DEC_Condition_IE)==0)\r\n    return decContextSetStatus(context, DEC_Inexact);\r\n  if (strcmp(string, DEC_Condition_IS)==0)\r\n    return decContextSetStatus(context, DEC_Insufficient_storage);\r\n  if (strcmp(string, DEC_Condition_IC)==0)\r\n    return decContextSetStatus(context, DEC_Invalid_context);\r\n  if (strcmp(string, DEC_Condition_IO)==0)\r\n    return decContextSetStatus(context, DEC_Invalid_operation);\r\n  #if DECSUBSET\r\n  if (strcmp(string, DEC_Condition_LD)==0)\r\n    return decContextSetStatus(context, DEC_Lost_digits);\r\n  #endif\r\n  if (strcmp(string, DEC_Condition_OV)==0)\r\n    return decContextSetStatus(context, DEC_Overflow);\r\n  if (strcmp(string, DEC_Condition_PA)==0)\r\n    return decContextSetStatus(context, DEC_Clamped);\r\n  if (strcmp(string, DEC_Condition_RO)==0)\r\n    return decContextSetStatus(context, DEC_Rounded);\r\n  if (strcmp(string, DEC_Condition_SU)==0)\r\n    return decContextSetStatus(context, DEC_Subnormal);\r\n  if (strcmp(string, DEC_Condition_UN)==0)\r\n    return decContextSetStatus(context, DEC_Underflow);\r\n  if (strcmp(string, DEC_Condition_ZE)==0)\r\n    return context;\r\n  return NULL;  // Multiple status, or unknown\r\n  } // decContextSetStatusFromString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextSetStatusFromStringQuiet -- set status from a string     */\r\n/*                                                                    */\r\n/*  context is the context structure to be updated                    */\r\n/*  string is a string exactly equal to one that might be returned    */\r\n/*            by decContextStatusToString                             */\r\n/*                                                                    */\r\n/*  The status bit corresponding to the string is set; no trap is     */\r\n/*  raised.                                                           */\r\n/*                                                                    */\r\n/*  returns the context structure, unless the string is equal to      */\r\n/*    DEC_Condition_MU or is not recognized.  In these cases NULL is  */\r\n/*    returned.                                                       */\r\n/* ------------------------------------------------------------------ */\r\ndecContext * decContextSetStatusFromStringQuiet(decContext *context,\r\n                                                const char *string) {\r\n  if (strcmp(string, DEC_Condition_CS)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Conversion_syntax);\r\n  if (strcmp(string, DEC_Condition_DZ)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Division_by_zero);\r\n  if (strcmp(string, DEC_Condition_DI)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Division_impossible);\r\n  if (strcmp(string, DEC_Condition_DU)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Division_undefined);\r\n  if (strcmp(string, DEC_Condition_IE)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Inexact);\r\n  if (strcmp(string, DEC_Condition_IS)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Insufficient_storage);\r\n  if (strcmp(string, DEC_Condition_IC)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Invalid_context);\r\n  if (strcmp(string, DEC_Condition_IO)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Invalid_operation);\r\n  #if DECSUBSET\r\n  if (strcmp(string, DEC_Condition_LD)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Lost_digits);\r\n  #endif\r\n  if (strcmp(string, DEC_Condition_OV)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Overflow);\r\n  if (strcmp(string, DEC_Condition_PA)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Clamped);\r\n  if (strcmp(string, DEC_Condition_RO)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Rounded);\r\n  if (strcmp(string, DEC_Condition_SU)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Subnormal);\r\n  if (strcmp(string, DEC_Condition_UN)==0)\r\n    return decContextSetStatusQuiet(context, DEC_Underflow);\r\n  if (strcmp(string, DEC_Condition_ZE)==0)\r\n    return context;\r\n  return NULL;  // Multiple status, or unknown\r\n  } // decContextSetStatusFromStringQuiet\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextSetStatusQuiet -- set status without trap                */\r\n/*                                                                    */\r\n/*  context is the context structure to be updated                    */\r\n/*  status  is the DEC_ exception code                                */\r\n/*  returns the context structure                                     */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecContext * decContextSetStatusQuiet(decContext *context, uInt status) {\r\n  context->status|=status;\r\n  return context;} // decContextSetStatusQuiet\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextStatusToString -- convert status flags to a string       */\r\n/*                                                                    */\r\n/*  context is a context with valid status field                      */\r\n/*                                                                    */\r\n/*  returns a constant string describing the condition.  If multiple  */\r\n/*    (or no) flags are set, a generic constant message is returned.  */\r\n/* ------------------------------------------------------------------ */\r\nconst char *decContextStatusToString(const decContext *context) {\r\n  Int status=context->status;\r\n\r\n  // test the five IEEE first, as some of the others are ambiguous when\r\n  // DECEXTFLAG=0\r\n  if (status==DEC_Invalid_operation    ) return DEC_Condition_IO;\r\n  if (status==DEC_Division_by_zero     ) return DEC_Condition_DZ;\r\n  if (status==DEC_Overflow             ) return DEC_Condition_OV;\r\n  if (status==DEC_Underflow            ) return DEC_Condition_UN;\r\n  if (status==DEC_Inexact              ) return DEC_Condition_IE;\r\n\r\n  if (status==DEC_Division_impossible  ) return DEC_Condition_DI;\r\n  if (status==DEC_Division_undefined   ) return DEC_Condition_DU;\r\n  if (status==DEC_Rounded              ) return DEC_Condition_RO;\r\n  if (status==DEC_Clamped              ) return DEC_Condition_PA;\r\n  if (status==DEC_Subnormal            ) return DEC_Condition_SU;\r\n  if (status==DEC_Conversion_syntax    ) return DEC_Condition_CS;\r\n  if (status==DEC_Insufficient_storage ) return DEC_Condition_IS;\r\n  if (status==DEC_Invalid_context      ) return DEC_Condition_IC;\r\n  #if DECSUBSET\r\n  if (status==DEC_Lost_digits          ) return DEC_Condition_LD;\r\n  #endif\r\n  if (status==0                        ) return DEC_Condition_ZE;\r\n  return DEC_Condition_MU;  // Multiple errors\r\n  } // decContextStatusToString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextTestEndian -- test whether DECLITEND is set correctly    */\r\n/*                                                                    */\r\n/*  quiet is 1 to suppress message; 0 otherwise                       */\r\n/*  returns 0 if DECLITEND is correct                                 */\r\n/*          1 if DECLITEND is incorrect and should be 1               */\r\n/*         -1 if DECLITEND is incorrect and should be 0               */\r\n/*                                                                    */\r\n/* A message is displayed if the return value is not 0 and quiet==0.  */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\nInt decContextTestEndian(Flag quiet) {\r\n  Int res=0;                  // optimist\r\n  uInt dle=(uInt)DECLITEND;   // unsign\r\n  if (dle>1) dle=1;           // ensure 0 or 1\r\n\r\n  if (LITEND!=DECLITEND) {\r\n    if (!quiet) {             // always refer to this\r\n      #if DECPRINT\r\n      const char *adj;\r\n      if (LITEND) adj=\"little\";\r\n             else adj=\"big\";\r\n      printf(\"Warning: DECLITEND is set to %d, but this computer appears to be %s-endian\\n\",\r\n             DECLITEND, adj);\r\n      #endif\r\n      }\r\n    res=(Int)LITEND-dle;\r\n    }\r\n  return res;\r\n  } // decContextTestEndian\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextTestSavedStatus -- test bits in saved status             */\r\n/*                                                                    */\r\n/*  oldstatus is the status word to be tested                         */\r\n/*  mask indicates the bits to be tested (the oldstatus bits that     */\r\n/*    correspond to each 1 bit in the mask are tested)                */\r\n/*  returns 1 if any of the tested bits are 1, or 0 otherwise         */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\nuInt decContextTestSavedStatus(uInt oldstatus, uInt mask) {\r\n  return (oldstatus&mask)!=0;\r\n  } // decContextTestSavedStatus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextTestStatus -- test bits in current status                */\r\n/*                                                                    */\r\n/*  context is the context structure to be updated                    */\r\n/*  mask indicates the bits to be tested (the status bits that        */\r\n/*    correspond to each 1 bit in the mask are tested)                */\r\n/*  returns 1 if any of the tested bits are 1, or 0 otherwise         */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\nuInt decContextTestStatus(decContext *context, uInt mask) {\r\n  return (context->status&mask)!=0;\r\n  } // decContextTestStatus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decContextZeroStatus -- clear all status bits                      */\r\n/*                                                                    */\r\n/*  context is the context structure to be updated                    */\r\n/*  returns context                                                   */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecContext *decContextZeroStatus(decContext *context) {\r\n  context->status=0;\r\n  return context;\r\n  } // decContextZeroStatus\r\n\r\n"
  },
  {
    "path": "vendor/decNumber/decContext.h",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Context module header                                      */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2010.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/*                                                                    */\r\n/* Context variables must always have valid values:                   */\r\n/*                                                                    */\r\n/*  status   -- [any bits may be cleared, but not set, by user]       */\r\n/*  round    -- must be one of the enumerated rounding modes          */\r\n/*                                                                    */\r\n/* The following variables are implied for fixed size formats (i.e.,  */\r\n/* they are ignored) but should still be set correctly in case used   */\r\n/* with decNumber functions:                                          */\r\n/*                                                                    */\r\n/*  clamp    -- must be either 0 or 1                                 */\r\n/*  digits   -- must be in the range 1 through 999999999              */\r\n/*  emax     -- must be in the range 0 through 999999999              */\r\n/*  emin     -- must be in the range 0 through -999999999             */\r\n/*  extended -- must be either 0 or 1 [present only if DECSUBSET]     */\r\n/*  traps    -- only defined bits may be set                          */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#if !defined(DECCONTEXT)\r\n  #define DECCONTEXT\r\n  #define DECCNAME     \"decContext\"                     /* Short name */\r\n  #define DECCFULLNAME \"Decimal Context Descriptor\"   /* Verbose name */\r\n  #define DECCAUTHOR   \"Mike Cowlishaw\"               /* Who to blame */\r\n\r\n  #if !defined(int32_t)\r\n    #include <stdint.h>            /* C99 standard integers           */\r\n  #endif\r\n  #include <stdio.h>               /* for printf, etc.                */\r\n  #include <signal.h>              /* for traps                       */\r\n\r\n  /* Extended flags setting -- set this to 0 to use only IEEE flags   */\r\n  #if !defined(DECEXTFLAG)\r\n  #define DECEXTFLAG 1             /* 1=enable extended flags         */\r\n  #endif\r\n\r\n  /* Conditional code flag -- set this to 0 for best performance      */\r\n  #if !defined(DECSUBSET)\r\n  #define DECSUBSET  0             /* 1=enable subset arithmetic      */\r\n  #endif\r\n\r\n  /* Context for operations, with associated constants                */\r\n  enum rounding {\r\n    DEC_ROUND_CEILING,             /* round towards +infinity         */\r\n    DEC_ROUND_UP,                  /* round away from 0               */\r\n    DEC_ROUND_HALF_UP,             /* 0.5 rounds up                   */\r\n    DEC_ROUND_HALF_EVEN,           /* 0.5 rounds to nearest even      */\r\n    DEC_ROUND_HALF_DOWN,           /* 0.5 rounds down                 */\r\n    DEC_ROUND_DOWN,                /* round towards 0 (truncate)      */\r\n    DEC_ROUND_FLOOR,               /* round towards -infinity         */\r\n    DEC_ROUND_05UP,                /* round for reround               */\r\n    DEC_ROUND_MAX                  /* enum must be less than this     */\r\n    };\r\n  #define DEC_ROUND_DEFAULT DEC_ROUND_HALF_EVEN;\r\n\r\n  typedef struct {\r\n    int32_t  digits;               /* working precision               */\r\n    int32_t  emax;                 /* maximum positive exponent       */\r\n    int32_t  emin;                 /* minimum negative exponent       */\r\n    enum     rounding round;       /* rounding mode                   */\r\n    uint32_t traps;                /* trap-enabler flags              */\r\n    uint32_t status;               /* status flags                    */\r\n    uint8_t  clamp;                /* flag: apply IEEE exponent clamp */\r\n    #if DECSUBSET\r\n    uint8_t  extended;             /* flag: special-values allowed    */\r\n    #endif\r\n    } decContext;\r\n\r\n  /* Maxima and Minima for context settings                           */\r\n  #define DEC_MAX_DIGITS 999999999\r\n  #define DEC_MIN_DIGITS         1\r\n  #define DEC_MAX_EMAX   999999999\r\n  #define DEC_MIN_EMAX           0\r\n  #define DEC_MAX_EMIN           0\r\n  #define DEC_MIN_EMIN  -999999999\r\n  #define DEC_MAX_MATH      999999 /* max emax, etc., for math funcs. */\r\n\r\n  /* Classifications for decimal numbers, aligned with 754 (note that */\r\n  /* 'normal' and 'subnormal' are meaningful only with a decContext   */\r\n  /* or a fixed size format).                                         */\r\n  enum decClass {\r\n    DEC_CLASS_SNAN,\r\n    DEC_CLASS_QNAN,\r\n    DEC_CLASS_NEG_INF,\r\n    DEC_CLASS_NEG_NORMAL,\r\n    DEC_CLASS_NEG_SUBNORMAL,\r\n    DEC_CLASS_NEG_ZERO,\r\n    DEC_CLASS_POS_ZERO,\r\n    DEC_CLASS_POS_SUBNORMAL,\r\n    DEC_CLASS_POS_NORMAL,\r\n    DEC_CLASS_POS_INF\r\n    };\r\n  /* Strings for the decClasses */\r\n  #define DEC_ClassString_SN  \"sNaN\"\r\n  #define DEC_ClassString_QN  \"NaN\"\r\n  #define DEC_ClassString_NI  \"-Infinity\"\r\n  #define DEC_ClassString_NN  \"-Normal\"\r\n  #define DEC_ClassString_NS  \"-Subnormal\"\r\n  #define DEC_ClassString_NZ  \"-Zero\"\r\n  #define DEC_ClassString_PZ  \"+Zero\"\r\n  #define DEC_ClassString_PS  \"+Subnormal\"\r\n  #define DEC_ClassString_PN  \"+Normal\"\r\n  #define DEC_ClassString_PI  \"+Infinity\"\r\n  #define DEC_ClassString_UN  \"Invalid\"\r\n\r\n  /* Trap-enabler and Status flags (exceptional conditions), and      */\r\n  /* their names.  The top byte is reserved for internal use          */\r\n  #if DECEXTFLAG\r\n    /* Extended flags */\r\n    #define DEC_Conversion_syntax    0x00000001\r\n    #define DEC_Division_by_zero     0x00000002\r\n    #define DEC_Division_impossible  0x00000004\r\n    #define DEC_Division_undefined   0x00000008\r\n    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */\r\n    #define DEC_Inexact              0x00000020\r\n    #define DEC_Invalid_context      0x00000040\r\n    #define DEC_Invalid_operation    0x00000080\r\n    #if DECSUBSET\r\n    #define DEC_Lost_digits          0x00000100\r\n    #endif\r\n    #define DEC_Overflow             0x00000200\r\n    #define DEC_Clamped              0x00000400\r\n    #define DEC_Rounded              0x00000800\r\n    #define DEC_Subnormal            0x00001000\r\n    #define DEC_Underflow            0x00002000\r\n  #else\r\n    /* IEEE flags only */\r\n    #define DEC_Conversion_syntax    0x00000010\r\n    #define DEC_Division_by_zero     0x00000002\r\n    #define DEC_Division_impossible  0x00000010\r\n    #define DEC_Division_undefined   0x00000010\r\n    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */\r\n    #define DEC_Inexact              0x00000001\r\n    #define DEC_Invalid_context      0x00000010\r\n    #define DEC_Invalid_operation    0x00000010\r\n    #if DECSUBSET\r\n    #define DEC_Lost_digits          0x00000000\r\n    #endif\r\n    #define DEC_Overflow             0x00000008\r\n    #define DEC_Clamped              0x00000000\r\n    #define DEC_Rounded              0x00000000\r\n    #define DEC_Subnormal            0x00000000\r\n    #define DEC_Underflow            0x00000004\r\n  #endif\r\n\r\n  /* IEEE 754 groupings for the flags                                 */\r\n  /* [DEC_Clamped, DEC_Lost_digits, DEC_Rounded, and DEC_Subnormal    */\r\n  /* are not in IEEE 754]                                             */\r\n  #define DEC_IEEE_754_Division_by_zero  (DEC_Division_by_zero)\r\n  #if DECSUBSET\r\n  #define DEC_IEEE_754_Inexact           (DEC_Inexact | DEC_Lost_digits)\r\n  #else\r\n  #define DEC_IEEE_754_Inexact           (DEC_Inexact)\r\n  #endif\r\n  #define DEC_IEEE_754_Invalid_operation (DEC_Conversion_syntax |     \\\r\n                                          DEC_Division_impossible |   \\\r\n                                          DEC_Division_undefined |    \\\r\n                                          DEC_Insufficient_storage |  \\\r\n                                          DEC_Invalid_context |       \\\r\n                                          DEC_Invalid_operation)\r\n  #define DEC_IEEE_754_Overflow          (DEC_Overflow)\r\n  #define DEC_IEEE_754_Underflow         (DEC_Underflow)\r\n\r\n  /* flags which are normally errors (result is qNaN, infinite, or 0) */\r\n  #define DEC_Errors (DEC_IEEE_754_Division_by_zero |                 \\\r\n                      DEC_IEEE_754_Invalid_operation |                \\\r\n                      DEC_IEEE_754_Overflow | DEC_IEEE_754_Underflow)\r\n  /* flags which cause a result to become qNaN                        */\r\n  #define DEC_NaNs    DEC_IEEE_754_Invalid_operation\r\n\r\n  /* flags which are normally for information only (finite results)   */\r\n  #if DECSUBSET\r\n  #define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact    \\\r\n                          | DEC_Lost_digits)\r\n  #else\r\n  #define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact)\r\n  #endif\r\n\r\n  /* IEEE 854 names (for compatibility with older decNumber versions) */\r\n  #define DEC_IEEE_854_Division_by_zero  DEC_IEEE_754_Division_by_zero\r\n  #define DEC_IEEE_854_Inexact           DEC_IEEE_754_Inexact\r\n  #define DEC_IEEE_854_Invalid_operation DEC_IEEE_754_Invalid_operation\r\n  #define DEC_IEEE_854_Overflow          DEC_IEEE_754_Overflow\r\n  #define DEC_IEEE_854_Underflow         DEC_IEEE_754_Underflow\r\n\r\n  /* Name strings for the exceptional conditions                      */\r\n  #define DEC_Condition_CS \"Conversion syntax\"\r\n  #define DEC_Condition_DZ \"Division by zero\"\r\n  #define DEC_Condition_DI \"Division impossible\"\r\n  #define DEC_Condition_DU \"Division undefined\"\r\n  #define DEC_Condition_IE \"Inexact\"\r\n  #define DEC_Condition_IS \"Insufficient storage\"\r\n  #define DEC_Condition_IC \"Invalid context\"\r\n  #define DEC_Condition_IO \"Invalid operation\"\r\n  #if DECSUBSET\r\n  #define DEC_Condition_LD \"Lost digits\"\r\n  #endif\r\n  #define DEC_Condition_OV \"Overflow\"\r\n  #define DEC_Condition_PA \"Clamped\"\r\n  #define DEC_Condition_RO \"Rounded\"\r\n  #define DEC_Condition_SU \"Subnormal\"\r\n  #define DEC_Condition_UN \"Underflow\"\r\n  #define DEC_Condition_ZE \"No status\"\r\n  #define DEC_Condition_MU \"Multiple status\"\r\n  #define DEC_Condition_Length 21  /* length of the longest string,   */\r\n                                   /* including terminator            */\r\n\r\n  /* Initialization descriptors, used by decContextDefault            */\r\n  #define DEC_INIT_BASE         0\r\n  #define DEC_INIT_DECIMAL32   32\r\n  #define DEC_INIT_DECIMAL64   64\r\n  #define DEC_INIT_DECIMAL128 128\r\n  /* Synonyms */\r\n  #define DEC_INIT_DECSINGLE  DEC_INIT_DECIMAL32\r\n  #define DEC_INIT_DECDOUBLE  DEC_INIT_DECIMAL64\r\n  #define DEC_INIT_DECQUAD    DEC_INIT_DECIMAL128\r\n\r\n  /* decContext routines                                              */\r\n  extern decContext  * decContextClearStatus(decContext *, uint32_t);\r\n  extern decContext  * decContextDefault(decContext *, int32_t);\r\n  extern enum rounding decContextGetRounding(decContext *);\r\n  extern uint32_t      decContextGetStatus(decContext *);\r\n  extern decContext  * decContextRestoreStatus(decContext *, uint32_t, uint32_t);\r\n  extern uint32_t      decContextSaveStatus(decContext *, uint32_t);\r\n  extern decContext  * decContextSetRounding(decContext *, enum rounding);\r\n  extern decContext  * decContextSetStatus(decContext *, uint32_t);\r\n  extern decContext  * decContextSetStatusFromString(decContext *, const char *);\r\n  extern decContext  * decContextSetStatusFromStringQuiet(decContext *, const char *);\r\n  extern decContext  * decContextSetStatusQuiet(decContext *, uint32_t);\r\n  extern const char  * decContextStatusToString(const decContext *);\r\n  extern int32_t       decContextTestEndian(uint8_t);\r\n  extern uint32_t      decContextTestSavedStatus(uint32_t, uint32_t);\r\n  extern uint32_t      decContextTestStatus(decContext *, uint32_t);\r\n  extern decContext  * decContextZeroStatus(decContext *);\r\n\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decDPD.h",
    "content": "/* ------------------------------------------------------------------------ */\r\n/* Binary Coded Decimal and Densely Packed Decimal conversion lookup tables */\r\n/* [Automatically generated -- do not edit.  2008.06.21]                    */\r\n/* ------------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2008. All rights reserved.          */\r\n/* ------------------------------------------------------------------------ */\r\n/* For details, see DPDecimal.html on the General Decimal Arithmetic page.  */\r\n/*                                                                          */\r\n/* This include file defines several DPD and BCD conversion tables:         */\r\n/*                                                                          */\r\n/*   uint16_t BCD2DPD[2458];     -- BCD -> DPD (0x999 => 2457)              */\r\n/*   uint16_t BIN2DPD[1000];     -- Bin -> DPD (999 => 2457)                */\r\n/*   uint8_t  BIN2CHAR[4001];    -- Bin -> CHAR (999 => '\\3' '9' '9' '9')   */\r\n/*   uint8_t  BIN2BCD8[4000];    -- Bin -> bytes (999 => 9 9 9 3)           */\r\n/*   uint16_t DPD2BCD[1024];     -- DPD -> BCD (0x3FF => 0x999)             */\r\n/*   uint16_t DPD2BIN[1024];     -- DPD -> BIN (0x3FF => 999)               */\r\n/*   uint32_t DPD2BINK[1024];    -- DPD -> BIN * 1000 (0x3FF => 999000)     */\r\n/*   uint32_t DPD2BINM[1024];    -- DPD -> BIN * 1E+6 (0x3FF => 999000000)  */\r\n/*   uint8_t  DPD2BCD8[4096];    -- DPD -> bytes (x3FF => 9 9 9 3)          */\r\n/*                                                                          */\r\n/* In all cases the result (10 bits or 12 bits, or binary) is right-aligned */\r\n/* in the table entry.  BIN2CHAR entries are a single byte length (0 for    */\r\n/* value 0) followed by three digit characters; a trailing terminator is    */\r\n/* included to allow 4-char moves always.  BIN2BCD8 and DPD2BCD8 entries    */\r\n/* are similar with the three BCD8 digits followed by a one-byte length     */\r\n/* (again, length=0 for value 0).                                           */\r\n/*                                                                          */\r\n/* To use a table, its name, prefixed with DEC_, must be defined with a     */\r\n/* value of 1 before this header file is included.  For example:            */\r\n/*    #define DEC_BCD2DPD 1                                                 */\r\n/* This mechanism allows software to only include tables that are needed.   */\r\n/* ------------------------------------------------------------------------ */\r\n \r\n#if defined(DEC_BCD2DPD) && DEC_BCD2DPD==1 && !defined(DECBCD2DPD)\r\n#define DECBCD2DPD\r\n \r\nconst uint16_t BCD2DPD[2458]={    0,    1,    2,    3,    4,    5,    6,    7, \r\n    8,    9,    0,    0,    0,    0,    0,    0,   16,   17,   18,   19,   20, \r\n   21,   22,   23,   24,   25,    0,    0,    0,    0,    0,    0,   32,   33, \r\n   34,   35,   36,   37,   38,   39,   40,   41,    0,    0,    0,    0,    0, \r\n    0,   48,   49,   50,   51,   52,   53,   54,   55,   56,   57,    0,    0, \r\n    0,    0,    0,    0,   64,   65,   66,   67,   68,   69,   70,   71,   72, \r\n   73,    0,    0,    0,    0,    0,    0,   80,   81,   82,   83,   84,   85, \r\n   86,   87,   88,   89,    0,    0,    0,    0,    0,    0,   96,   97,   98, \r\n   99,  100,  101,  102,  103,  104,  105,    0,    0,    0,    0,    0,    0, \r\n  112,  113,  114,  115,  116,  117,  118,  119,  120,  121,    0,    0,    0, \r\n    0,    0,    0,   10,   11,   42,   43,   74,   75,  106,  107,   78,   79, \r\n    0,    0,    0,    0,    0,    0,   26,   27,   58,   59,   90,   91,  122, \r\n  123,   94,   95,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,  128,  129,  130,  131,  132,  133,  134,  135,  136,  137,    0,    0, \r\n    0,    0,    0,    0,  144,  145,  146,  147,  148,  149,  150,  151,  152, \r\n  153,    0,    0,    0,    0,    0,    0,  160,  161,  162,  163,  164,  165, \r\n  166,  167,  168,  169,    0,    0,    0,    0,    0,    0,  176,  177,  178, \r\n  179,  180,  181,  182,  183,  184,  185,    0,    0,    0,    0,    0,    0, \r\n  192,  193,  194,  195,  196,  197,  198,  199,  200,  201,    0,    0,    0, \r\n    0,    0,    0,  208,  209,  210,  211,  212,  213,  214,  215,  216,  217, \r\n    0,    0,    0,    0,    0,    0,  224,  225,  226,  227,  228,  229,  230, \r\n  231,  232,  233,    0,    0,    0,    0,    0,    0,  240,  241,  242,  243, \r\n  244,  245,  246,  247,  248,  249,    0,    0,    0,    0,    0,    0,  138, \r\n  139,  170,  171,  202,  203,  234,  235,  206,  207,    0,    0,    0,    0, \r\n    0,    0,  154,  155,  186,  187,  218,  219,  250,  251,  222,  223,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,  256,  257,  258, \r\n  259,  260,  261,  262,  263,  264,  265,    0,    0,    0,    0,    0,    0, \r\n  272,  273,  274,  275,  276,  277,  278,  279,  280,  281,    0,    0,    0, \r\n    0,    0,    0,  288,  289,  290,  291,  292,  293,  294,  295,  296,  297, \r\n    0,    0,    0,    0,    0,    0,  304,  305,  306,  307,  308,  309,  310, \r\n  311,  312,  313,    0,    0,    0,    0,    0,    0,  320,  321,  322,  323, \r\n  324,  325,  326,  327,  328,  329,    0,    0,    0,    0,    0,    0,  336, \r\n  337,  338,  339,  340,  341,  342,  343,  344,  345,    0,    0,    0,    0, \r\n    0,    0,  352,  353,  354,  355,  356,  357,  358,  359,  360,  361,    0, \r\n    0,    0,    0,    0,    0,  368,  369,  370,  371,  372,  373,  374,  375, \r\n  376,  377,    0,    0,    0,    0,    0,    0,  266,  267,  298,  299,  330, \r\n  331,  362,  363,  334,  335,    0,    0,    0,    0,    0,    0,  282,  283, \r\n  314,  315,  346,  347,  378,  379,  350,  351,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,  384,  385,  386,  387,  388,  389,  390, \r\n  391,  392,  393,    0,    0,    0,    0,    0,    0,  400,  401,  402,  403, \r\n  404,  405,  406,  407,  408,  409,    0,    0,    0,    0,    0,    0,  416, \r\n  417,  418,  419,  420,  421,  422,  423,  424,  425,    0,    0,    0,    0, \r\n    0,    0,  432,  433,  434,  435,  436,  437,  438,  439,  440,  441,    0, \r\n    0,    0,    0,    0,    0,  448,  449,  450,  451,  452,  453,  454,  455, \r\n  456,  457,    0,    0,    0,    0,    0,    0,  464,  465,  466,  467,  468, \r\n  469,  470,  471,  472,  473,    0,    0,    0,    0,    0,    0,  480,  481, \r\n  482,  483,  484,  485,  486,  487,  488,  489,    0,    0,    0,    0,    0, \r\n    0,  496,  497,  498,  499,  500,  501,  502,  503,  504,  505,    0,    0, \r\n    0,    0,    0,    0,  394,  395,  426,  427,  458,  459,  490,  491,  462, \r\n  463,    0,    0,    0,    0,    0,    0,  410,  411,  442,  443,  474,  475, \r\n  506,  507,  478,  479,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,  512,  513,  514,  515,  516,  517,  518,  519,  520,  521,    0, \r\n    0,    0,    0,    0,    0,  528,  529,  530,  531,  532,  533,  534,  535, \r\n  536,  537,    0,    0,    0,    0,    0,    0,  544,  545,  546,  547,  548, \r\n  549,  550,  551,  552,  553,    0,    0,    0,    0,    0,    0,  560,  561, \r\n  562,  563,  564,  565,  566,  567,  568,  569,    0,    0,    0,    0,    0, \r\n    0,  576,  577,  578,  579,  580,  581,  582,  583,  584,  585,    0,    0, \r\n    0,    0,    0,    0,  592,  593,  594,  595,  596,  597,  598,  599,  600, \r\n  601,    0,    0,    0,    0,    0,    0,  608,  609,  610,  611,  612,  613, \r\n  614,  615,  616,  617,    0,    0,    0,    0,    0,    0,  624,  625,  626, \r\n  627,  628,  629,  630,  631,  632,  633,    0,    0,    0,    0,    0,    0, \r\n  522,  523,  554,  555,  586,  587,  618,  619,  590,  591,    0,    0,    0, \r\n    0,    0,    0,  538,  539,  570,  571,  602,  603,  634,  635,  606,  607, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,  640,  641, \r\n  642,  643,  644,  645,  646,  647,  648,  649,    0,    0,    0,    0,    0, \r\n    0,  656,  657,  658,  659,  660,  661,  662,  663,  664,  665,    0,    0, \r\n    0,    0,    0,    0,  672,  673,  674,  675,  676,  677,  678,  679,  680, \r\n  681,    0,    0,    0,    0,    0,    0,  688,  689,  690,  691,  692,  693, \r\n  694,  695,  696,  697,    0,    0,    0,    0,    0,    0,  704,  705,  706, \r\n  707,  708,  709,  710,  711,  712,  713,    0,    0,    0,    0,    0,    0, \r\n  720,  721,  722,  723,  724,  725,  726,  727,  728,  729,    0,    0,    0, \r\n    0,    0,    0,  736,  737,  738,  739,  740,  741,  742,  743,  744,  745, \r\n    0,    0,    0,    0,    0,    0,  752,  753,  754,  755,  756,  757,  758, \r\n  759,  760,  761,    0,    0,    0,    0,    0,    0,  650,  651,  682,  683, \r\n  714,  715,  746,  747,  718,  719,    0,    0,    0,    0,    0,    0,  666, \r\n  667,  698,  699,  730,  731,  762,  763,  734,  735,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,  768,  769,  770,  771,  772,  773, \r\n  774,  775,  776,  777,    0,    0,    0,    0,    0,    0,  784,  785,  786, \r\n  787,  788,  789,  790,  791,  792,  793,    0,    0,    0,    0,    0,    0, \r\n  800,  801,  802,  803,  804,  805,  806,  807,  808,  809,    0,    0,    0, \r\n    0,    0,    0,  816,  817,  818,  819,  820,  821,  822,  823,  824,  825, \r\n    0,    0,    0,    0,    0,    0,  832,  833,  834,  835,  836,  837,  838, \r\n  839,  840,  841,    0,    0,    0,    0,    0,    0,  848,  849,  850,  851, \r\n  852,  853,  854,  855,  856,  857,    0,    0,    0,    0,    0,    0,  864, \r\n  865,  866,  867,  868,  869,  870,  871,  872,  873,    0,    0,    0,    0, \r\n    0,    0,  880,  881,  882,  883,  884,  885,  886,  887,  888,  889,    0, \r\n    0,    0,    0,    0,    0,  778,  779,  810,  811,  842,  843,  874,  875, \r\n  846,  847,    0,    0,    0,    0,    0,    0,  794,  795,  826,  827,  858, \r\n  859,  890,  891,  862,  863,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,  896,  897,  898,  899,  900,  901,  902,  903,  904,  905, \r\n    0,    0,    0,    0,    0,    0,  912,  913,  914,  915,  916,  917,  918, \r\n  919,  920,  921,    0,    0,    0,    0,    0,    0,  928,  929,  930,  931, \r\n  932,  933,  934,  935,  936,  937,    0,    0,    0,    0,    0,    0,  944, \r\n  945,  946,  947,  948,  949,  950,  951,  952,  953,    0,    0,    0,    0, \r\n    0,    0,  960,  961,  962,  963,  964,  965,  966,  967,  968,  969,    0, \r\n    0,    0,    0,    0,    0,  976,  977,  978,  979,  980,  981,  982,  983, \r\n  984,  985,    0,    0,    0,    0,    0,    0,  992,  993,  994,  995,  996, \r\n  997,  998,  999, 1000, 1001,    0,    0,    0,    0,    0,    0, 1008, 1009, \r\n 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,    0,    0,    0,    0,    0, \r\n    0,  906,  907,  938,  939,  970,  971, 1002, 1003,  974,  975,    0,    0, \r\n    0,    0,    0,    0,  922,  923,  954,  955,  986,  987, 1018, 1019,  990, \r\n  991,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,   12, \r\n   13,  268,  269,  524,  525,  780,  781,   46,   47,    0,    0,    0,    0, \r\n    0,    0,   28,   29,  284,  285,  540,  541,  796,  797,   62,   63,    0, \r\n    0,    0,    0,    0,    0,   44,   45,  300,  301,  556,  557,  812,  813, \r\n  302,  303,    0,    0,    0,    0,    0,    0,   60,   61,  316,  317,  572, \r\n  573,  828,  829,  318,  319,    0,    0,    0,    0,    0,    0,   76,   77, \r\n  332,  333,  588,  589,  844,  845,  558,  559,    0,    0,    0,    0,    0, \r\n    0,   92,   93,  348,  349,  604,  605,  860,  861,  574,  575,    0,    0, \r\n    0,    0,    0,    0,  108,  109,  364,  365,  620,  621,  876,  877,  814, \r\n  815,    0,    0,    0,    0,    0,    0,  124,  125,  380,  381,  636,  637, \r\n  892,  893,  830,  831,    0,    0,    0,    0,    0,    0,   14,   15,  270, \r\n  271,  526,  527,  782,  783,  110,  111,    0,    0,    0,    0,    0,    0, \r\n   30,   31,  286,  287,  542,  543,  798,  799,  126,  127,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, \r\n    0,    0,    0,    0,    0,    0,    0,    0,  140,  141,  396,  397,  652, \r\n  653,  908,  909,  174,  175,    0,    0,    0,    0,    0,    0,  156,  157, \r\n  412,  413,  668,  669,  924,  925,  190,  191,    0,    0,    0,    0,    0, \r\n    0,  172,  173,  428,  429,  684,  685,  940,  941,  430,  431,    0,    0, \r\n    0,    0,    0,    0,  188,  189,  444,  445,  700,  701,  956,  957,  446, \r\n  447,    0,    0,    0,    0,    0,    0,  204,  205,  460,  461,  716,  717, \r\n  972,  973,  686,  687,    0,    0,    0,    0,    0,    0,  220,  221,  476, \r\n  477,  732,  733,  988,  989,  702,  703,    0,    0,    0,    0,    0,    0, \r\n  236,  237,  492,  493,  748,  749, 1004, 1005,  942,  943,    0,    0,    0, \r\n    0,    0,    0,  252,  253,  508,  509,  764,  765, 1020, 1021,  958,  959, \r\n    0,    0,    0,    0,    0,    0,  142,  143,  398,  399,  654,  655,  910, \r\n  911,  238,  239,    0,    0,    0,    0,    0,    0,  158,  159,  414,  415, \r\n  670,  671,  926,  927,  254,  255};\r\n#endif\r\n \r\n#if defined(DEC_DPD2BCD) && DEC_DPD2BCD==1 && !defined(DECDPD2BCD)\r\n#define DECDPD2BCD\r\n \r\nconst uint16_t DPD2BCD[1024]={    0,    1,    2,    3,    4,    5,    6,    7, \r\n    8,    9,  128,  129, 2048, 2049, 2176, 2177,   16,   17,   18,   19,   20, \r\n   21,   22,   23,   24,   25,  144,  145, 2064, 2065, 2192, 2193,   32,   33, \r\n   34,   35,   36,   37,   38,   39,   40,   41,  130,  131, 2080, 2081, 2056, \r\n 2057,   48,   49,   50,   51,   52,   53,   54,   55,   56,   57,  146,  147, \r\n 2096, 2097, 2072, 2073,   64,   65,   66,   67,   68,   69,   70,   71,   72, \r\n   73,  132,  133, 2112, 2113,  136,  137,   80,   81,   82,   83,   84,   85, \r\n   86,   87,   88,   89,  148,  149, 2128, 2129,  152,  153,   96,   97,   98, \r\n   99,  100,  101,  102,  103,  104,  105,  134,  135, 2144, 2145, 2184, 2185, \r\n  112,  113,  114,  115,  116,  117,  118,  119,  120,  121,  150,  151, 2160, \r\n 2161, 2200, 2201,  256,  257,  258,  259,  260,  261,  262,  263,  264,  265, \r\n  384,  385, 2304, 2305, 2432, 2433,  272,  273,  274,  275,  276,  277,  278, \r\n  279,  280,  281,  400,  401, 2320, 2321, 2448, 2449,  288,  289,  290,  291, \r\n  292,  293,  294,  295,  296,  297,  386,  387, 2336, 2337, 2312, 2313,  304, \r\n  305,  306,  307,  308,  309,  310,  311,  312,  313,  402,  403, 2352, 2353, \r\n 2328, 2329,  320,  321,  322,  323,  324,  325,  326,  327,  328,  329,  388, \r\n  389, 2368, 2369,  392,  393,  336,  337,  338,  339,  340,  341,  342,  343, \r\n  344,  345,  404,  405, 2384, 2385,  408,  409,  352,  353,  354,  355,  356, \r\n  357,  358,  359,  360,  361,  390,  391, 2400, 2401, 2440, 2441,  368,  369, \r\n  370,  371,  372,  373,  374,  375,  376,  377,  406,  407, 2416, 2417, 2456, \r\n 2457,  512,  513,  514,  515,  516,  517,  518,  519,  520,  521,  640,  641, \r\n 2050, 2051, 2178, 2179,  528,  529,  530,  531,  532,  533,  534,  535,  536, \r\n  537,  656,  657, 2066, 2067, 2194, 2195,  544,  545,  546,  547,  548,  549, \r\n  550,  551,  552,  553,  642,  643, 2082, 2083, 2088, 2089,  560,  561,  562, \r\n  563,  564,  565,  566,  567,  568,  569,  658,  659, 2098, 2099, 2104, 2105, \r\n  576,  577,  578,  579,  580,  581,  582,  583,  584,  585,  644,  645, 2114, \r\n 2115,  648,  649,  592,  593,  594,  595,  596,  597,  598,  599,  600,  601, \r\n  660,  661, 2130, 2131,  664,  665,  608,  609,  610,  611,  612,  613,  614, \r\n  615,  616,  617,  646,  647, 2146, 2147, 2184, 2185,  624,  625,  626,  627, \r\n  628,  629,  630,  631,  632,  633,  662,  663, 2162, 2163, 2200, 2201,  768, \r\n  769,  770,  771,  772,  773,  774,  775,  776,  777,  896,  897, 2306, 2307, \r\n 2434, 2435,  784,  785,  786,  787,  788,  789,  790,  791,  792,  793,  912, \r\n  913, 2322, 2323, 2450, 2451,  800,  801,  802,  803,  804,  805,  806,  807, \r\n  808,  809,  898,  899, 2338, 2339, 2344, 2345,  816,  817,  818,  819,  820, \r\n  821,  822,  823,  824,  825,  914,  915, 2354, 2355, 2360, 2361,  832,  833, \r\n  834,  835,  836,  837,  838,  839,  840,  841,  900,  901, 2370, 2371,  904, \r\n  905,  848,  849,  850,  851,  852,  853,  854,  855,  856,  857,  916,  917, \r\n 2386, 2387,  920,  921,  864,  865,  866,  867,  868,  869,  870,  871,  872, \r\n  873,  902,  903, 2402, 2403, 2440, 2441,  880,  881,  882,  883,  884,  885, \r\n  886,  887,  888,  889,  918,  919, 2418, 2419, 2456, 2457, 1024, 1025, 1026, \r\n 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1152, 1153, 2052, 2053, 2180, 2181, \r\n 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1168, 1169, 2068, \r\n 2069, 2196, 2197, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, \r\n 1154, 1155, 2084, 2085, 2120, 2121, 1072, 1073, 1074, 1075, 1076, 1077, 1078, \r\n 1079, 1080, 1081, 1170, 1171, 2100, 2101, 2136, 2137, 1088, 1089, 1090, 1091, \r\n 1092, 1093, 1094, 1095, 1096, 1097, 1156, 1157, 2116, 2117, 1160, 1161, 1104, \r\n 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1172, 1173, 2132, 2133, \r\n 1176, 1177, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1158, \r\n 1159, 2148, 2149, 2184, 2185, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, \r\n 1144, 1145, 1174, 1175, 2164, 2165, 2200, 2201, 1280, 1281, 1282, 1283, 1284, \r\n 1285, 1286, 1287, 1288, 1289, 1408, 1409, 2308, 2309, 2436, 2437, 1296, 1297, \r\n 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1424, 1425, 2324, 2325, 2452, \r\n 2453, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1410, 1411, \r\n 2340, 2341, 2376, 2377, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, \r\n 1337, 1426, 1427, 2356, 2357, 2392, 2393, 1344, 1345, 1346, 1347, 1348, 1349, \r\n 1350, 1351, 1352, 1353, 1412, 1413, 2372, 2373, 1416, 1417, 1360, 1361, 1362, \r\n 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1428, 1429, 2388, 2389, 1432, 1433, \r\n 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1414, 1415, 2404, \r\n 2405, 2440, 2441, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, \r\n 1430, 1431, 2420, 2421, 2456, 2457, 1536, 1537, 1538, 1539, 1540, 1541, 1542, \r\n 1543, 1544, 1545, 1664, 1665, 2054, 2055, 2182, 2183, 1552, 1553, 1554, 1555, \r\n 1556, 1557, 1558, 1559, 1560, 1561, 1680, 1681, 2070, 2071, 2198, 2199, 1568, \r\n 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1666, 1667, 2086, 2087, \r\n 2152, 2153, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1682, \r\n 1683, 2102, 2103, 2168, 2169, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, \r\n 1608, 1609, 1668, 1669, 2118, 2119, 1672, 1673, 1616, 1617, 1618, 1619, 1620, \r\n 1621, 1622, 1623, 1624, 1625, 1684, 1685, 2134, 2135, 1688, 1689, 1632, 1633, \r\n 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1670, 1671, 2150, 2151, 2184, \r\n 2185, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1686, 1687, \r\n 2166, 2167, 2200, 2201, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, \r\n 1801, 1920, 1921, 2310, 2311, 2438, 2439, 1808, 1809, 1810, 1811, 1812, 1813, \r\n 1814, 1815, 1816, 1817, 1936, 1937, 2326, 2327, 2454, 2455, 1824, 1825, 1826, \r\n 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1922, 1923, 2342, 2343, 2408, 2409, \r\n 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1938, 1939, 2358, \r\n 2359, 2424, 2425, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, \r\n 1924, 1925, 2374, 2375, 1928, 1929, 1872, 1873, 1874, 1875, 1876, 1877, 1878, \r\n 1879, 1880, 1881, 1940, 1941, 2390, 2391, 1944, 1945, 1888, 1889, 1890, 1891, \r\n 1892, 1893, 1894, 1895, 1896, 1897, 1926, 1927, 2406, 2407, 2440, 2441, 1904, \r\n 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1942, 1943, 2422, 2423, \r\n 2456, 2457};\r\n#endif\r\n \r\n#if defined(DEC_BIN2DPD) && DEC_BIN2DPD==1 && !defined(DECBIN2DPD)\r\n#define DECBIN2DPD\r\n \r\nconst uint16_t BIN2DPD[1000]={    0,    1,    2,    3,    4,    5,    6,    7, \r\n    8,    9,   16,   17,   18,   19,   20,   21,   22,   23,   24,   25,   32, \r\n   33,   34,   35,   36,   37,   38,   39,   40,   41,   48,   49,   50,   51, \r\n   52,   53,   54,   55,   56,   57,   64,   65,   66,   67,   68,   69,   70, \r\n   71,   72,   73,   80,   81,   82,   83,   84,   85,   86,   87,   88,   89, \r\n   96,   97,   98,   99,  100,  101,  102,  103,  104,  105,  112,  113,  114, \r\n  115,  116,  117,  118,  119,  120,  121,   10,   11,   42,   43,   74,   75, \r\n  106,  107,   78,   79,   26,   27,   58,   59,   90,   91,  122,  123,   94, \r\n   95,  128,  129,  130,  131,  132,  133,  134,  135,  136,  137,  144,  145, \r\n  146,  147,  148,  149,  150,  151,  152,  153,  160,  161,  162,  163,  164, \r\n  165,  166,  167,  168,  169,  176,  177,  178,  179,  180,  181,  182,  183, \r\n  184,  185,  192,  193,  194,  195,  196,  197,  198,  199,  200,  201,  208, \r\n  209,  210,  211,  212,  213,  214,  215,  216,  217,  224,  225,  226,  227, \r\n  228,  229,  230,  231,  232,  233,  240,  241,  242,  243,  244,  245,  246, \r\n  247,  248,  249,  138,  139,  170,  171,  202,  203,  234,  235,  206,  207, \r\n  154,  155,  186,  187,  218,  219,  250,  251,  222,  223,  256,  257,  258, \r\n  259,  260,  261,  262,  263,  264,  265,  272,  273,  274,  275,  276,  277, \r\n  278,  279,  280,  281,  288,  289,  290,  291,  292,  293,  294,  295,  296, \r\n  297,  304,  305,  306,  307,  308,  309,  310,  311,  312,  313,  320,  321, \r\n  322,  323,  324,  325,  326,  327,  328,  329,  336,  337,  338,  339,  340, \r\n  341,  342,  343,  344,  345,  352,  353,  354,  355,  356,  357,  358,  359, \r\n  360,  361,  368,  369,  370,  371,  372,  373,  374,  375,  376,  377,  266, \r\n  267,  298,  299,  330,  331,  362,  363,  334,  335,  282,  283,  314,  315, \r\n  346,  347,  378,  379,  350,  351,  384,  385,  386,  387,  388,  389,  390, \r\n  391,  392,  393,  400,  401,  402,  403,  404,  405,  406,  407,  408,  409, \r\n  416,  417,  418,  419,  420,  421,  422,  423,  424,  425,  432,  433,  434, \r\n  435,  436,  437,  438,  439,  440,  441,  448,  449,  450,  451,  452,  453, \r\n  454,  455,  456,  457,  464,  465,  466,  467,  468,  469,  470,  471,  472, \r\n  473,  480,  481,  482,  483,  484,  485,  486,  487,  488,  489,  496,  497, \r\n  498,  499,  500,  501,  502,  503,  504,  505,  394,  395,  426,  427,  458, \r\n  459,  490,  491,  462,  463,  410,  411,  442,  443,  474,  475,  506,  507, \r\n  478,  479,  512,  513,  514,  515,  516,  517,  518,  519,  520,  521,  528, \r\n  529,  530,  531,  532,  533,  534,  535,  536,  537,  544,  545,  546,  547, \r\n  548,  549,  550,  551,  552,  553,  560,  561,  562,  563,  564,  565,  566, \r\n  567,  568,  569,  576,  577,  578,  579,  580,  581,  582,  583,  584,  585, \r\n  592,  593,  594,  595,  596,  597,  598,  599,  600,  601,  608,  609,  610, \r\n  611,  612,  613,  614,  615,  616,  617,  624,  625,  626,  627,  628,  629, \r\n  630,  631,  632,  633,  522,  523,  554,  555,  586,  587,  618,  619,  590, \r\n  591,  538,  539,  570,  571,  602,  603,  634,  635,  606,  607,  640,  641, \r\n  642,  643,  644,  645,  646,  647,  648,  649,  656,  657,  658,  659,  660, \r\n  661,  662,  663,  664,  665,  672,  673,  674,  675,  676,  677,  678,  679, \r\n  680,  681,  688,  689,  690,  691,  692,  693,  694,  695,  696,  697,  704, \r\n  705,  706,  707,  708,  709,  710,  711,  712,  713,  720,  721,  722,  723, \r\n  724,  725,  726,  727,  728,  729,  736,  737,  738,  739,  740,  741,  742, \r\n  743,  744,  745,  752,  753,  754,  755,  756,  757,  758,  759,  760,  761, \r\n  650,  651,  682,  683,  714,  715,  746,  747,  718,  719,  666,  667,  698, \r\n  699,  730,  731,  762,  763,  734,  735,  768,  769,  770,  771,  772,  773, \r\n  774,  775,  776,  777,  784,  785,  786,  787,  788,  789,  790,  791,  792, \r\n  793,  800,  801,  802,  803,  804,  805,  806,  807,  808,  809,  816,  817, \r\n  818,  819,  820,  821,  822,  823,  824,  825,  832,  833,  834,  835,  836, \r\n  837,  838,  839,  840,  841,  848,  849,  850,  851,  852,  853,  854,  855, \r\n  856,  857,  864,  865,  866,  867,  868,  869,  870,  871,  872,  873,  880, \r\n  881,  882,  883,  884,  885,  886,  887,  888,  889,  778,  779,  810,  811, \r\n  842,  843,  874,  875,  846,  847,  794,  795,  826,  827,  858,  859,  890, \r\n  891,  862,  863,  896,  897,  898,  899,  900,  901,  902,  903,  904,  905, \r\n  912,  913,  914,  915,  916,  917,  918,  919,  920,  921,  928,  929,  930, \r\n  931,  932,  933,  934,  935,  936,  937,  944,  945,  946,  947,  948,  949, \r\n  950,  951,  952,  953,  960,  961,  962,  963,  964,  965,  966,  967,  968, \r\n  969,  976,  977,  978,  979,  980,  981,  982,  983,  984,  985,  992,  993, \r\n  994,  995,  996,  997,  998,  999, 1000, 1001, 1008, 1009, 1010, 1011, 1012, \r\n 1013, 1014, 1015, 1016, 1017,  906,  907,  938,  939,  970,  971, 1002, 1003, \r\n  974,  975,  922,  923,  954,  955,  986,  987, 1018, 1019,  990,  991,   12, \r\n   13,  268,  269,  524,  525,  780,  781,   46,   47,   28,   29,  284,  285, \r\n  540,  541,  796,  797,   62,   63,   44,   45,  300,  301,  556,  557,  812, \r\n  813,  302,  303,   60,   61,  316,  317,  572,  573,  828,  829,  318,  319, \r\n   76,   77,  332,  333,  588,  589,  844,  845,  558,  559,   92,   93,  348, \r\n  349,  604,  605,  860,  861,  574,  575,  108,  109,  364,  365,  620,  621, \r\n  876,  877,  814,  815,  124,  125,  380,  381,  636,  637,  892,  893,  830, \r\n  831,   14,   15,  270,  271,  526,  527,  782,  783,  110,  111,   30,   31, \r\n  286,  287,  542,  543,  798,  799,  126,  127,  140,  141,  396,  397,  652, \r\n  653,  908,  909,  174,  175,  156,  157,  412,  413,  668,  669,  924,  925, \r\n  190,  191,  172,  173,  428,  429,  684,  685,  940,  941,  430,  431,  188, \r\n  189,  444,  445,  700,  701,  956,  957,  446,  447,  204,  205,  460,  461, \r\n  716,  717,  972,  973,  686,  687,  220,  221,  476,  477,  732,  733,  988, \r\n  989,  702,  703,  236,  237,  492,  493,  748,  749, 1004, 1005,  942,  943, \r\n  252,  253,  508,  509,  764,  765, 1020, 1021,  958,  959,  142,  143,  398, \r\n  399,  654,  655,  910,  911,  238,  239,  158,  159,  414,  415,  670,  671, \r\n  926,  927,  254,  255};\r\n#endif \r\n \r\n#if defined(DEC_DPD2BIN) && DEC_DPD2BIN==1 && !defined(DECDPD2BIN)\r\n#define DECDPD2BIN\r\n \r\nconst uint16_t DPD2BIN[1024]={    0,    1,    2,    3,    4,    5,    6,    7, \r\n    8,    9,   80,   81,  800,  801,  880,  881,   10,   11,   12,   13,   14, \r\n   15,   16,   17,   18,   19,   90,   91,  810,  811,  890,  891,   20,   21, \r\n   22,   23,   24,   25,   26,   27,   28,   29,   82,   83,  820,  821,  808, \r\n  809,   30,   31,   32,   33,   34,   35,   36,   37,   38,   39,   92,   93, \r\n  830,  831,  818,  819,   40,   41,   42,   43,   44,   45,   46,   47,   48, \r\n   49,   84,   85,  840,  841,   88,   89,   50,   51,   52,   53,   54,   55, \r\n   56,   57,   58,   59,   94,   95,  850,  851,   98,   99,   60,   61,   62, \r\n   63,   64,   65,   66,   67,   68,   69,   86,   87,  860,  861,  888,  889, \r\n   70,   71,   72,   73,   74,   75,   76,   77,   78,   79,   96,   97,  870, \r\n  871,  898,  899,  100,  101,  102,  103,  104,  105,  106,  107,  108,  109, \r\n  180,  181,  900,  901,  980,  981,  110,  111,  112,  113,  114,  115,  116, \r\n  117,  118,  119,  190,  191,  910,  911,  990,  991,  120,  121,  122,  123, \r\n  124,  125,  126,  127,  128,  129,  182,  183,  920,  921,  908,  909,  130, \r\n  131,  132,  133,  134,  135,  136,  137,  138,  139,  192,  193,  930,  931, \r\n  918,  919,  140,  141,  142,  143,  144,  145,  146,  147,  148,  149,  184, \r\n  185,  940,  941,  188,  189,  150,  151,  152,  153,  154,  155,  156,  157, \r\n  158,  159,  194,  195,  950,  951,  198,  199,  160,  161,  162,  163,  164, \r\n  165,  166,  167,  168,  169,  186,  187,  960,  961,  988,  989,  170,  171, \r\n  172,  173,  174,  175,  176,  177,  178,  179,  196,  197,  970,  971,  998, \r\n  999,  200,  201,  202,  203,  204,  205,  206,  207,  208,  209,  280,  281, \r\n  802,  803,  882,  883,  210,  211,  212,  213,  214,  215,  216,  217,  218, \r\n  219,  290,  291,  812,  813,  892,  893,  220,  221,  222,  223,  224,  225, \r\n  226,  227,  228,  229,  282,  283,  822,  823,  828,  829,  230,  231,  232, \r\n  233,  234,  235,  236,  237,  238,  239,  292,  293,  832,  833,  838,  839, \r\n  240,  241,  242,  243,  244,  245,  246,  247,  248,  249,  284,  285,  842, \r\n  843,  288,  289,  250,  251,  252,  253,  254,  255,  256,  257,  258,  259, \r\n  294,  295,  852,  853,  298,  299,  260,  261,  262,  263,  264,  265,  266, \r\n  267,  268,  269,  286,  287,  862,  863,  888,  889,  270,  271,  272,  273, \r\n  274,  275,  276,  277,  278,  279,  296,  297,  872,  873,  898,  899,  300, \r\n  301,  302,  303,  304,  305,  306,  307,  308,  309,  380,  381,  902,  903, \r\n  982,  983,  310,  311,  312,  313,  314,  315,  316,  317,  318,  319,  390, \r\n  391,  912,  913,  992,  993,  320,  321,  322,  323,  324,  325,  326,  327, \r\n  328,  329,  382,  383,  922,  923,  928,  929,  330,  331,  332,  333,  334, \r\n  335,  336,  337,  338,  339,  392,  393,  932,  933,  938,  939,  340,  341, \r\n  342,  343,  344,  345,  346,  347,  348,  349,  384,  385,  942,  943,  388, \r\n  389,  350,  351,  352,  353,  354,  355,  356,  357,  358,  359,  394,  395, \r\n  952,  953,  398,  399,  360,  361,  362,  363,  364,  365,  366,  367,  368, \r\n  369,  386,  387,  962,  963,  988,  989,  370,  371,  372,  373,  374,  375, \r\n  376,  377,  378,  379,  396,  397,  972,  973,  998,  999,  400,  401,  402, \r\n  403,  404,  405,  406,  407,  408,  409,  480,  481,  804,  805,  884,  885, \r\n  410,  411,  412,  413,  414,  415,  416,  417,  418,  419,  490,  491,  814, \r\n  815,  894,  895,  420,  421,  422,  423,  424,  425,  426,  427,  428,  429, \r\n  482,  483,  824,  825,  848,  849,  430,  431,  432,  433,  434,  435,  436, \r\n  437,  438,  439,  492,  493,  834,  835,  858,  859,  440,  441,  442,  443, \r\n  444,  445,  446,  447,  448,  449,  484,  485,  844,  845,  488,  489,  450, \r\n  451,  452,  453,  454,  455,  456,  457,  458,  459,  494,  495,  854,  855, \r\n  498,  499,  460,  461,  462,  463,  464,  465,  466,  467,  468,  469,  486, \r\n  487,  864,  865,  888,  889,  470,  471,  472,  473,  474,  475,  476,  477, \r\n  478,  479,  496,  497,  874,  875,  898,  899,  500,  501,  502,  503,  504, \r\n  505,  506,  507,  508,  509,  580,  581,  904,  905,  984,  985,  510,  511, \r\n  512,  513,  514,  515,  516,  517,  518,  519,  590,  591,  914,  915,  994, \r\n  995,  520,  521,  522,  523,  524,  525,  526,  527,  528,  529,  582,  583, \r\n  924,  925,  948,  949,  530,  531,  532,  533,  534,  535,  536,  537,  538, \r\n  539,  592,  593,  934,  935,  958,  959,  540,  541,  542,  543,  544,  545, \r\n  546,  547,  548,  549,  584,  585,  944,  945,  588,  589,  550,  551,  552, \r\n  553,  554,  555,  556,  557,  558,  559,  594,  595,  954,  955,  598,  599, \r\n  560,  561,  562,  563,  564,  565,  566,  567,  568,  569,  586,  587,  964, \r\n  965,  988,  989,  570,  571,  572,  573,  574,  575,  576,  577,  578,  579, \r\n  596,  597,  974,  975,  998,  999,  600,  601,  602,  603,  604,  605,  606, \r\n  607,  608,  609,  680,  681,  806,  807,  886,  887,  610,  611,  612,  613, \r\n  614,  615,  616,  617,  618,  619,  690,  691,  816,  817,  896,  897,  620, \r\n  621,  622,  623,  624,  625,  626,  627,  628,  629,  682,  683,  826,  827, \r\n  868,  869,  630,  631,  632,  633,  634,  635,  636,  637,  638,  639,  692, \r\n  693,  836,  837,  878,  879,  640,  641,  642,  643,  644,  645,  646,  647, \r\n  648,  649,  684,  685,  846,  847,  688,  689,  650,  651,  652,  653,  654, \r\n  655,  656,  657,  658,  659,  694,  695,  856,  857,  698,  699,  660,  661, \r\n  662,  663,  664,  665,  666,  667,  668,  669,  686,  687,  866,  867,  888, \r\n  889,  670,  671,  672,  673,  674,  675,  676,  677,  678,  679,  696,  697, \r\n  876,  877,  898,  899,  700,  701,  702,  703,  704,  705,  706,  707,  708, \r\n  709,  780,  781,  906,  907,  986,  987,  710,  711,  712,  713,  714,  715, \r\n  716,  717,  718,  719,  790,  791,  916,  917,  996,  997,  720,  721,  722, \r\n  723,  724,  725,  726,  727,  728,  729,  782,  783,  926,  927,  968,  969, \r\n  730,  731,  732,  733,  734,  735,  736,  737,  738,  739,  792,  793,  936, \r\n  937,  978,  979,  740,  741,  742,  743,  744,  745,  746,  747,  748,  749, \r\n  784,  785,  946,  947,  788,  789,  750,  751,  752,  753,  754,  755,  756, \r\n  757,  758,  759,  794,  795,  956,  957,  798,  799,  760,  761,  762,  763, \r\n  764,  765,  766,  767,  768,  769,  786,  787,  966,  967,  988,  989,  770, \r\n  771,  772,  773,  774,  775,  776,  777,  778,  779,  796,  797,  976,  977, \r\n  998,  999};\r\n#endif\r\n \r\n#if defined(DEC_DPD2BINK) && DEC_DPD2BINK==1 && !defined(DECDPD2BINK)\r\n#define DECDPD2BINK\r\n \r\nconst uint32_t DPD2BINK[1024]={       0,   1000,   2000,   3000,   4000,   5000, \r\n   6000,   7000,   8000,   9000,  80000,  81000, 800000, 801000, 880000, 881000, \r\n  10000,  11000,  12000,  13000,  14000,  15000,  16000,  17000,  18000,  19000, \r\n  90000,  91000, 810000, 811000, 890000, 891000,  20000,  21000,  22000,  23000, \r\n  24000,  25000,  26000,  27000,  28000,  29000,  82000,  83000, 820000, 821000, \r\n 808000, 809000,  30000,  31000,  32000,  33000,  34000,  35000,  36000,  37000, \r\n  38000,  39000,  92000,  93000, 830000, 831000, 818000, 819000,  40000,  41000, \r\n  42000,  43000,  44000,  45000,  46000,  47000,  48000,  49000,  84000,  85000, \r\n 840000, 841000,  88000,  89000,  50000,  51000,  52000,  53000,  54000,  55000, \r\n  56000,  57000,  58000,  59000,  94000,  95000, 850000, 851000,  98000,  99000, \r\n  60000,  61000,  62000,  63000,  64000,  65000,  66000,  67000,  68000,  69000, \r\n  86000,  87000, 860000, 861000, 888000, 889000,  70000,  71000,  72000,  73000, \r\n  74000,  75000,  76000,  77000,  78000,  79000,  96000,  97000, 870000, 871000, \r\n 898000, 899000, 100000, 101000, 102000, 103000, 104000, 105000, 106000, 107000, \r\n 108000, 109000, 180000, 181000, 900000, 901000, 980000, 981000, 110000, 111000, \r\n 112000, 113000, 114000, 115000, 116000, 117000, 118000, 119000, 190000, 191000, \r\n 910000, 911000, 990000, 991000, 120000, 121000, 122000, 123000, 124000, 125000, \r\n 126000, 127000, 128000, 129000, 182000, 183000, 920000, 921000, 908000, 909000, \r\n 130000, 131000, 132000, 133000, 134000, 135000, 136000, 137000, 138000, 139000, \r\n 192000, 193000, 930000, 931000, 918000, 919000, 140000, 141000, 142000, 143000, \r\n 144000, 145000, 146000, 147000, 148000, 149000, 184000, 185000, 940000, 941000, \r\n 188000, 189000, 150000, 151000, 152000, 153000, 154000, 155000, 156000, 157000, \r\n 158000, 159000, 194000, 195000, 950000, 951000, 198000, 199000, 160000, 161000, \r\n 162000, 163000, 164000, 165000, 166000, 167000, 168000, 169000, 186000, 187000, \r\n 960000, 961000, 988000, 989000, 170000, 171000, 172000, 173000, 174000, 175000, \r\n 176000, 177000, 178000, 179000, 196000, 197000, 970000, 971000, 998000, 999000, \r\n 200000, 201000, 202000, 203000, 204000, 205000, 206000, 207000, 208000, 209000, \r\n 280000, 281000, 802000, 803000, 882000, 883000, 210000, 211000, 212000, 213000, \r\n 214000, 215000, 216000, 217000, 218000, 219000, 290000, 291000, 812000, 813000, \r\n 892000, 893000, 220000, 221000, 222000, 223000, 224000, 225000, 226000, 227000, \r\n 228000, 229000, 282000, 283000, 822000, 823000, 828000, 829000, 230000, 231000, \r\n 232000, 233000, 234000, 235000, 236000, 237000, 238000, 239000, 292000, 293000, \r\n 832000, 833000, 838000, 839000, 240000, 241000, 242000, 243000, 244000, 245000, \r\n 246000, 247000, 248000, 249000, 284000, 285000, 842000, 843000, 288000, 289000, \r\n 250000, 251000, 252000, 253000, 254000, 255000, 256000, 257000, 258000, 259000, \r\n 294000, 295000, 852000, 853000, 298000, 299000, 260000, 261000, 262000, 263000, \r\n 264000, 265000, 266000, 267000, 268000, 269000, 286000, 287000, 862000, 863000, \r\n 888000, 889000, 270000, 271000, 272000, 273000, 274000, 275000, 276000, 277000, \r\n 278000, 279000, 296000, 297000, 872000, 873000, 898000, 899000, 300000, 301000, \r\n 302000, 303000, 304000, 305000, 306000, 307000, 308000, 309000, 380000, 381000, \r\n 902000, 903000, 982000, 983000, 310000, 311000, 312000, 313000, 314000, 315000, \r\n 316000, 317000, 318000, 319000, 390000, 391000, 912000, 913000, 992000, 993000, \r\n 320000, 321000, 322000, 323000, 324000, 325000, 326000, 327000, 328000, 329000, \r\n 382000, 383000, 922000, 923000, 928000, 929000, 330000, 331000, 332000, 333000, \r\n 334000, 335000, 336000, 337000, 338000, 339000, 392000, 393000, 932000, 933000, \r\n 938000, 939000, 340000, 341000, 342000, 343000, 344000, 345000, 346000, 347000, \r\n 348000, 349000, 384000, 385000, 942000, 943000, 388000, 389000, 350000, 351000, \r\n 352000, 353000, 354000, 355000, 356000, 357000, 358000, 359000, 394000, 395000, \r\n 952000, 953000, 398000, 399000, 360000, 361000, 362000, 363000, 364000, 365000, \r\n 366000, 367000, 368000, 369000, 386000, 387000, 962000, 963000, 988000, 989000, \r\n 370000, 371000, 372000, 373000, 374000, 375000, 376000, 377000, 378000, 379000, \r\n 396000, 397000, 972000, 973000, 998000, 999000, 400000, 401000, 402000, 403000, \r\n 404000, 405000, 406000, 407000, 408000, 409000, 480000, 481000, 804000, 805000, \r\n 884000, 885000, 410000, 411000, 412000, 413000, 414000, 415000, 416000, 417000, \r\n 418000, 419000, 490000, 491000, 814000, 815000, 894000, 895000, 420000, 421000, \r\n 422000, 423000, 424000, 425000, 426000, 427000, 428000, 429000, 482000, 483000, \r\n 824000, 825000, 848000, 849000, 430000, 431000, 432000, 433000, 434000, 435000, \r\n 436000, 437000, 438000, 439000, 492000, 493000, 834000, 835000, 858000, 859000, \r\n 440000, 441000, 442000, 443000, 444000, 445000, 446000, 447000, 448000, 449000, \r\n 484000, 485000, 844000, 845000, 488000, 489000, 450000, 451000, 452000, 453000, \r\n 454000, 455000, 456000, 457000, 458000, 459000, 494000, 495000, 854000, 855000, \r\n 498000, 499000, 460000, 461000, 462000, 463000, 464000, 465000, 466000, 467000, \r\n 468000, 469000, 486000, 487000, 864000, 865000, 888000, 889000, 470000, 471000, \r\n 472000, 473000, 474000, 475000, 476000, 477000, 478000, 479000, 496000, 497000, \r\n 874000, 875000, 898000, 899000, 500000, 501000, 502000, 503000, 504000, 505000, \r\n 506000, 507000, 508000, 509000, 580000, 581000, 904000, 905000, 984000, 985000, \r\n 510000, 511000, 512000, 513000, 514000, 515000, 516000, 517000, 518000, 519000, \r\n 590000, 591000, 914000, 915000, 994000, 995000, 520000, 521000, 522000, 523000, \r\n 524000, 525000, 526000, 527000, 528000, 529000, 582000, 583000, 924000, 925000, \r\n 948000, 949000, 530000, 531000, 532000, 533000, 534000, 535000, 536000, 537000, \r\n 538000, 539000, 592000, 593000, 934000, 935000, 958000, 959000, 540000, 541000, \r\n 542000, 543000, 544000, 545000, 546000, 547000, 548000, 549000, 584000, 585000, \r\n 944000, 945000, 588000, 589000, 550000, 551000, 552000, 553000, 554000, 555000, \r\n 556000, 557000, 558000, 559000, 594000, 595000, 954000, 955000, 598000, 599000, \r\n 560000, 561000, 562000, 563000, 564000, 565000, 566000, 567000, 568000, 569000, \r\n 586000, 587000, 964000, 965000, 988000, 989000, 570000, 571000, 572000, 573000, \r\n 574000, 575000, 576000, 577000, 578000, 579000, 596000, 597000, 974000, 975000, \r\n 998000, 999000, 600000, 601000, 602000, 603000, 604000, 605000, 606000, 607000, \r\n 608000, 609000, 680000, 681000, 806000, 807000, 886000, 887000, 610000, 611000, \r\n 612000, 613000, 614000, 615000, 616000, 617000, 618000, 619000, 690000, 691000, \r\n 816000, 817000, 896000, 897000, 620000, 621000, 622000, 623000, 624000, 625000, \r\n 626000, 627000, 628000, 629000, 682000, 683000, 826000, 827000, 868000, 869000, \r\n 630000, 631000, 632000, 633000, 634000, 635000, 636000, 637000, 638000, 639000, \r\n 692000, 693000, 836000, 837000, 878000, 879000, 640000, 641000, 642000, 643000, \r\n 644000, 645000, 646000, 647000, 648000, 649000, 684000, 685000, 846000, 847000, \r\n 688000, 689000, 650000, 651000, 652000, 653000, 654000, 655000, 656000, 657000, \r\n 658000, 659000, 694000, 695000, 856000, 857000, 698000, 699000, 660000, 661000, \r\n 662000, 663000, 664000, 665000, 666000, 667000, 668000, 669000, 686000, 687000, \r\n 866000, 867000, 888000, 889000, 670000, 671000, 672000, 673000, 674000, 675000, \r\n 676000, 677000, 678000, 679000, 696000, 697000, 876000, 877000, 898000, 899000, \r\n 700000, 701000, 702000, 703000, 704000, 705000, 706000, 707000, 708000, 709000, \r\n 780000, 781000, 906000, 907000, 986000, 987000, 710000, 711000, 712000, 713000, \r\n 714000, 715000, 716000, 717000, 718000, 719000, 790000, 791000, 916000, 917000, \r\n 996000, 997000, 720000, 721000, 722000, 723000, 724000, 725000, 726000, 727000, \r\n 728000, 729000, 782000, 783000, 926000, 927000, 968000, 969000, 730000, 731000, \r\n 732000, 733000, 734000, 735000, 736000, 737000, 738000, 739000, 792000, 793000, \r\n 936000, 937000, 978000, 979000, 740000, 741000, 742000, 743000, 744000, 745000, \r\n 746000, 747000, 748000, 749000, 784000, 785000, 946000, 947000, 788000, 789000, \r\n 750000, 751000, 752000, 753000, 754000, 755000, 756000, 757000, 758000, 759000, \r\n 794000, 795000, 956000, 957000, 798000, 799000, 760000, 761000, 762000, 763000, \r\n 764000, 765000, 766000, 767000, 768000, 769000, 786000, 787000, 966000, 967000, \r\n 988000, 989000, 770000, 771000, 772000, 773000, 774000, 775000, 776000, 777000, \r\n 778000, 779000, 796000, 797000, 976000, 977000, 998000, 999000};\r\n#endif\r\n \r\n#if defined(DEC_DPD2BINM) && DEC_DPD2BINM==1 && !defined(DECDPD2BINM)\r\n#define DECDPD2BINM\r\n \r\nconst uint32_t DPD2BINM[1024]={0,   1000000,   2000000,   3000000,   4000000, \r\n   5000000,   6000000,   7000000,   8000000,   9000000,  80000000,  81000000, \r\n 800000000, 801000000, 880000000, 881000000,  10000000,  11000000,  12000000, \r\n  13000000,  14000000,  15000000,  16000000,  17000000,  18000000,  19000000, \r\n  90000000,  91000000, 810000000, 811000000, 890000000, 891000000,  20000000, \r\n  21000000,  22000000,  23000000,  24000000,  25000000,  26000000,  27000000, \r\n  28000000,  29000000,  82000000,  83000000, 820000000, 821000000, 808000000, \r\n 809000000,  30000000,  31000000,  32000000,  33000000,  34000000,  35000000, \r\n  36000000,  37000000,  38000000,  39000000,  92000000,  93000000, 830000000, \r\n 831000000, 818000000, 819000000,  40000000,  41000000,  42000000,  43000000, \r\n  44000000,  45000000,  46000000,  47000000,  48000000,  49000000,  84000000, \r\n  85000000, 840000000, 841000000,  88000000,  89000000,  50000000,  51000000, \r\n  52000000,  53000000,  54000000,  55000000,  56000000,  57000000,  58000000, \r\n  59000000,  94000000,  95000000, 850000000, 851000000,  98000000,  99000000, \r\n  60000000,  61000000,  62000000,  63000000,  64000000,  65000000,  66000000, \r\n  67000000,  68000000,  69000000,  86000000,  87000000, 860000000, 861000000, \r\n 888000000, 889000000,  70000000,  71000000,  72000000,  73000000,  74000000, \r\n  75000000,  76000000,  77000000,  78000000,  79000000,  96000000,  97000000, \r\n 870000000, 871000000, 898000000, 899000000, 100000000, 101000000, 102000000, \r\n 103000000, 104000000, 105000000, 106000000, 107000000, 108000000, 109000000, \r\n 180000000, 181000000, 900000000, 901000000, 980000000, 981000000, 110000000, \r\n 111000000, 112000000, 113000000, 114000000, 115000000, 116000000, 117000000, \r\n 118000000, 119000000, 190000000, 191000000, 910000000, 911000000, 990000000, \r\n 991000000, 120000000, 121000000, 122000000, 123000000, 124000000, 125000000, \r\n 126000000, 127000000, 128000000, 129000000, 182000000, 183000000, 920000000, \r\n 921000000, 908000000, 909000000, 130000000, 131000000, 132000000, 133000000, \r\n 134000000, 135000000, 136000000, 137000000, 138000000, 139000000, 192000000, \r\n 193000000, 930000000, 931000000, 918000000, 919000000, 140000000, 141000000, \r\n 142000000, 143000000, 144000000, 145000000, 146000000, 147000000, 148000000, \r\n 149000000, 184000000, 185000000, 940000000, 941000000, 188000000, 189000000, \r\n 150000000, 151000000, 152000000, 153000000, 154000000, 155000000, 156000000, \r\n 157000000, 158000000, 159000000, 194000000, 195000000, 950000000, 951000000, \r\n 198000000, 199000000, 160000000, 161000000, 162000000, 163000000, 164000000, \r\n 165000000, 166000000, 167000000, 168000000, 169000000, 186000000, 187000000, \r\n 960000000, 961000000, 988000000, 989000000, 170000000, 171000000, 172000000, \r\n 173000000, 174000000, 175000000, 176000000, 177000000, 178000000, 179000000, \r\n 196000000, 197000000, 970000000, 971000000, 998000000, 999000000, 200000000, \r\n 201000000, 202000000, 203000000, 204000000, 205000000, 206000000, 207000000, \r\n 208000000, 209000000, 280000000, 281000000, 802000000, 803000000, 882000000, \r\n 883000000, 210000000, 211000000, 212000000, 213000000, 214000000, 215000000, \r\n 216000000, 217000000, 218000000, 219000000, 290000000, 291000000, 812000000, \r\n 813000000, 892000000, 893000000, 220000000, 221000000, 222000000, 223000000, \r\n 224000000, 225000000, 226000000, 227000000, 228000000, 229000000, 282000000, \r\n 283000000, 822000000, 823000000, 828000000, 829000000, 230000000, 231000000, \r\n 232000000, 233000000, 234000000, 235000000, 236000000, 237000000, 238000000, \r\n 239000000, 292000000, 293000000, 832000000, 833000000, 838000000, 839000000, \r\n 240000000, 241000000, 242000000, 243000000, 244000000, 245000000, 246000000, \r\n 247000000, 248000000, 249000000, 284000000, 285000000, 842000000, 843000000, \r\n 288000000, 289000000, 250000000, 251000000, 252000000, 253000000, 254000000, \r\n 255000000, 256000000, 257000000, 258000000, 259000000, 294000000, 295000000, \r\n 852000000, 853000000, 298000000, 299000000, 260000000, 261000000, 262000000, \r\n 263000000, 264000000, 265000000, 266000000, 267000000, 268000000, 269000000, \r\n 286000000, 287000000, 862000000, 863000000, 888000000, 889000000, 270000000, \r\n 271000000, 272000000, 273000000, 274000000, 275000000, 276000000, 277000000, \r\n 278000000, 279000000, 296000000, 297000000, 872000000, 873000000, 898000000, \r\n 899000000, 300000000, 301000000, 302000000, 303000000, 304000000, 305000000, \r\n 306000000, 307000000, 308000000, 309000000, 380000000, 381000000, 902000000, \r\n 903000000, 982000000, 983000000, 310000000, 311000000, 312000000, 313000000, \r\n 314000000, 315000000, 316000000, 317000000, 318000000, 319000000, 390000000, \r\n 391000000, 912000000, 913000000, 992000000, 993000000, 320000000, 321000000, \r\n 322000000, 323000000, 324000000, 325000000, 326000000, 327000000, 328000000, \r\n 329000000, 382000000, 383000000, 922000000, 923000000, 928000000, 929000000, \r\n 330000000, 331000000, 332000000, 333000000, 334000000, 335000000, 336000000, \r\n 337000000, 338000000, 339000000, 392000000, 393000000, 932000000, 933000000, \r\n 938000000, 939000000, 340000000, 341000000, 342000000, 343000000, 344000000, \r\n 345000000, 346000000, 347000000, 348000000, 349000000, 384000000, 385000000, \r\n 942000000, 943000000, 388000000, 389000000, 350000000, 351000000, 352000000, \r\n 353000000, 354000000, 355000000, 356000000, 357000000, 358000000, 359000000, \r\n 394000000, 395000000, 952000000, 953000000, 398000000, 399000000, 360000000, \r\n 361000000, 362000000, 363000000, 364000000, 365000000, 366000000, 367000000, \r\n 368000000, 369000000, 386000000, 387000000, 962000000, 963000000, 988000000, \r\n 989000000, 370000000, 371000000, 372000000, 373000000, 374000000, 375000000, \r\n 376000000, 377000000, 378000000, 379000000, 396000000, 397000000, 972000000, \r\n 973000000, 998000000, 999000000, 400000000, 401000000, 402000000, 403000000, \r\n 404000000, 405000000, 406000000, 407000000, 408000000, 409000000, 480000000, \r\n 481000000, 804000000, 805000000, 884000000, 885000000, 410000000, 411000000, \r\n 412000000, 413000000, 414000000, 415000000, 416000000, 417000000, 418000000, \r\n 419000000, 490000000, 491000000, 814000000, 815000000, 894000000, 895000000, \r\n 420000000, 421000000, 422000000, 423000000, 424000000, 425000000, 426000000, \r\n 427000000, 428000000, 429000000, 482000000, 483000000, 824000000, 825000000, \r\n 848000000, 849000000, 430000000, 431000000, 432000000, 433000000, 434000000, \r\n 435000000, 436000000, 437000000, 438000000, 439000000, 492000000, 493000000, \r\n 834000000, 835000000, 858000000, 859000000, 440000000, 441000000, 442000000, \r\n 443000000, 444000000, 445000000, 446000000, 447000000, 448000000, 449000000, \r\n 484000000, 485000000, 844000000, 845000000, 488000000, 489000000, 450000000, \r\n 451000000, 452000000, 453000000, 454000000, 455000000, 456000000, 457000000, \r\n 458000000, 459000000, 494000000, 495000000, 854000000, 855000000, 498000000, \r\n 499000000, 460000000, 461000000, 462000000, 463000000, 464000000, 465000000, \r\n 466000000, 467000000, 468000000, 469000000, 486000000, 487000000, 864000000, \r\n 865000000, 888000000, 889000000, 470000000, 471000000, 472000000, 473000000, \r\n 474000000, 475000000, 476000000, 477000000, 478000000, 479000000, 496000000, \r\n 497000000, 874000000, 875000000, 898000000, 899000000, 500000000, 501000000, \r\n 502000000, 503000000, 504000000, 505000000, 506000000, 507000000, 508000000, \r\n 509000000, 580000000, 581000000, 904000000, 905000000, 984000000, 985000000, \r\n 510000000, 511000000, 512000000, 513000000, 514000000, 515000000, 516000000, \r\n 517000000, 518000000, 519000000, 590000000, 591000000, 914000000, 915000000, \r\n 994000000, 995000000, 520000000, 521000000, 522000000, 523000000, 524000000, \r\n 525000000, 526000000, 527000000, 528000000, 529000000, 582000000, 583000000, \r\n 924000000, 925000000, 948000000, 949000000, 530000000, 531000000, 532000000, \r\n 533000000, 534000000, 535000000, 536000000, 537000000, 538000000, 539000000, \r\n 592000000, 593000000, 934000000, 935000000, 958000000, 959000000, 540000000, \r\n 541000000, 542000000, 543000000, 544000000, 545000000, 546000000, 547000000, \r\n 548000000, 549000000, 584000000, 585000000, 944000000, 945000000, 588000000, \r\n 589000000, 550000000, 551000000, 552000000, 553000000, 554000000, 555000000, \r\n 556000000, 557000000, 558000000, 559000000, 594000000, 595000000, 954000000, \r\n 955000000, 598000000, 599000000, 560000000, 561000000, 562000000, 563000000, \r\n 564000000, 565000000, 566000000, 567000000, 568000000, 569000000, 586000000, \r\n 587000000, 964000000, 965000000, 988000000, 989000000, 570000000, 571000000, \r\n 572000000, 573000000, 574000000, 575000000, 576000000, 577000000, 578000000, \r\n 579000000, 596000000, 597000000, 974000000, 975000000, 998000000, 999000000, \r\n 600000000, 601000000, 602000000, 603000000, 604000000, 605000000, 606000000, \r\n 607000000, 608000000, 609000000, 680000000, 681000000, 806000000, 807000000, \r\n 886000000, 887000000, 610000000, 611000000, 612000000, 613000000, 614000000, \r\n 615000000, 616000000, 617000000, 618000000, 619000000, 690000000, 691000000, \r\n 816000000, 817000000, 896000000, 897000000, 620000000, 621000000, 622000000, \r\n 623000000, 624000000, 625000000, 626000000, 627000000, 628000000, 629000000, \r\n 682000000, 683000000, 826000000, 827000000, 868000000, 869000000, 630000000, \r\n 631000000, 632000000, 633000000, 634000000, 635000000, 636000000, 637000000, \r\n 638000000, 639000000, 692000000, 693000000, 836000000, 837000000, 878000000, \r\n 879000000, 640000000, 641000000, 642000000, 643000000, 644000000, 645000000, \r\n 646000000, 647000000, 648000000, 649000000, 684000000, 685000000, 846000000, \r\n 847000000, 688000000, 689000000, 650000000, 651000000, 652000000, 653000000, \r\n 654000000, 655000000, 656000000, 657000000, 658000000, 659000000, 694000000, \r\n 695000000, 856000000, 857000000, 698000000, 699000000, 660000000, 661000000, \r\n 662000000, 663000000, 664000000, 665000000, 666000000, 667000000, 668000000, \r\n 669000000, 686000000, 687000000, 866000000, 867000000, 888000000, 889000000, \r\n 670000000, 671000000, 672000000, 673000000, 674000000, 675000000, 676000000, \r\n 677000000, 678000000, 679000000, 696000000, 697000000, 876000000, 877000000, \r\n 898000000, 899000000, 700000000, 701000000, 702000000, 703000000, 704000000, \r\n 705000000, 706000000, 707000000, 708000000, 709000000, 780000000, 781000000, \r\n 906000000, 907000000, 986000000, 987000000, 710000000, 711000000, 712000000, \r\n 713000000, 714000000, 715000000, 716000000, 717000000, 718000000, 719000000, \r\n 790000000, 791000000, 916000000, 917000000, 996000000, 997000000, 720000000, \r\n 721000000, 722000000, 723000000, 724000000, 725000000, 726000000, 727000000, \r\n 728000000, 729000000, 782000000, 783000000, 926000000, 927000000, 968000000, \r\n 969000000, 730000000, 731000000, 732000000, 733000000, 734000000, 735000000, \r\n 736000000, 737000000, 738000000, 739000000, 792000000, 793000000, 936000000, \r\n 937000000, 978000000, 979000000, 740000000, 741000000, 742000000, 743000000, \r\n 744000000, 745000000, 746000000, 747000000, 748000000, 749000000, 784000000, \r\n 785000000, 946000000, 947000000, 788000000, 789000000, 750000000, 751000000, \r\n 752000000, 753000000, 754000000, 755000000, 756000000, 757000000, 758000000, \r\n 759000000, 794000000, 795000000, 956000000, 957000000, 798000000, 799000000, \r\n 760000000, 761000000, 762000000, 763000000, 764000000, 765000000, 766000000, \r\n 767000000, 768000000, 769000000, 786000000, 787000000, 966000000, 967000000, \r\n 988000000, 989000000, 770000000, 771000000, 772000000, 773000000, 774000000, \r\n 775000000, 776000000, 777000000, 778000000, 779000000, 796000000, 797000000, \r\n 976000000, 977000000, 998000000, 999000000};\r\n#endif\r\n \r\n#if defined(DEC_BIN2CHAR) && DEC_BIN2CHAR==1 && !defined(DECBIN2CHAR)\r\n#define DECBIN2CHAR\r\n \r\nconst uint8_t BIN2CHAR[4001]={\r\n '\\0','0','0','0', '\\1','0','0','1', '\\1','0','0','2', '\\1','0','0','3', '\\1','0','0','4', \r\n '\\1','0','0','5', '\\1','0','0','6', '\\1','0','0','7', '\\1','0','0','8', '\\1','0','0','9', \r\n '\\2','0','1','0', '\\2','0','1','1', '\\2','0','1','2', '\\2','0','1','3', '\\2','0','1','4', \r\n '\\2','0','1','5', '\\2','0','1','6', '\\2','0','1','7', '\\2','0','1','8', '\\2','0','1','9', \r\n '\\2','0','2','0', '\\2','0','2','1', '\\2','0','2','2', '\\2','0','2','3', '\\2','0','2','4', \r\n '\\2','0','2','5', '\\2','0','2','6', '\\2','0','2','7', '\\2','0','2','8', '\\2','0','2','9', \r\n '\\2','0','3','0', '\\2','0','3','1', '\\2','0','3','2', '\\2','0','3','3', '\\2','0','3','4', \r\n '\\2','0','3','5', '\\2','0','3','6', '\\2','0','3','7', '\\2','0','3','8', '\\2','0','3','9', \r\n '\\2','0','4','0', '\\2','0','4','1', '\\2','0','4','2', '\\2','0','4','3', '\\2','0','4','4', \r\n '\\2','0','4','5', '\\2','0','4','6', '\\2','0','4','7', '\\2','0','4','8', '\\2','0','4','9', \r\n '\\2','0','5','0', '\\2','0','5','1', '\\2','0','5','2', '\\2','0','5','3', '\\2','0','5','4', \r\n '\\2','0','5','5', '\\2','0','5','6', '\\2','0','5','7', '\\2','0','5','8', '\\2','0','5','9', \r\n '\\2','0','6','0', '\\2','0','6','1', '\\2','0','6','2', '\\2','0','6','3', '\\2','0','6','4', \r\n '\\2','0','6','5', '\\2','0','6','6', '\\2','0','6','7', '\\2','0','6','8', '\\2','0','6','9', \r\n '\\2','0','7','0', '\\2','0','7','1', '\\2','0','7','2', '\\2','0','7','3', '\\2','0','7','4', \r\n '\\2','0','7','5', '\\2','0','7','6', '\\2','0','7','7', '\\2','0','7','8', '\\2','0','7','9', \r\n '\\2','0','8','0', '\\2','0','8','1', '\\2','0','8','2', '\\2','0','8','3', '\\2','0','8','4', \r\n '\\2','0','8','5', '\\2','0','8','6', '\\2','0','8','7', '\\2','0','8','8', '\\2','0','8','9', \r\n '\\2','0','9','0', '\\2','0','9','1', '\\2','0','9','2', '\\2','0','9','3', '\\2','0','9','4', \r\n '\\2','0','9','5', '\\2','0','9','6', '\\2','0','9','7', '\\2','0','9','8', '\\2','0','9','9', \r\n '\\3','1','0','0', '\\3','1','0','1', '\\3','1','0','2', '\\3','1','0','3', '\\3','1','0','4', \r\n '\\3','1','0','5', '\\3','1','0','6', '\\3','1','0','7', '\\3','1','0','8', '\\3','1','0','9', \r\n '\\3','1','1','0', '\\3','1','1','1', '\\3','1','1','2', '\\3','1','1','3', '\\3','1','1','4', \r\n '\\3','1','1','5', '\\3','1','1','6', '\\3','1','1','7', '\\3','1','1','8', '\\3','1','1','9', \r\n '\\3','1','2','0', '\\3','1','2','1', '\\3','1','2','2', '\\3','1','2','3', '\\3','1','2','4', \r\n '\\3','1','2','5', '\\3','1','2','6', '\\3','1','2','7', '\\3','1','2','8', '\\3','1','2','9', \r\n '\\3','1','3','0', '\\3','1','3','1', '\\3','1','3','2', '\\3','1','3','3', '\\3','1','3','4', \r\n '\\3','1','3','5', '\\3','1','3','6', '\\3','1','3','7', '\\3','1','3','8', '\\3','1','3','9', \r\n '\\3','1','4','0', '\\3','1','4','1', '\\3','1','4','2', '\\3','1','4','3', '\\3','1','4','4', \r\n '\\3','1','4','5', '\\3','1','4','6', '\\3','1','4','7', '\\3','1','4','8', '\\3','1','4','9', \r\n '\\3','1','5','0', '\\3','1','5','1', '\\3','1','5','2', '\\3','1','5','3', '\\3','1','5','4', \r\n '\\3','1','5','5', '\\3','1','5','6', '\\3','1','5','7', '\\3','1','5','8', '\\3','1','5','9', \r\n '\\3','1','6','0', '\\3','1','6','1', '\\3','1','6','2', '\\3','1','6','3', '\\3','1','6','4', \r\n '\\3','1','6','5', '\\3','1','6','6', '\\3','1','6','7', '\\3','1','6','8', '\\3','1','6','9', \r\n '\\3','1','7','0', '\\3','1','7','1', '\\3','1','7','2', '\\3','1','7','3', '\\3','1','7','4', \r\n '\\3','1','7','5', '\\3','1','7','6', '\\3','1','7','7', '\\3','1','7','8', '\\3','1','7','9', \r\n '\\3','1','8','0', '\\3','1','8','1', '\\3','1','8','2', '\\3','1','8','3', '\\3','1','8','4', \r\n '\\3','1','8','5', '\\3','1','8','6', '\\3','1','8','7', '\\3','1','8','8', '\\3','1','8','9', \r\n '\\3','1','9','0', '\\3','1','9','1', '\\3','1','9','2', '\\3','1','9','3', '\\3','1','9','4', \r\n '\\3','1','9','5', '\\3','1','9','6', '\\3','1','9','7', '\\3','1','9','8', '\\3','1','9','9', \r\n '\\3','2','0','0', '\\3','2','0','1', '\\3','2','0','2', '\\3','2','0','3', '\\3','2','0','4', \r\n '\\3','2','0','5', '\\3','2','0','6', '\\3','2','0','7', '\\3','2','0','8', '\\3','2','0','9', \r\n '\\3','2','1','0', '\\3','2','1','1', '\\3','2','1','2', '\\3','2','1','3', '\\3','2','1','4', \r\n '\\3','2','1','5', '\\3','2','1','6', '\\3','2','1','7', '\\3','2','1','8', '\\3','2','1','9', \r\n '\\3','2','2','0', '\\3','2','2','1', '\\3','2','2','2', '\\3','2','2','3', '\\3','2','2','4', \r\n '\\3','2','2','5', '\\3','2','2','6', '\\3','2','2','7', '\\3','2','2','8', '\\3','2','2','9', \r\n '\\3','2','3','0', '\\3','2','3','1', '\\3','2','3','2', '\\3','2','3','3', '\\3','2','3','4', \r\n '\\3','2','3','5', '\\3','2','3','6', '\\3','2','3','7', '\\3','2','3','8', '\\3','2','3','9', \r\n '\\3','2','4','0', '\\3','2','4','1', '\\3','2','4','2', '\\3','2','4','3', '\\3','2','4','4', \r\n '\\3','2','4','5', '\\3','2','4','6', '\\3','2','4','7', '\\3','2','4','8', '\\3','2','4','9', \r\n '\\3','2','5','0', '\\3','2','5','1', '\\3','2','5','2', '\\3','2','5','3', '\\3','2','5','4', \r\n '\\3','2','5','5', '\\3','2','5','6', '\\3','2','5','7', '\\3','2','5','8', '\\3','2','5','9', \r\n '\\3','2','6','0', '\\3','2','6','1', '\\3','2','6','2', '\\3','2','6','3', '\\3','2','6','4', \r\n '\\3','2','6','5', '\\3','2','6','6', '\\3','2','6','7', '\\3','2','6','8', '\\3','2','6','9', \r\n '\\3','2','7','0', '\\3','2','7','1', '\\3','2','7','2', '\\3','2','7','3', '\\3','2','7','4', \r\n '\\3','2','7','5', '\\3','2','7','6', '\\3','2','7','7', '\\3','2','7','8', '\\3','2','7','9', \r\n '\\3','2','8','0', '\\3','2','8','1', '\\3','2','8','2', '\\3','2','8','3', '\\3','2','8','4', \r\n '\\3','2','8','5', '\\3','2','8','6', '\\3','2','8','7', '\\3','2','8','8', '\\3','2','8','9', \r\n '\\3','2','9','0', '\\3','2','9','1', '\\3','2','9','2', '\\3','2','9','3', '\\3','2','9','4', \r\n '\\3','2','9','5', '\\3','2','9','6', '\\3','2','9','7', '\\3','2','9','8', '\\3','2','9','9', \r\n '\\3','3','0','0', '\\3','3','0','1', '\\3','3','0','2', '\\3','3','0','3', '\\3','3','0','4', \r\n '\\3','3','0','5', '\\3','3','0','6', '\\3','3','0','7', '\\3','3','0','8', '\\3','3','0','9', \r\n '\\3','3','1','0', '\\3','3','1','1', '\\3','3','1','2', '\\3','3','1','3', '\\3','3','1','4', \r\n '\\3','3','1','5', '\\3','3','1','6', '\\3','3','1','7', '\\3','3','1','8', '\\3','3','1','9', \r\n '\\3','3','2','0', '\\3','3','2','1', '\\3','3','2','2', '\\3','3','2','3', '\\3','3','2','4', \r\n '\\3','3','2','5', '\\3','3','2','6', '\\3','3','2','7', '\\3','3','2','8', '\\3','3','2','9', \r\n '\\3','3','3','0', '\\3','3','3','1', '\\3','3','3','2', '\\3','3','3','3', '\\3','3','3','4', \r\n '\\3','3','3','5', '\\3','3','3','6', '\\3','3','3','7', '\\3','3','3','8', '\\3','3','3','9', \r\n '\\3','3','4','0', '\\3','3','4','1', '\\3','3','4','2', '\\3','3','4','3', '\\3','3','4','4', \r\n '\\3','3','4','5', '\\3','3','4','6', '\\3','3','4','7', '\\3','3','4','8', '\\3','3','4','9', \r\n '\\3','3','5','0', '\\3','3','5','1', '\\3','3','5','2', '\\3','3','5','3', '\\3','3','5','4', \r\n '\\3','3','5','5', '\\3','3','5','6', '\\3','3','5','7', '\\3','3','5','8', '\\3','3','5','9', \r\n '\\3','3','6','0', '\\3','3','6','1', '\\3','3','6','2', '\\3','3','6','3', '\\3','3','6','4', \r\n '\\3','3','6','5', '\\3','3','6','6', '\\3','3','6','7', '\\3','3','6','8', '\\3','3','6','9', \r\n '\\3','3','7','0', '\\3','3','7','1', '\\3','3','7','2', '\\3','3','7','3', '\\3','3','7','4', \r\n '\\3','3','7','5', '\\3','3','7','6', '\\3','3','7','7', '\\3','3','7','8', '\\3','3','7','9', \r\n '\\3','3','8','0', '\\3','3','8','1', '\\3','3','8','2', '\\3','3','8','3', '\\3','3','8','4', \r\n '\\3','3','8','5', '\\3','3','8','6', '\\3','3','8','7', '\\3','3','8','8', '\\3','3','8','9', \r\n '\\3','3','9','0', '\\3','3','9','1', '\\3','3','9','2', '\\3','3','9','3', '\\3','3','9','4', \r\n '\\3','3','9','5', '\\3','3','9','6', '\\3','3','9','7', '\\3','3','9','8', '\\3','3','9','9', \r\n '\\3','4','0','0', '\\3','4','0','1', '\\3','4','0','2', '\\3','4','0','3', '\\3','4','0','4', \r\n '\\3','4','0','5', '\\3','4','0','6', '\\3','4','0','7', '\\3','4','0','8', '\\3','4','0','9', \r\n '\\3','4','1','0', '\\3','4','1','1', '\\3','4','1','2', '\\3','4','1','3', '\\3','4','1','4', \r\n '\\3','4','1','5', '\\3','4','1','6', '\\3','4','1','7', '\\3','4','1','8', '\\3','4','1','9', \r\n '\\3','4','2','0', '\\3','4','2','1', '\\3','4','2','2', '\\3','4','2','3', '\\3','4','2','4', \r\n '\\3','4','2','5', '\\3','4','2','6', '\\3','4','2','7', '\\3','4','2','8', '\\3','4','2','9', \r\n '\\3','4','3','0', '\\3','4','3','1', '\\3','4','3','2', '\\3','4','3','3', '\\3','4','3','4', \r\n '\\3','4','3','5', '\\3','4','3','6', '\\3','4','3','7', '\\3','4','3','8', '\\3','4','3','9', \r\n '\\3','4','4','0', '\\3','4','4','1', '\\3','4','4','2', '\\3','4','4','3', '\\3','4','4','4', \r\n '\\3','4','4','5', '\\3','4','4','6', '\\3','4','4','7', '\\3','4','4','8', '\\3','4','4','9', \r\n '\\3','4','5','0', '\\3','4','5','1', '\\3','4','5','2', '\\3','4','5','3', '\\3','4','5','4', \r\n '\\3','4','5','5', '\\3','4','5','6', '\\3','4','5','7', '\\3','4','5','8', '\\3','4','5','9', \r\n '\\3','4','6','0', '\\3','4','6','1', '\\3','4','6','2', '\\3','4','6','3', '\\3','4','6','4', \r\n '\\3','4','6','5', '\\3','4','6','6', '\\3','4','6','7', '\\3','4','6','8', '\\3','4','6','9', \r\n '\\3','4','7','0', '\\3','4','7','1', '\\3','4','7','2', '\\3','4','7','3', '\\3','4','7','4', \r\n '\\3','4','7','5', '\\3','4','7','6', '\\3','4','7','7', '\\3','4','7','8', '\\3','4','7','9', \r\n '\\3','4','8','0', '\\3','4','8','1', '\\3','4','8','2', '\\3','4','8','3', '\\3','4','8','4', \r\n '\\3','4','8','5', '\\3','4','8','6', '\\3','4','8','7', '\\3','4','8','8', '\\3','4','8','9', \r\n '\\3','4','9','0', '\\3','4','9','1', '\\3','4','9','2', '\\3','4','9','3', '\\3','4','9','4', \r\n '\\3','4','9','5', '\\3','4','9','6', '\\3','4','9','7', '\\3','4','9','8', '\\3','4','9','9', \r\n '\\3','5','0','0', '\\3','5','0','1', '\\3','5','0','2', '\\3','5','0','3', '\\3','5','0','4', \r\n '\\3','5','0','5', '\\3','5','0','6', '\\3','5','0','7', '\\3','5','0','8', '\\3','5','0','9', \r\n '\\3','5','1','0', '\\3','5','1','1', '\\3','5','1','2', '\\3','5','1','3', '\\3','5','1','4', \r\n '\\3','5','1','5', '\\3','5','1','6', '\\3','5','1','7', '\\3','5','1','8', '\\3','5','1','9', \r\n '\\3','5','2','0', '\\3','5','2','1', '\\3','5','2','2', '\\3','5','2','3', '\\3','5','2','4', \r\n '\\3','5','2','5', '\\3','5','2','6', '\\3','5','2','7', '\\3','5','2','8', '\\3','5','2','9', \r\n '\\3','5','3','0', '\\3','5','3','1', '\\3','5','3','2', '\\3','5','3','3', '\\3','5','3','4', \r\n '\\3','5','3','5', '\\3','5','3','6', '\\3','5','3','7', '\\3','5','3','8', '\\3','5','3','9', \r\n '\\3','5','4','0', '\\3','5','4','1', '\\3','5','4','2', '\\3','5','4','3', '\\3','5','4','4', \r\n '\\3','5','4','5', '\\3','5','4','6', '\\3','5','4','7', '\\3','5','4','8', '\\3','5','4','9', \r\n '\\3','5','5','0', '\\3','5','5','1', '\\3','5','5','2', '\\3','5','5','3', '\\3','5','5','4', \r\n '\\3','5','5','5', '\\3','5','5','6', '\\3','5','5','7', '\\3','5','5','8', '\\3','5','5','9', \r\n '\\3','5','6','0', '\\3','5','6','1', '\\3','5','6','2', '\\3','5','6','3', '\\3','5','6','4', \r\n '\\3','5','6','5', '\\3','5','6','6', '\\3','5','6','7', '\\3','5','6','8', '\\3','5','6','9', \r\n '\\3','5','7','0', '\\3','5','7','1', '\\3','5','7','2', '\\3','5','7','3', '\\3','5','7','4', \r\n '\\3','5','7','5', '\\3','5','7','6', '\\3','5','7','7', '\\3','5','7','8', '\\3','5','7','9', \r\n '\\3','5','8','0', '\\3','5','8','1', '\\3','5','8','2', '\\3','5','8','3', '\\3','5','8','4', \r\n '\\3','5','8','5', '\\3','5','8','6', '\\3','5','8','7', '\\3','5','8','8', '\\3','5','8','9', \r\n '\\3','5','9','0', '\\3','5','9','1', '\\3','5','9','2', '\\3','5','9','3', '\\3','5','9','4', \r\n '\\3','5','9','5', '\\3','5','9','6', '\\3','5','9','7', '\\3','5','9','8', '\\3','5','9','9', \r\n '\\3','6','0','0', '\\3','6','0','1', '\\3','6','0','2', '\\3','6','0','3', '\\3','6','0','4', \r\n '\\3','6','0','5', '\\3','6','0','6', '\\3','6','0','7', '\\3','6','0','8', '\\3','6','0','9', \r\n '\\3','6','1','0', '\\3','6','1','1', '\\3','6','1','2', '\\3','6','1','3', '\\3','6','1','4', \r\n '\\3','6','1','5', '\\3','6','1','6', '\\3','6','1','7', '\\3','6','1','8', '\\3','6','1','9', \r\n '\\3','6','2','0', '\\3','6','2','1', '\\3','6','2','2', '\\3','6','2','3', '\\3','6','2','4', \r\n '\\3','6','2','5', '\\3','6','2','6', '\\3','6','2','7', '\\3','6','2','8', '\\3','6','2','9', \r\n '\\3','6','3','0', '\\3','6','3','1', '\\3','6','3','2', '\\3','6','3','3', '\\3','6','3','4', \r\n '\\3','6','3','5', '\\3','6','3','6', '\\3','6','3','7', '\\3','6','3','8', '\\3','6','3','9', \r\n '\\3','6','4','0', '\\3','6','4','1', '\\3','6','4','2', '\\3','6','4','3', '\\3','6','4','4', \r\n '\\3','6','4','5', '\\3','6','4','6', '\\3','6','4','7', '\\3','6','4','8', '\\3','6','4','9', \r\n '\\3','6','5','0', '\\3','6','5','1', '\\3','6','5','2', '\\3','6','5','3', '\\3','6','5','4', \r\n '\\3','6','5','5', '\\3','6','5','6', '\\3','6','5','7', '\\3','6','5','8', '\\3','6','5','9', \r\n '\\3','6','6','0', '\\3','6','6','1', '\\3','6','6','2', '\\3','6','6','3', '\\3','6','6','4', \r\n '\\3','6','6','5', '\\3','6','6','6', '\\3','6','6','7', '\\3','6','6','8', '\\3','6','6','9', \r\n '\\3','6','7','0', '\\3','6','7','1', '\\3','6','7','2', '\\3','6','7','3', '\\3','6','7','4', \r\n '\\3','6','7','5', '\\3','6','7','6', '\\3','6','7','7', '\\3','6','7','8', '\\3','6','7','9', \r\n '\\3','6','8','0', '\\3','6','8','1', '\\3','6','8','2', '\\3','6','8','3', '\\3','6','8','4', \r\n '\\3','6','8','5', '\\3','6','8','6', '\\3','6','8','7', '\\3','6','8','8', '\\3','6','8','9', \r\n '\\3','6','9','0', '\\3','6','9','1', '\\3','6','9','2', '\\3','6','9','3', '\\3','6','9','4', \r\n '\\3','6','9','5', '\\3','6','9','6', '\\3','6','9','7', '\\3','6','9','8', '\\3','6','9','9', \r\n '\\3','7','0','0', '\\3','7','0','1', '\\3','7','0','2', '\\3','7','0','3', '\\3','7','0','4', \r\n '\\3','7','0','5', '\\3','7','0','6', '\\3','7','0','7', '\\3','7','0','8', '\\3','7','0','9', \r\n '\\3','7','1','0', '\\3','7','1','1', '\\3','7','1','2', '\\3','7','1','3', '\\3','7','1','4', \r\n '\\3','7','1','5', '\\3','7','1','6', '\\3','7','1','7', '\\3','7','1','8', '\\3','7','1','9', \r\n '\\3','7','2','0', '\\3','7','2','1', '\\3','7','2','2', '\\3','7','2','3', '\\3','7','2','4', \r\n '\\3','7','2','5', '\\3','7','2','6', '\\3','7','2','7', '\\3','7','2','8', '\\3','7','2','9', \r\n '\\3','7','3','0', '\\3','7','3','1', '\\3','7','3','2', '\\3','7','3','3', '\\3','7','3','4', \r\n '\\3','7','3','5', '\\3','7','3','6', '\\3','7','3','7', '\\3','7','3','8', '\\3','7','3','9', \r\n '\\3','7','4','0', '\\3','7','4','1', '\\3','7','4','2', '\\3','7','4','3', '\\3','7','4','4', \r\n '\\3','7','4','5', '\\3','7','4','6', '\\3','7','4','7', '\\3','7','4','8', '\\3','7','4','9', \r\n '\\3','7','5','0', '\\3','7','5','1', '\\3','7','5','2', '\\3','7','5','3', '\\3','7','5','4', \r\n '\\3','7','5','5', '\\3','7','5','6', '\\3','7','5','7', '\\3','7','5','8', '\\3','7','5','9', \r\n '\\3','7','6','0', '\\3','7','6','1', '\\3','7','6','2', '\\3','7','6','3', '\\3','7','6','4', \r\n '\\3','7','6','5', '\\3','7','6','6', '\\3','7','6','7', '\\3','7','6','8', '\\3','7','6','9', \r\n '\\3','7','7','0', '\\3','7','7','1', '\\3','7','7','2', '\\3','7','7','3', '\\3','7','7','4', \r\n '\\3','7','7','5', '\\3','7','7','6', '\\3','7','7','7', '\\3','7','7','8', '\\3','7','7','9', \r\n '\\3','7','8','0', '\\3','7','8','1', '\\3','7','8','2', '\\3','7','8','3', '\\3','7','8','4', \r\n '\\3','7','8','5', '\\3','7','8','6', '\\3','7','8','7', '\\3','7','8','8', '\\3','7','8','9', \r\n '\\3','7','9','0', '\\3','7','9','1', '\\3','7','9','2', '\\3','7','9','3', '\\3','7','9','4', \r\n '\\3','7','9','5', '\\3','7','9','6', '\\3','7','9','7', '\\3','7','9','8', '\\3','7','9','9', \r\n '\\3','8','0','0', '\\3','8','0','1', '\\3','8','0','2', '\\3','8','0','3', '\\3','8','0','4', \r\n '\\3','8','0','5', '\\3','8','0','6', '\\3','8','0','7', '\\3','8','0','8', '\\3','8','0','9', \r\n '\\3','8','1','0', '\\3','8','1','1', '\\3','8','1','2', '\\3','8','1','3', '\\3','8','1','4', \r\n '\\3','8','1','5', '\\3','8','1','6', '\\3','8','1','7', '\\3','8','1','8', '\\3','8','1','9', \r\n '\\3','8','2','0', '\\3','8','2','1', '\\3','8','2','2', '\\3','8','2','3', '\\3','8','2','4', \r\n '\\3','8','2','5', '\\3','8','2','6', '\\3','8','2','7', '\\3','8','2','8', '\\3','8','2','9', \r\n '\\3','8','3','0', '\\3','8','3','1', '\\3','8','3','2', '\\3','8','3','3', '\\3','8','3','4', \r\n '\\3','8','3','5', '\\3','8','3','6', '\\3','8','3','7', '\\3','8','3','8', '\\3','8','3','9', \r\n '\\3','8','4','0', '\\3','8','4','1', '\\3','8','4','2', '\\3','8','4','3', '\\3','8','4','4', \r\n '\\3','8','4','5', '\\3','8','4','6', '\\3','8','4','7', '\\3','8','4','8', '\\3','8','4','9', \r\n '\\3','8','5','0', '\\3','8','5','1', '\\3','8','5','2', '\\3','8','5','3', '\\3','8','5','4', \r\n '\\3','8','5','5', '\\3','8','5','6', '\\3','8','5','7', '\\3','8','5','8', '\\3','8','5','9', \r\n '\\3','8','6','0', '\\3','8','6','1', '\\3','8','6','2', '\\3','8','6','3', '\\3','8','6','4', \r\n '\\3','8','6','5', '\\3','8','6','6', '\\3','8','6','7', '\\3','8','6','8', '\\3','8','6','9', \r\n '\\3','8','7','0', '\\3','8','7','1', '\\3','8','7','2', '\\3','8','7','3', '\\3','8','7','4', \r\n '\\3','8','7','5', '\\3','8','7','6', '\\3','8','7','7', '\\3','8','7','8', '\\3','8','7','9', \r\n '\\3','8','8','0', '\\3','8','8','1', '\\3','8','8','2', '\\3','8','8','3', '\\3','8','8','4', \r\n '\\3','8','8','5', '\\3','8','8','6', '\\3','8','8','7', '\\3','8','8','8', '\\3','8','8','9', \r\n '\\3','8','9','0', '\\3','8','9','1', '\\3','8','9','2', '\\3','8','9','3', '\\3','8','9','4', \r\n '\\3','8','9','5', '\\3','8','9','6', '\\3','8','9','7', '\\3','8','9','8', '\\3','8','9','9', \r\n '\\3','9','0','0', '\\3','9','0','1', '\\3','9','0','2', '\\3','9','0','3', '\\3','9','0','4', \r\n '\\3','9','0','5', '\\3','9','0','6', '\\3','9','0','7', '\\3','9','0','8', '\\3','9','0','9', \r\n '\\3','9','1','0', '\\3','9','1','1', '\\3','9','1','2', '\\3','9','1','3', '\\3','9','1','4', \r\n '\\3','9','1','5', '\\3','9','1','6', '\\3','9','1','7', '\\3','9','1','8', '\\3','9','1','9', \r\n '\\3','9','2','0', '\\3','9','2','1', '\\3','9','2','2', '\\3','9','2','3', '\\3','9','2','4', \r\n '\\3','9','2','5', '\\3','9','2','6', '\\3','9','2','7', '\\3','9','2','8', '\\3','9','2','9', \r\n '\\3','9','3','0', '\\3','9','3','1', '\\3','9','3','2', '\\3','9','3','3', '\\3','9','3','4', \r\n '\\3','9','3','5', '\\3','9','3','6', '\\3','9','3','7', '\\3','9','3','8', '\\3','9','3','9', \r\n '\\3','9','4','0', '\\3','9','4','1', '\\3','9','4','2', '\\3','9','4','3', '\\3','9','4','4', \r\n '\\3','9','4','5', '\\3','9','4','6', '\\3','9','4','7', '\\3','9','4','8', '\\3','9','4','9', \r\n '\\3','9','5','0', '\\3','9','5','1', '\\3','9','5','2', '\\3','9','5','3', '\\3','9','5','4', \r\n '\\3','9','5','5', '\\3','9','5','6', '\\3','9','5','7', '\\3','9','5','8', '\\3','9','5','9', \r\n '\\3','9','6','0', '\\3','9','6','1', '\\3','9','6','2', '\\3','9','6','3', '\\3','9','6','4', \r\n '\\3','9','6','5', '\\3','9','6','6', '\\3','9','6','7', '\\3','9','6','8', '\\3','9','6','9', \r\n '\\3','9','7','0', '\\3','9','7','1', '\\3','9','7','2', '\\3','9','7','3', '\\3','9','7','4', \r\n '\\3','9','7','5', '\\3','9','7','6', '\\3','9','7','7', '\\3','9','7','8', '\\3','9','7','9', \r\n '\\3','9','8','0', '\\3','9','8','1', '\\3','9','8','2', '\\3','9','8','3', '\\3','9','8','4', \r\n '\\3','9','8','5', '\\3','9','8','6', '\\3','9','8','7', '\\3','9','8','8', '\\3','9','8','9', \r\n '\\3','9','9','0', '\\3','9','9','1', '\\3','9','9','2', '\\3','9','9','3', '\\3','9','9','4', \r\n '\\3','9','9','5', '\\3','9','9','6', '\\3','9','9','7', '\\3','9','9','8', '\\3','9','9','9', '\\0'};\r\n#endif\r\n \r\n#if defined(DEC_DPD2BCD8) && DEC_DPD2BCD8==1 && !defined(DECDPD2BCD8)\r\n#define DECDPD2BCD8\r\n \r\nconst uint8_t DPD2BCD8[4096]={\r\n 0,0,0,0, 0,0,1,1, 0,0,2,1, 0,0,3,1, 0,0,4,1, 0,0,5,1, 0,0,6,1, 0,0,7,1, 0,0,8,1, \r\n 0,0,9,1, 0,8,0,2, 0,8,1,2, 8,0,0,3, 8,0,1,3, 8,8,0,3, 8,8,1,3, 0,1,0,2, 0,1,1,2, \r\n 0,1,2,2, 0,1,3,2, 0,1,4,2, 0,1,5,2, 0,1,6,2, 0,1,7,2, 0,1,8,2, 0,1,9,2, 0,9,0,2, \r\n 0,9,1,2, 8,1,0,3, 8,1,1,3, 8,9,0,3, 8,9,1,3, 0,2,0,2, 0,2,1,2, 0,2,2,2, 0,2,3,2, \r\n 0,2,4,2, 0,2,5,2, 0,2,6,2, 0,2,7,2, 0,2,8,2, 0,2,9,2, 0,8,2,2, 0,8,3,2, 8,2,0,3, \r\n 8,2,1,3, 8,0,8,3, 8,0,9,3, 0,3,0,2, 0,3,1,2, 0,3,2,2, 0,3,3,2, 0,3,4,2, 0,3,5,2, \r\n 0,3,6,2, 0,3,7,2, 0,3,8,2, 0,3,9,2, 0,9,2,2, 0,9,3,2, 8,3,0,3, 8,3,1,3, 8,1,8,3, \r\n 8,1,9,3, 0,4,0,2, 0,4,1,2, 0,4,2,2, 0,4,3,2, 0,4,4,2, 0,4,5,2, 0,4,6,2, 0,4,7,2, \r\n 0,4,8,2, 0,4,9,2, 0,8,4,2, 0,8,5,2, 8,4,0,3, 8,4,1,3, 0,8,8,2, 0,8,9,2, 0,5,0,2, \r\n 0,5,1,2, 0,5,2,2, 0,5,3,2, 0,5,4,2, 0,5,5,2, 0,5,6,2, 0,5,7,2, 0,5,8,2, 0,5,9,2, \r\n 0,9,4,2, 0,9,5,2, 8,5,0,3, 8,5,1,3, 0,9,8,2, 0,9,9,2, 0,6,0,2, 0,6,1,2, 0,6,2,2, \r\n 0,6,3,2, 0,6,4,2, 0,6,5,2, 0,6,6,2, 0,6,7,2, 0,6,8,2, 0,6,9,2, 0,8,6,2, 0,8,7,2, \r\n 8,6,0,3, 8,6,1,3, 8,8,8,3, 8,8,9,3, 0,7,0,2, 0,7,1,2, 0,7,2,2, 0,7,3,2, 0,7,4,2, \r\n 0,7,5,2, 0,7,6,2, 0,7,7,2, 0,7,8,2, 0,7,9,2, 0,9,6,2, 0,9,7,2, 8,7,0,3, 8,7,1,3, \r\n 8,9,8,3, 8,9,9,3, 1,0,0,3, 1,0,1,3, 1,0,2,3, 1,0,3,3, 1,0,4,3, 1,0,5,3, 1,0,6,3, \r\n 1,0,7,3, 1,0,8,3, 1,0,9,3, 1,8,0,3, 1,8,1,3, 9,0,0,3, 9,0,1,3, 9,8,0,3, 9,8,1,3, \r\n 1,1,0,3, 1,1,1,3, 1,1,2,3, 1,1,3,3, 1,1,4,3, 1,1,5,3, 1,1,6,3, 1,1,7,3, 1,1,8,3, \r\n 1,1,9,3, 1,9,0,3, 1,9,1,3, 9,1,0,3, 9,1,1,3, 9,9,0,3, 9,9,1,3, 1,2,0,3, 1,2,1,3, \r\n 1,2,2,3, 1,2,3,3, 1,2,4,3, 1,2,5,3, 1,2,6,3, 1,2,7,3, 1,2,8,3, 1,2,9,3, 1,8,2,3, \r\n 1,8,3,3, 9,2,0,3, 9,2,1,3, 9,0,8,3, 9,0,9,3, 1,3,0,3, 1,3,1,3, 1,3,2,3, 1,3,3,3, \r\n 1,3,4,3, 1,3,5,3, 1,3,6,3, 1,3,7,3, 1,3,8,3, 1,3,9,3, 1,9,2,3, 1,9,3,3, 9,3,0,3, \r\n 9,3,1,3, 9,1,8,3, 9,1,9,3, 1,4,0,3, 1,4,1,3, 1,4,2,3, 1,4,3,3, 1,4,4,3, 1,4,5,3, \r\n 1,4,6,3, 1,4,7,3, 1,4,8,3, 1,4,9,3, 1,8,4,3, 1,8,5,3, 9,4,0,3, 9,4,1,3, 1,8,8,3, \r\n 1,8,9,3, 1,5,0,3, 1,5,1,3, 1,5,2,3, 1,5,3,3, 1,5,4,3, 1,5,5,3, 1,5,6,3, 1,5,7,3, \r\n 1,5,8,3, 1,5,9,3, 1,9,4,3, 1,9,5,3, 9,5,0,3, 9,5,1,3, 1,9,8,3, 1,9,9,3, 1,6,0,3, \r\n 1,6,1,3, 1,6,2,3, 1,6,3,3, 1,6,4,3, 1,6,5,3, 1,6,6,3, 1,6,7,3, 1,6,8,3, 1,6,9,3, \r\n 1,8,6,3, 1,8,7,3, 9,6,0,3, 9,6,1,3, 9,8,8,3, 9,8,9,3, 1,7,0,3, 1,7,1,3, 1,7,2,3, \r\n 1,7,3,3, 1,7,4,3, 1,7,5,3, 1,7,6,3, 1,7,7,3, 1,7,8,3, 1,7,9,3, 1,9,6,3, 1,9,7,3, \r\n 9,7,0,3, 9,7,1,3, 9,9,8,3, 9,9,9,3, 2,0,0,3, 2,0,1,3, 2,0,2,3, 2,0,3,3, 2,0,4,3, \r\n 2,0,5,3, 2,0,6,3, 2,0,7,3, 2,0,8,3, 2,0,9,3, 2,8,0,3, 2,8,1,3, 8,0,2,3, 8,0,3,3, \r\n 8,8,2,3, 8,8,3,3, 2,1,0,3, 2,1,1,3, 2,1,2,3, 2,1,3,3, 2,1,4,3, 2,1,5,3, 2,1,6,3, \r\n 2,1,7,3, 2,1,8,3, 2,1,9,3, 2,9,0,3, 2,9,1,3, 8,1,2,3, 8,1,3,3, 8,9,2,3, 8,9,3,3, \r\n 2,2,0,3, 2,2,1,3, 2,2,2,3, 2,2,3,3, 2,2,4,3, 2,2,5,3, 2,2,6,3, 2,2,7,3, 2,2,8,3, \r\n 2,2,9,3, 2,8,2,3, 2,8,3,3, 8,2,2,3, 8,2,3,3, 8,2,8,3, 8,2,9,3, 2,3,0,3, 2,3,1,3, \r\n 2,3,2,3, 2,3,3,3, 2,3,4,3, 2,3,5,3, 2,3,6,3, 2,3,7,3, 2,3,8,3, 2,3,9,3, 2,9,2,3, \r\n 2,9,3,3, 8,3,2,3, 8,3,3,3, 8,3,8,3, 8,3,9,3, 2,4,0,3, 2,4,1,3, 2,4,2,3, 2,4,3,3, \r\n 2,4,4,3, 2,4,5,3, 2,4,6,3, 2,4,7,3, 2,4,8,3, 2,4,9,3, 2,8,4,3, 2,8,5,3, 8,4,2,3, \r\n 8,4,3,3, 2,8,8,3, 2,8,9,3, 2,5,0,3, 2,5,1,3, 2,5,2,3, 2,5,3,3, 2,5,4,3, 2,5,5,3, \r\n 2,5,6,3, 2,5,7,3, 2,5,8,3, 2,5,9,3, 2,9,4,3, 2,9,5,3, 8,5,2,3, 8,5,3,3, 2,9,8,3, \r\n 2,9,9,3, 2,6,0,3, 2,6,1,3, 2,6,2,3, 2,6,3,3, 2,6,4,3, 2,6,5,3, 2,6,6,3, 2,6,7,3, \r\n 2,6,8,3, 2,6,9,3, 2,8,6,3, 2,8,7,3, 8,6,2,3, 8,6,3,3, 8,8,8,3, 8,8,9,3, 2,7,0,3, \r\n 2,7,1,3, 2,7,2,3, 2,7,3,3, 2,7,4,3, 2,7,5,3, 2,7,6,3, 2,7,7,3, 2,7,8,3, 2,7,9,3, \r\n 2,9,6,3, 2,9,7,3, 8,7,2,3, 8,7,3,3, 8,9,8,3, 8,9,9,3, 3,0,0,3, 3,0,1,3, 3,0,2,3, \r\n 3,0,3,3, 3,0,4,3, 3,0,5,3, 3,0,6,3, 3,0,7,3, 3,0,8,3, 3,0,9,3, 3,8,0,3, 3,8,1,3, \r\n 9,0,2,3, 9,0,3,3, 9,8,2,3, 9,8,3,3, 3,1,0,3, 3,1,1,3, 3,1,2,3, 3,1,3,3, 3,1,4,3, \r\n 3,1,5,3, 3,1,6,3, 3,1,7,3, 3,1,8,3, 3,1,9,3, 3,9,0,3, 3,9,1,3, 9,1,2,3, 9,1,3,3, \r\n 9,9,2,3, 9,9,3,3, 3,2,0,3, 3,2,1,3, 3,2,2,3, 3,2,3,3, 3,2,4,3, 3,2,5,3, 3,2,6,3, \r\n 3,2,7,3, 3,2,8,3, 3,2,9,3, 3,8,2,3, 3,8,3,3, 9,2,2,3, 9,2,3,3, 9,2,8,3, 9,2,9,3, \r\n 3,3,0,3, 3,3,1,3, 3,3,2,3, 3,3,3,3, 3,3,4,3, 3,3,5,3, 3,3,6,3, 3,3,7,3, 3,3,8,3, \r\n 3,3,9,3, 3,9,2,3, 3,9,3,3, 9,3,2,3, 9,3,3,3, 9,3,8,3, 9,3,9,3, 3,4,0,3, 3,4,1,3, \r\n 3,4,2,3, 3,4,3,3, 3,4,4,3, 3,4,5,3, 3,4,6,3, 3,4,7,3, 3,4,8,3, 3,4,9,3, 3,8,4,3, \r\n 3,8,5,3, 9,4,2,3, 9,4,3,3, 3,8,8,3, 3,8,9,3, 3,5,0,3, 3,5,1,3, 3,5,2,3, 3,5,3,3, \r\n 3,5,4,3, 3,5,5,3, 3,5,6,3, 3,5,7,3, 3,5,8,3, 3,5,9,3, 3,9,4,3, 3,9,5,3, 9,5,2,3, \r\n 9,5,3,3, 3,9,8,3, 3,9,9,3, 3,6,0,3, 3,6,1,3, 3,6,2,3, 3,6,3,3, 3,6,4,3, 3,6,5,3, \r\n 3,6,6,3, 3,6,7,3, 3,6,8,3, 3,6,9,3, 3,8,6,3, 3,8,7,3, 9,6,2,3, 9,6,3,3, 9,8,8,3, \r\n 9,8,9,3, 3,7,0,3, 3,7,1,3, 3,7,2,3, 3,7,3,3, 3,7,4,3, 3,7,5,3, 3,7,6,3, 3,7,7,3, \r\n 3,7,8,3, 3,7,9,3, 3,9,6,3, 3,9,7,3, 9,7,2,3, 9,7,3,3, 9,9,8,3, 9,9,9,3, 4,0,0,3, \r\n 4,0,1,3, 4,0,2,3, 4,0,3,3, 4,0,4,3, 4,0,5,3, 4,0,6,3, 4,0,7,3, 4,0,8,3, 4,0,9,3, \r\n 4,8,0,3, 4,8,1,3, 8,0,4,3, 8,0,5,3, 8,8,4,3, 8,8,5,3, 4,1,0,3, 4,1,1,3, 4,1,2,3, \r\n 4,1,3,3, 4,1,4,3, 4,1,5,3, 4,1,6,3, 4,1,7,3, 4,1,8,3, 4,1,9,3, 4,9,0,3, 4,9,1,3, \r\n 8,1,4,3, 8,1,5,3, 8,9,4,3, 8,9,5,3, 4,2,0,3, 4,2,1,3, 4,2,2,3, 4,2,3,3, 4,2,4,3, \r\n 4,2,5,3, 4,2,6,3, 4,2,7,3, 4,2,8,3, 4,2,9,3, 4,8,2,3, 4,8,3,3, 8,2,4,3, 8,2,5,3, \r\n 8,4,8,3, 8,4,9,3, 4,3,0,3, 4,3,1,3, 4,3,2,3, 4,3,3,3, 4,3,4,3, 4,3,5,3, 4,3,6,3, \r\n 4,3,7,3, 4,3,8,3, 4,3,9,3, 4,9,2,3, 4,9,3,3, 8,3,4,3, 8,3,5,3, 8,5,8,3, 8,5,9,3, \r\n 4,4,0,3, 4,4,1,3, 4,4,2,3, 4,4,3,3, 4,4,4,3, 4,4,5,3, 4,4,6,3, 4,4,7,3, 4,4,8,3, \r\n 4,4,9,3, 4,8,4,3, 4,8,5,3, 8,4,4,3, 8,4,5,3, 4,8,8,3, 4,8,9,3, 4,5,0,3, 4,5,1,3, \r\n 4,5,2,3, 4,5,3,3, 4,5,4,3, 4,5,5,3, 4,5,6,3, 4,5,7,3, 4,5,8,3, 4,5,9,3, 4,9,4,3, \r\n 4,9,5,3, 8,5,4,3, 8,5,5,3, 4,9,8,3, 4,9,9,3, 4,6,0,3, 4,6,1,3, 4,6,2,3, 4,6,3,3, \r\n 4,6,4,3, 4,6,5,3, 4,6,6,3, 4,6,7,3, 4,6,8,3, 4,6,9,3, 4,8,6,3, 4,8,7,3, 8,6,4,3, \r\n 8,6,5,3, 8,8,8,3, 8,8,9,3, 4,7,0,3, 4,7,1,3, 4,7,2,3, 4,7,3,3, 4,7,4,3, 4,7,5,3, \r\n 4,7,6,3, 4,7,7,3, 4,7,8,3, 4,7,9,3, 4,9,6,3, 4,9,7,3, 8,7,4,3, 8,7,5,3, 8,9,8,3, \r\n 8,9,9,3, 5,0,0,3, 5,0,1,3, 5,0,2,3, 5,0,3,3, 5,0,4,3, 5,0,5,3, 5,0,6,3, 5,0,7,3, \r\n 5,0,8,3, 5,0,9,3, 5,8,0,3, 5,8,1,3, 9,0,4,3, 9,0,5,3, 9,8,4,3, 9,8,5,3, 5,1,0,3, \r\n 5,1,1,3, 5,1,2,3, 5,1,3,3, 5,1,4,3, 5,1,5,3, 5,1,6,3, 5,1,7,3, 5,1,8,3, 5,1,9,3, \r\n 5,9,0,3, 5,9,1,3, 9,1,4,3, 9,1,5,3, 9,9,4,3, 9,9,5,3, 5,2,0,3, 5,2,1,3, 5,2,2,3, \r\n 5,2,3,3, 5,2,4,3, 5,2,5,3, 5,2,6,3, 5,2,7,3, 5,2,8,3, 5,2,9,3, 5,8,2,3, 5,8,3,3, \r\n 9,2,4,3, 9,2,5,3, 9,4,8,3, 9,4,9,3, 5,3,0,3, 5,3,1,3, 5,3,2,3, 5,3,3,3, 5,3,4,3, \r\n 5,3,5,3, 5,3,6,3, 5,3,7,3, 5,3,8,3, 5,3,9,3, 5,9,2,3, 5,9,3,3, 9,3,4,3, 9,3,5,3, \r\n 9,5,8,3, 9,5,9,3, 5,4,0,3, 5,4,1,3, 5,4,2,3, 5,4,3,3, 5,4,4,3, 5,4,5,3, 5,4,6,3, \r\n 5,4,7,3, 5,4,8,3, 5,4,9,3, 5,8,4,3, 5,8,5,3, 9,4,4,3, 9,4,5,3, 5,8,8,3, 5,8,9,3, \r\n 5,5,0,3, 5,5,1,3, 5,5,2,3, 5,5,3,3, 5,5,4,3, 5,5,5,3, 5,5,6,3, 5,5,7,3, 5,5,8,3, \r\n 5,5,9,3, 5,9,4,3, 5,9,5,3, 9,5,4,3, 9,5,5,3, 5,9,8,3, 5,9,9,3, 5,6,0,3, 5,6,1,3, \r\n 5,6,2,3, 5,6,3,3, 5,6,4,3, 5,6,5,3, 5,6,6,3, 5,6,7,3, 5,6,8,3, 5,6,9,3, 5,8,6,3, \r\n 5,8,7,3, 9,6,4,3, 9,6,5,3, 9,8,8,3, 9,8,9,3, 5,7,0,3, 5,7,1,3, 5,7,2,3, 5,7,3,3, \r\n 5,7,4,3, 5,7,5,3, 5,7,6,3, 5,7,7,3, 5,7,8,3, 5,7,9,3, 5,9,6,3, 5,9,7,3, 9,7,4,3, \r\n 9,7,5,3, 9,9,8,3, 9,9,9,3, 6,0,0,3, 6,0,1,3, 6,0,2,3, 6,0,3,3, 6,0,4,3, 6,0,5,3, \r\n 6,0,6,3, 6,0,7,3, 6,0,8,3, 6,0,9,3, 6,8,0,3, 6,8,1,3, 8,0,6,3, 8,0,7,3, 8,8,6,3, \r\n 8,8,7,3, 6,1,0,3, 6,1,1,3, 6,1,2,3, 6,1,3,3, 6,1,4,3, 6,1,5,3, 6,1,6,3, 6,1,7,3, \r\n 6,1,8,3, 6,1,9,3, 6,9,0,3, 6,9,1,3, 8,1,6,3, 8,1,7,3, 8,9,6,3, 8,9,7,3, 6,2,0,3, \r\n 6,2,1,3, 6,2,2,3, 6,2,3,3, 6,2,4,3, 6,2,5,3, 6,2,6,3, 6,2,7,3, 6,2,8,3, 6,2,9,3, \r\n 6,8,2,3, 6,8,3,3, 8,2,6,3, 8,2,7,3, 8,6,8,3, 8,6,9,3, 6,3,0,3, 6,3,1,3, 6,3,2,3, \r\n 6,3,3,3, 6,3,4,3, 6,3,5,3, 6,3,6,3, 6,3,7,3, 6,3,8,3, 6,3,9,3, 6,9,2,3, 6,9,3,3, \r\n 8,3,6,3, 8,3,7,3, 8,7,8,3, 8,7,9,3, 6,4,0,3, 6,4,1,3, 6,4,2,3, 6,4,3,3, 6,4,4,3, \r\n 6,4,5,3, 6,4,6,3, 6,4,7,3, 6,4,8,3, 6,4,9,3, 6,8,4,3, 6,8,5,3, 8,4,6,3, 8,4,7,3, \r\n 6,8,8,3, 6,8,9,3, 6,5,0,3, 6,5,1,3, 6,5,2,3, 6,5,3,3, 6,5,4,3, 6,5,5,3, 6,5,6,3, \r\n 6,5,7,3, 6,5,8,3, 6,5,9,3, 6,9,4,3, 6,9,5,3, 8,5,6,3, 8,5,7,3, 6,9,8,3, 6,9,9,3, \r\n 6,6,0,3, 6,6,1,3, 6,6,2,3, 6,6,3,3, 6,6,4,3, 6,6,5,3, 6,6,6,3, 6,6,7,3, 6,6,8,3, \r\n 6,6,9,3, 6,8,6,3, 6,8,7,3, 8,6,6,3, 8,6,7,3, 8,8,8,3, 8,8,9,3, 6,7,0,3, 6,7,1,3, \r\n 6,7,2,3, 6,7,3,3, 6,7,4,3, 6,7,5,3, 6,7,6,3, 6,7,7,3, 6,7,8,3, 6,7,9,3, 6,9,6,3, \r\n 6,9,7,3, 8,7,6,3, 8,7,7,3, 8,9,8,3, 8,9,9,3, 7,0,0,3, 7,0,1,3, 7,0,2,3, 7,0,3,3, \r\n 7,0,4,3, 7,0,5,3, 7,0,6,3, 7,0,7,3, 7,0,8,3, 7,0,9,3, 7,8,0,3, 7,8,1,3, 9,0,6,3, \r\n 9,0,7,3, 9,8,6,3, 9,8,7,3, 7,1,0,3, 7,1,1,3, 7,1,2,3, 7,1,3,3, 7,1,4,3, 7,1,5,3, \r\n 7,1,6,3, 7,1,7,3, 7,1,8,3, 7,1,9,3, 7,9,0,3, 7,9,1,3, 9,1,6,3, 9,1,7,3, 9,9,6,3, \r\n 9,9,7,3, 7,2,0,3, 7,2,1,3, 7,2,2,3, 7,2,3,3, 7,2,4,3, 7,2,5,3, 7,2,6,3, 7,2,7,3, \r\n 7,2,8,3, 7,2,9,3, 7,8,2,3, 7,8,3,3, 9,2,6,3, 9,2,7,3, 9,6,8,3, 9,6,9,3, 7,3,0,3, \r\n 7,3,1,3, 7,3,2,3, 7,3,3,3, 7,3,4,3, 7,3,5,3, 7,3,6,3, 7,3,7,3, 7,3,8,3, 7,3,9,3, \r\n 7,9,2,3, 7,9,3,3, 9,3,6,3, 9,3,7,3, 9,7,8,3, 9,7,9,3, 7,4,0,3, 7,4,1,3, 7,4,2,3, \r\n 7,4,3,3, 7,4,4,3, 7,4,5,3, 7,4,6,3, 7,4,7,3, 7,4,8,3, 7,4,9,3, 7,8,4,3, 7,8,5,3, \r\n 9,4,6,3, 9,4,7,3, 7,8,8,3, 7,8,9,3, 7,5,0,3, 7,5,1,3, 7,5,2,3, 7,5,3,3, 7,5,4,3, \r\n 7,5,5,3, 7,5,6,3, 7,5,7,3, 7,5,8,3, 7,5,9,3, 7,9,4,3, 7,9,5,3, 9,5,6,3, 9,5,7,3, \r\n 7,9,8,3, 7,9,9,3, 7,6,0,3, 7,6,1,3, 7,6,2,3, 7,6,3,3, 7,6,4,3, 7,6,5,3, 7,6,6,3, \r\n 7,6,7,3, 7,6,8,3, 7,6,9,3, 7,8,6,3, 7,8,7,3, 9,6,6,3, 9,6,7,3, 9,8,8,3, 9,8,9,3, \r\n 7,7,0,3, 7,7,1,3, 7,7,2,3, 7,7,3,3, 7,7,4,3, 7,7,5,3, 7,7,6,3, 7,7,7,3, 7,7,8,3, \r\n 7,7,9,3, 7,9,6,3, 7,9,7,3, 9,7,6,3, 9,7,7,3, 9,9,8,3, 9,9,9,3};\r\n#endif\r\n \r\n#if defined(DEC_BIN2BCD8) && DEC_BIN2BCD8==1 && !defined(DECBIN2BCD8)\r\n#define DECBIN2BCD8\r\n \r\nconst uint8_t BIN2BCD8[4000]={\r\n 0,0,0,0, 0,0,1,1, 0,0,2,1, 0,0,3,1, 0,0,4,1, 0,0,5,1, 0,0,6,1, 0,0,7,1, 0,0,8,1, \r\n 0,0,9,1, 0,1,0,2, 0,1,1,2, 0,1,2,2, 0,1,3,2, 0,1,4,2, 0,1,5,2, 0,1,6,2, 0,1,7,2, \r\n 0,1,8,2, 0,1,9,2, 0,2,0,2, 0,2,1,2, 0,2,2,2, 0,2,3,2, 0,2,4,2, 0,2,5,2, 0,2,6,2, \r\n 0,2,7,2, 0,2,8,2, 0,2,9,2, 0,3,0,2, 0,3,1,2, 0,3,2,2, 0,3,3,2, 0,3,4,2, 0,3,5,2, \r\n 0,3,6,2, 0,3,7,2, 0,3,8,2, 0,3,9,2, 0,4,0,2, 0,4,1,2, 0,4,2,2, 0,4,3,2, 0,4,4,2, \r\n 0,4,5,2, 0,4,6,2, 0,4,7,2, 0,4,8,2, 0,4,9,2, 0,5,0,2, 0,5,1,2, 0,5,2,2, 0,5,3,2, \r\n 0,5,4,2, 0,5,5,2, 0,5,6,2, 0,5,7,2, 0,5,8,2, 0,5,9,2, 0,6,0,2, 0,6,1,2, 0,6,2,2, \r\n 0,6,3,2, 0,6,4,2, 0,6,5,2, 0,6,6,2, 0,6,7,2, 0,6,8,2, 0,6,9,2, 0,7,0,2, 0,7,1,2, \r\n 0,7,2,2, 0,7,3,2, 0,7,4,2, 0,7,5,2, 0,7,6,2, 0,7,7,2, 0,7,8,2, 0,7,9,2, 0,8,0,2, \r\n 0,8,1,2, 0,8,2,2, 0,8,3,2, 0,8,4,2, 0,8,5,2, 0,8,6,2, 0,8,7,2, 0,8,8,2, 0,8,9,2, \r\n 0,9,0,2, 0,9,1,2, 0,9,2,2, 0,9,3,2, 0,9,4,2, 0,9,5,2, 0,9,6,2, 0,9,7,2, 0,9,8,2, \r\n 0,9,9,2, 1,0,0,3, 1,0,1,3, 1,0,2,3, 1,0,3,3, 1,0,4,3, 1,0,5,3, 1,0,6,3, 1,0,7,3, \r\n 1,0,8,3, 1,0,9,3, 1,1,0,3, 1,1,1,3, 1,1,2,3, 1,1,3,3, 1,1,4,3, 1,1,5,3, 1,1,6,3, \r\n 1,1,7,3, 1,1,8,3, 1,1,9,3, 1,2,0,3, 1,2,1,3, 1,2,2,3, 1,2,3,3, 1,2,4,3, 1,2,5,3, \r\n 1,2,6,3, 1,2,7,3, 1,2,8,3, 1,2,9,3, 1,3,0,3, 1,3,1,3, 1,3,2,3, 1,3,3,3, 1,3,4,3, \r\n 1,3,5,3, 1,3,6,3, 1,3,7,3, 1,3,8,3, 1,3,9,3, 1,4,0,3, 1,4,1,3, 1,4,2,3, 1,4,3,3, \r\n 1,4,4,3, 1,4,5,3, 1,4,6,3, 1,4,7,3, 1,4,8,3, 1,4,9,3, 1,5,0,3, 1,5,1,3, 1,5,2,3, \r\n 1,5,3,3, 1,5,4,3, 1,5,5,3, 1,5,6,3, 1,5,7,3, 1,5,8,3, 1,5,9,3, 1,6,0,3, 1,6,1,3, \r\n 1,6,2,3, 1,6,3,3, 1,6,4,3, 1,6,5,3, 1,6,6,3, 1,6,7,3, 1,6,8,3, 1,6,9,3, 1,7,0,3, \r\n 1,7,1,3, 1,7,2,3, 1,7,3,3, 1,7,4,3, 1,7,5,3, 1,7,6,3, 1,7,7,3, 1,7,8,3, 1,7,9,3, \r\n 1,8,0,3, 1,8,1,3, 1,8,2,3, 1,8,3,3, 1,8,4,3, 1,8,5,3, 1,8,6,3, 1,8,7,3, 1,8,8,3, \r\n 1,8,9,3, 1,9,0,3, 1,9,1,3, 1,9,2,3, 1,9,3,3, 1,9,4,3, 1,9,5,3, 1,9,6,3, 1,9,7,3, \r\n 1,9,8,3, 1,9,9,3, 2,0,0,3, 2,0,1,3, 2,0,2,3, 2,0,3,3, 2,0,4,3, 2,0,5,3, 2,0,6,3, \r\n 2,0,7,3, 2,0,8,3, 2,0,9,3, 2,1,0,3, 2,1,1,3, 2,1,2,3, 2,1,3,3, 2,1,4,3, 2,1,5,3, \r\n 2,1,6,3, 2,1,7,3, 2,1,8,3, 2,1,9,3, 2,2,0,3, 2,2,1,3, 2,2,2,3, 2,2,3,3, 2,2,4,3, \r\n 2,2,5,3, 2,2,6,3, 2,2,7,3, 2,2,8,3, 2,2,9,3, 2,3,0,3, 2,3,1,3, 2,3,2,3, 2,3,3,3, \r\n 2,3,4,3, 2,3,5,3, 2,3,6,3, 2,3,7,3, 2,3,8,3, 2,3,9,3, 2,4,0,3, 2,4,1,3, 2,4,2,3, \r\n 2,4,3,3, 2,4,4,3, 2,4,5,3, 2,4,6,3, 2,4,7,3, 2,4,8,3, 2,4,9,3, 2,5,0,3, 2,5,1,3, \r\n 2,5,2,3, 2,5,3,3, 2,5,4,3, 2,5,5,3, 2,5,6,3, 2,5,7,3, 2,5,8,3, 2,5,9,3, 2,6,0,3, \r\n 2,6,1,3, 2,6,2,3, 2,6,3,3, 2,6,4,3, 2,6,5,3, 2,6,6,3, 2,6,7,3, 2,6,8,3, 2,6,9,3, \r\n 2,7,0,3, 2,7,1,3, 2,7,2,3, 2,7,3,3, 2,7,4,3, 2,7,5,3, 2,7,6,3, 2,7,7,3, 2,7,8,3, \r\n 2,7,9,3, 2,8,0,3, 2,8,1,3, 2,8,2,3, 2,8,3,3, 2,8,4,3, 2,8,5,3, 2,8,6,3, 2,8,7,3, \r\n 2,8,8,3, 2,8,9,3, 2,9,0,3, 2,9,1,3, 2,9,2,3, 2,9,3,3, 2,9,4,3, 2,9,5,3, 2,9,6,3, \r\n 2,9,7,3, 2,9,8,3, 2,9,9,3, 3,0,0,3, 3,0,1,3, 3,0,2,3, 3,0,3,3, 3,0,4,3, 3,0,5,3, \r\n 3,0,6,3, 3,0,7,3, 3,0,8,3, 3,0,9,3, 3,1,0,3, 3,1,1,3, 3,1,2,3, 3,1,3,3, 3,1,4,3, \r\n 3,1,5,3, 3,1,6,3, 3,1,7,3, 3,1,8,3, 3,1,9,3, 3,2,0,3, 3,2,1,3, 3,2,2,3, 3,2,3,3, \r\n 3,2,4,3, 3,2,5,3, 3,2,6,3, 3,2,7,3, 3,2,8,3, 3,2,9,3, 3,3,0,3, 3,3,1,3, 3,3,2,3, \r\n 3,3,3,3, 3,3,4,3, 3,3,5,3, 3,3,6,3, 3,3,7,3, 3,3,8,3, 3,3,9,3, 3,4,0,3, 3,4,1,3, \r\n 3,4,2,3, 3,4,3,3, 3,4,4,3, 3,4,5,3, 3,4,6,3, 3,4,7,3, 3,4,8,3, 3,4,9,3, 3,5,0,3, \r\n 3,5,1,3, 3,5,2,3, 3,5,3,3, 3,5,4,3, 3,5,5,3, 3,5,6,3, 3,5,7,3, 3,5,8,3, 3,5,9,3, \r\n 3,6,0,3, 3,6,1,3, 3,6,2,3, 3,6,3,3, 3,6,4,3, 3,6,5,3, 3,6,6,3, 3,6,7,3, 3,6,8,3, \r\n 3,6,9,3, 3,7,0,3, 3,7,1,3, 3,7,2,3, 3,7,3,3, 3,7,4,3, 3,7,5,3, 3,7,6,3, 3,7,7,3, \r\n 3,7,8,3, 3,7,9,3, 3,8,0,3, 3,8,1,3, 3,8,2,3, 3,8,3,3, 3,8,4,3, 3,8,5,3, 3,8,6,3, \r\n 3,8,7,3, 3,8,8,3, 3,8,9,3, 3,9,0,3, 3,9,1,3, 3,9,2,3, 3,9,3,3, 3,9,4,3, 3,9,5,3, \r\n 3,9,6,3, 3,9,7,3, 3,9,8,3, 3,9,9,3, 4,0,0,3, 4,0,1,3, 4,0,2,3, 4,0,3,3, 4,0,4,3, \r\n 4,0,5,3, 4,0,6,3, 4,0,7,3, 4,0,8,3, 4,0,9,3, 4,1,0,3, 4,1,1,3, 4,1,2,3, 4,1,3,3, \r\n 4,1,4,3, 4,1,5,3, 4,1,6,3, 4,1,7,3, 4,1,8,3, 4,1,9,3, 4,2,0,3, 4,2,1,3, 4,2,2,3, \r\n 4,2,3,3, 4,2,4,3, 4,2,5,3, 4,2,6,3, 4,2,7,3, 4,2,8,3, 4,2,9,3, 4,3,0,3, 4,3,1,3, \r\n 4,3,2,3, 4,3,3,3, 4,3,4,3, 4,3,5,3, 4,3,6,3, 4,3,7,3, 4,3,8,3, 4,3,9,3, 4,4,0,3, \r\n 4,4,1,3, 4,4,2,3, 4,4,3,3, 4,4,4,3, 4,4,5,3, 4,4,6,3, 4,4,7,3, 4,4,8,3, 4,4,9,3, \r\n 4,5,0,3, 4,5,1,3, 4,5,2,3, 4,5,3,3, 4,5,4,3, 4,5,5,3, 4,5,6,3, 4,5,7,3, 4,5,8,3, \r\n 4,5,9,3, 4,6,0,3, 4,6,1,3, 4,6,2,3, 4,6,3,3, 4,6,4,3, 4,6,5,3, 4,6,6,3, 4,6,7,3, \r\n 4,6,8,3, 4,6,9,3, 4,7,0,3, 4,7,1,3, 4,7,2,3, 4,7,3,3, 4,7,4,3, 4,7,5,3, 4,7,6,3, \r\n 4,7,7,3, 4,7,8,3, 4,7,9,3, 4,8,0,3, 4,8,1,3, 4,8,2,3, 4,8,3,3, 4,8,4,3, 4,8,5,3, \r\n 4,8,6,3, 4,8,7,3, 4,8,8,3, 4,8,9,3, 4,9,0,3, 4,9,1,3, 4,9,2,3, 4,9,3,3, 4,9,4,3, \r\n 4,9,5,3, 4,9,6,3, 4,9,7,3, 4,9,8,3, 4,9,9,3, 5,0,0,3, 5,0,1,3, 5,0,2,3, 5,0,3,3, \r\n 5,0,4,3, 5,0,5,3, 5,0,6,3, 5,0,7,3, 5,0,8,3, 5,0,9,3, 5,1,0,3, 5,1,1,3, 5,1,2,3, \r\n 5,1,3,3, 5,1,4,3, 5,1,5,3, 5,1,6,3, 5,1,7,3, 5,1,8,3, 5,1,9,3, 5,2,0,3, 5,2,1,3, \r\n 5,2,2,3, 5,2,3,3, 5,2,4,3, 5,2,5,3, 5,2,6,3, 5,2,7,3, 5,2,8,3, 5,2,9,3, 5,3,0,3, \r\n 5,3,1,3, 5,3,2,3, 5,3,3,3, 5,3,4,3, 5,3,5,3, 5,3,6,3, 5,3,7,3, 5,3,8,3, 5,3,9,3, \r\n 5,4,0,3, 5,4,1,3, 5,4,2,3, 5,4,3,3, 5,4,4,3, 5,4,5,3, 5,4,6,3, 5,4,7,3, 5,4,8,3, \r\n 5,4,9,3, 5,5,0,3, 5,5,1,3, 5,5,2,3, 5,5,3,3, 5,5,4,3, 5,5,5,3, 5,5,6,3, 5,5,7,3, \r\n 5,5,8,3, 5,5,9,3, 5,6,0,3, 5,6,1,3, 5,6,2,3, 5,6,3,3, 5,6,4,3, 5,6,5,3, 5,6,6,3, \r\n 5,6,7,3, 5,6,8,3, 5,6,9,3, 5,7,0,3, 5,7,1,3, 5,7,2,3, 5,7,3,3, 5,7,4,3, 5,7,5,3, \r\n 5,7,6,3, 5,7,7,3, 5,7,8,3, 5,7,9,3, 5,8,0,3, 5,8,1,3, 5,8,2,3, 5,8,3,3, 5,8,4,3, \r\n 5,8,5,3, 5,8,6,3, 5,8,7,3, 5,8,8,3, 5,8,9,3, 5,9,0,3, 5,9,1,3, 5,9,2,3, 5,9,3,3, \r\n 5,9,4,3, 5,9,5,3, 5,9,6,3, 5,9,7,3, 5,9,8,3, 5,9,9,3, 6,0,0,3, 6,0,1,3, 6,0,2,3, \r\n 6,0,3,3, 6,0,4,3, 6,0,5,3, 6,0,6,3, 6,0,7,3, 6,0,8,3, 6,0,9,3, 6,1,0,3, 6,1,1,3, \r\n 6,1,2,3, 6,1,3,3, 6,1,4,3, 6,1,5,3, 6,1,6,3, 6,1,7,3, 6,1,8,3, 6,1,9,3, 6,2,0,3, \r\n 6,2,1,3, 6,2,2,3, 6,2,3,3, 6,2,4,3, 6,2,5,3, 6,2,6,3, 6,2,7,3, 6,2,8,3, 6,2,9,3, \r\n 6,3,0,3, 6,3,1,3, 6,3,2,3, 6,3,3,3, 6,3,4,3, 6,3,5,3, 6,3,6,3, 6,3,7,3, 6,3,8,3, \r\n 6,3,9,3, 6,4,0,3, 6,4,1,3, 6,4,2,3, 6,4,3,3, 6,4,4,3, 6,4,5,3, 6,4,6,3, 6,4,7,3, \r\n 6,4,8,3, 6,4,9,3, 6,5,0,3, 6,5,1,3, 6,5,2,3, 6,5,3,3, 6,5,4,3, 6,5,5,3, 6,5,6,3, \r\n 6,5,7,3, 6,5,8,3, 6,5,9,3, 6,6,0,3, 6,6,1,3, 6,6,2,3, 6,6,3,3, 6,6,4,3, 6,6,5,3, \r\n 6,6,6,3, 6,6,7,3, 6,6,8,3, 6,6,9,3, 6,7,0,3, 6,7,1,3, 6,7,2,3, 6,7,3,3, 6,7,4,3, \r\n 6,7,5,3, 6,7,6,3, 6,7,7,3, 6,7,8,3, 6,7,9,3, 6,8,0,3, 6,8,1,3, 6,8,2,3, 6,8,3,3, \r\n 6,8,4,3, 6,8,5,3, 6,8,6,3, 6,8,7,3, 6,8,8,3, 6,8,9,3, 6,9,0,3, 6,9,1,3, 6,9,2,3, \r\n 6,9,3,3, 6,9,4,3, 6,9,5,3, 6,9,6,3, 6,9,7,3, 6,9,8,3, 6,9,9,3, 7,0,0,3, 7,0,1,3, \r\n 7,0,2,3, 7,0,3,3, 7,0,4,3, 7,0,5,3, 7,0,6,3, 7,0,7,3, 7,0,8,3, 7,0,9,3, 7,1,0,3, \r\n 7,1,1,3, 7,1,2,3, 7,1,3,3, 7,1,4,3, 7,1,5,3, 7,1,6,3, 7,1,7,3, 7,1,8,3, 7,1,9,3, \r\n 7,2,0,3, 7,2,1,3, 7,2,2,3, 7,2,3,3, 7,2,4,3, 7,2,5,3, 7,2,6,3, 7,2,7,3, 7,2,8,3, \r\n 7,2,9,3, 7,3,0,3, 7,3,1,3, 7,3,2,3, 7,3,3,3, 7,3,4,3, 7,3,5,3, 7,3,6,3, 7,3,7,3, \r\n 7,3,8,3, 7,3,9,3, 7,4,0,3, 7,4,1,3, 7,4,2,3, 7,4,3,3, 7,4,4,3, 7,4,5,3, 7,4,6,3, \r\n 7,4,7,3, 7,4,8,3, 7,4,9,3, 7,5,0,3, 7,5,1,3, 7,5,2,3, 7,5,3,3, 7,5,4,3, 7,5,5,3, \r\n 7,5,6,3, 7,5,7,3, 7,5,8,3, 7,5,9,3, 7,6,0,3, 7,6,1,3, 7,6,2,3, 7,6,3,3, 7,6,4,3, \r\n 7,6,5,3, 7,6,6,3, 7,6,7,3, 7,6,8,3, 7,6,9,3, 7,7,0,3, 7,7,1,3, 7,7,2,3, 7,7,3,3, \r\n 7,7,4,3, 7,7,5,3, 7,7,6,3, 7,7,7,3, 7,7,8,3, 7,7,9,3, 7,8,0,3, 7,8,1,3, 7,8,2,3, \r\n 7,8,3,3, 7,8,4,3, 7,8,5,3, 7,8,6,3, 7,8,7,3, 7,8,8,3, 7,8,9,3, 7,9,0,3, 7,9,1,3, \r\n 7,9,2,3, 7,9,3,3, 7,9,4,3, 7,9,5,3, 7,9,6,3, 7,9,7,3, 7,9,8,3, 7,9,9,3, 8,0,0,3, \r\n 8,0,1,3, 8,0,2,3, 8,0,3,3, 8,0,4,3, 8,0,5,3, 8,0,6,3, 8,0,7,3, 8,0,8,3, 8,0,9,3, \r\n 8,1,0,3, 8,1,1,3, 8,1,2,3, 8,1,3,3, 8,1,4,3, 8,1,5,3, 8,1,6,3, 8,1,7,3, 8,1,8,3, \r\n 8,1,9,3, 8,2,0,3, 8,2,1,3, 8,2,2,3, 8,2,3,3, 8,2,4,3, 8,2,5,3, 8,2,6,3, 8,2,7,3, \r\n 8,2,8,3, 8,2,9,3, 8,3,0,3, 8,3,1,3, 8,3,2,3, 8,3,3,3, 8,3,4,3, 8,3,5,3, 8,3,6,3, \r\n 8,3,7,3, 8,3,8,3, 8,3,9,3, 8,4,0,3, 8,4,1,3, 8,4,2,3, 8,4,3,3, 8,4,4,3, 8,4,5,3, \r\n 8,4,6,3, 8,4,7,3, 8,4,8,3, 8,4,9,3, 8,5,0,3, 8,5,1,3, 8,5,2,3, 8,5,3,3, 8,5,4,3, \r\n 8,5,5,3, 8,5,6,3, 8,5,7,3, 8,5,8,3, 8,5,9,3, 8,6,0,3, 8,6,1,3, 8,6,2,3, 8,6,3,3, \r\n 8,6,4,3, 8,6,5,3, 8,6,6,3, 8,6,7,3, 8,6,8,3, 8,6,9,3, 8,7,0,3, 8,7,1,3, 8,7,2,3, \r\n 8,7,3,3, 8,7,4,3, 8,7,5,3, 8,7,6,3, 8,7,7,3, 8,7,8,3, 8,7,9,3, 8,8,0,3, 8,8,1,3, \r\n 8,8,2,3, 8,8,3,3, 8,8,4,3, 8,8,5,3, 8,8,6,3, 8,8,7,3, 8,8,8,3, 8,8,9,3, 8,9,0,3, \r\n 8,9,1,3, 8,9,2,3, 8,9,3,3, 8,9,4,3, 8,9,5,3, 8,9,6,3, 8,9,7,3, 8,9,8,3, 8,9,9,3, \r\n 9,0,0,3, 9,0,1,3, 9,0,2,3, 9,0,3,3, 9,0,4,3, 9,0,5,3, 9,0,6,3, 9,0,7,3, 9,0,8,3, \r\n 9,0,9,3, 9,1,0,3, 9,1,1,3, 9,1,2,3, 9,1,3,3, 9,1,4,3, 9,1,5,3, 9,1,6,3, 9,1,7,3, \r\n 9,1,8,3, 9,1,9,3, 9,2,0,3, 9,2,1,3, 9,2,2,3, 9,2,3,3, 9,2,4,3, 9,2,5,3, 9,2,6,3, \r\n 9,2,7,3, 9,2,8,3, 9,2,9,3, 9,3,0,3, 9,3,1,3, 9,3,2,3, 9,3,3,3, 9,3,4,3, 9,3,5,3, \r\n 9,3,6,3, 9,3,7,3, 9,3,8,3, 9,3,9,3, 9,4,0,3, 9,4,1,3, 9,4,2,3, 9,4,3,3, 9,4,4,3, \r\n 9,4,5,3, 9,4,6,3, 9,4,7,3, 9,4,8,3, 9,4,9,3, 9,5,0,3, 9,5,1,3, 9,5,2,3, 9,5,3,3, \r\n 9,5,4,3, 9,5,5,3, 9,5,6,3, 9,5,7,3, 9,5,8,3, 9,5,9,3, 9,6,0,3, 9,6,1,3, 9,6,2,3, \r\n 9,6,3,3, 9,6,4,3, 9,6,5,3, 9,6,6,3, 9,6,7,3, 9,6,8,3, 9,6,9,3, 9,7,0,3, 9,7,1,3, \r\n 9,7,2,3, 9,7,3,3, 9,7,4,3, 9,7,5,3, 9,7,6,3, 9,7,7,3, 9,7,8,3, 9,7,9,3, 9,8,0,3, \r\n 9,8,1,3, 9,8,2,3, 9,8,3,3, 9,8,4,3, 9,8,5,3, 9,8,6,3, 9,8,7,3, 9,8,8,3, 9,8,9,3, \r\n 9,9,0,3, 9,9,1,3, 9,9,2,3, 9,9,3,3, 9,9,4,3, 9,9,5,3, 9,9,6,3, 9,9,7,3, 9,9,8,3, \r\n 9,9,9,3};\r\n#endif\r\n \r\n"
  },
  {
    "path": "vendor/decNumber/decDouble.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* decDouble.c -- decDouble operations module                         */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2010.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is included in the package as decNumber.pdf.  This   */\r\n/* document is also available in HTML, together with specifications,  */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This module comprises decDouble operations (including conversions) */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#include \"decContext.h\"       // public includes\r\n#include \"decDouble.h\"        // ..\r\n\r\n/* Constant mappings for shared code */\r\n#define DECPMAX     DECDOUBLE_Pmax\r\n#define DECEMIN     DECDOUBLE_Emin\r\n#define DECEMAX     DECDOUBLE_Emax\r\n#define DECEMAXD    DECDOUBLE_EmaxD\r\n#define DECBYTES    DECDOUBLE_Bytes\r\n#define DECSTRING   DECDOUBLE_String\r\n#define DECECONL    DECDOUBLE_EconL\r\n#define DECBIAS     DECDOUBLE_Bias\r\n#define DECLETS     DECDOUBLE_Declets\r\n#define DECQTINY    (-DECDOUBLE_Bias)\r\n// parameters of next-wider format\r\n#define DECWBYTES   DECQUAD_Bytes\r\n#define DECWPMAX    DECQUAD_Pmax\r\n#define DECWECONL   DECQUAD_EconL\r\n#define DECWBIAS    DECQUAD_Bias\r\n\r\n/* Type and function mappings for shared code */\r\n#define decFloat                   decDouble      // Type name\r\n#define decFloatWider              decQuad        // Type name\r\n\r\n// Utilities and conversions (binary results, extractors, etc.)\r\n#define decFloatFromBCD            decDoubleFromBCD\r\n#define decFloatFromInt32          decDoubleFromInt32\r\n#define decFloatFromPacked         decDoubleFromPacked\r\n#define decFloatFromPackedChecked  decDoubleFromPackedChecked\r\n#define decFloatFromString         decDoubleFromString\r\n#define decFloatFromUInt32         decDoubleFromUInt32\r\n#define decFloatFromWider          decDoubleFromWider\r\n#define decFloatGetCoefficient     decDoubleGetCoefficient\r\n#define decFloatGetExponent        decDoubleGetExponent\r\n#define decFloatSetCoefficient     decDoubleSetCoefficient\r\n#define decFloatSetExponent        decDoubleSetExponent\r\n#define decFloatShow               decDoubleShow\r\n#define decFloatToBCD              decDoubleToBCD\r\n#define decFloatToEngString        decDoubleToEngString\r\n#define decFloatToInt32            decDoubleToInt32\r\n#define decFloatToInt32Exact       decDoubleToInt32Exact\r\n#define decFloatToPacked           decDoubleToPacked\r\n#define decFloatToString           decDoubleToString\r\n#define decFloatToUInt32           decDoubleToUInt32\r\n#define decFloatToUInt32Exact      decDoubleToUInt32Exact\r\n#define decFloatToWider            decDoubleToWider\r\n#define decFloatZero               decDoubleZero\r\n\r\n// Computational (result is a decFloat)\r\n#define decFloatAbs                decDoubleAbs\r\n#define decFloatAdd                decDoubleAdd\r\n#define decFloatAnd                decDoubleAnd\r\n#define decFloatDivide             decDoubleDivide\r\n#define decFloatDivideInteger      decDoubleDivideInteger\r\n#define decFloatFMA                decDoubleFMA\r\n#define decFloatInvert             decDoubleInvert\r\n#define decFloatLogB               decDoubleLogB\r\n#define decFloatMax                decDoubleMax\r\n#define decFloatMaxMag             decDoubleMaxMag\r\n#define decFloatMin                decDoubleMin\r\n#define decFloatMinMag             decDoubleMinMag\r\n#define decFloatMinus              decDoubleMinus\r\n#define decFloatMultiply           decDoubleMultiply\r\n#define decFloatNextMinus          decDoubleNextMinus\r\n#define decFloatNextPlus           decDoubleNextPlus\r\n#define decFloatNextToward         decDoubleNextToward\r\n#define decFloatOr                 decDoubleOr\r\n#define decFloatPlus               decDoublePlus\r\n#define decFloatQuantize           decDoubleQuantize\r\n#define decFloatReduce             decDoubleReduce\r\n#define decFloatRemainder          decDoubleRemainder\r\n#define decFloatRemainderNear      decDoubleRemainderNear\r\n#define decFloatRotate             decDoubleRotate\r\n#define decFloatScaleB             decDoubleScaleB\r\n#define decFloatShift              decDoubleShift\r\n#define decFloatSubtract           decDoubleSubtract\r\n#define decFloatToIntegralValue    decDoubleToIntegralValue\r\n#define decFloatToIntegralExact    decDoubleToIntegralExact\r\n#define decFloatXor                decDoubleXor\r\n\r\n// Comparisons\r\n#define decFloatCompare            decDoubleCompare\r\n#define decFloatCompareSignal      decDoubleCompareSignal\r\n#define decFloatCompareTotal       decDoubleCompareTotal\r\n#define decFloatCompareTotalMag    decDoubleCompareTotalMag\r\n\r\n// Copies\r\n#define decFloatCanonical          decDoubleCanonical\r\n#define decFloatCopy               decDoubleCopy\r\n#define decFloatCopyAbs            decDoubleCopyAbs\r\n#define decFloatCopyNegate         decDoubleCopyNegate\r\n#define decFloatCopySign           decDoubleCopySign\r\n\r\n// Non-computational\r\n#define decFloatClass              decDoubleClass\r\n#define decFloatClassString        decDoubleClassString\r\n#define decFloatDigits             decDoubleDigits\r\n#define decFloatIsCanonical        decDoubleIsCanonical\r\n#define decFloatIsFinite           decDoubleIsFinite\r\n#define decFloatIsInfinite         decDoubleIsInfinite\r\n#define decFloatIsInteger          decDoubleIsInteger\r\n#define decFloatIsLogical          decDoubleIsLogical\r\n#define decFloatIsNaN              decDoubleIsNaN\r\n#define decFloatIsNegative         decDoubleIsNegative\r\n#define decFloatIsNormal           decDoubleIsNormal\r\n#define decFloatIsPositive         decDoubleIsPositive\r\n#define decFloatIsSignaling        decDoubleIsSignaling\r\n#define decFloatIsSignalling       decDoubleIsSignalling\r\n#define decFloatIsSigned           decDoubleIsSigned\r\n#define decFloatIsSubnormal        decDoubleIsSubnormal\r\n#define decFloatIsZero             decDoubleIsZero\r\n#define decFloatRadix              decDoubleRadix\r\n#define decFloatSameQuantum        decDoubleSameQuantum\r\n#define decFloatVersion            decDoubleVersion\r\n\r\n#include \"decNumberLocal.h\"   // local includes (need DECPMAX)\r\n#include \"decCommon.c\"        // non-arithmetic decFloat routines\r\n#include \"decBasic.c\"         // basic formats routines\r\n\r\n"
  },
  {
    "path": "vendor/decNumber/decDouble.h",
    "content": "/* ------------------------------------------------------------------ */\r\n/* decDouble.h -- Decimal 64-bit format module header                 */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2010.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is included in the package as decNumber.pdf.  This   */\r\n/* document is also available in HTML, together with specifications,  */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#if !defined(DECDOUBLE)\r\n  #define DECDOUBLE\r\n\r\n  #define DECDOUBLENAME       \"decimalDouble\"         /* Short name   */\r\n  #define DECDOUBLETITLE      \"Decimal 64-bit datum\"  /* Verbose name */\r\n  #define DECDOUBLEAUTHOR     \"Mike Cowlishaw\"        /* Who to blame */\r\n\r\n  /* parameters for decDoubles */\r\n  #define DECDOUBLE_Bytes   8      /* length                          */\r\n  #define DECDOUBLE_Pmax    16     /* maximum precision (digits)      */\r\n  #define DECDOUBLE_Emin   -383    /* minimum adjusted exponent       */\r\n  #define DECDOUBLE_Emax    384    /* maximum adjusted exponent       */\r\n  #define DECDOUBLE_EmaxD   3      /* maximum exponent digits         */\r\n  #define DECDOUBLE_Bias    398    /* bias for the exponent           */\r\n  #define DECDOUBLE_String  25     /* maximum string length, +1       */\r\n  #define DECDOUBLE_EconL   8      /* exponent continuation length    */\r\n  #define DECDOUBLE_Declets 5      /* count of declets                */\r\n  /* highest biased exponent (Elimit-1) */\r\n  #define DECDOUBLE_Ehigh (DECDOUBLE_Emax + DECDOUBLE_Bias - (DECDOUBLE_Pmax-1))\r\n\r\n  /* Required includes                                                */\r\n  #include \"decContext.h\"\r\n  #include \"decQuad.h\"\r\n\r\n  /* The decDouble decimal 64-bit type, accessible by all sizes */\r\n  typedef union {\r\n    uint8_t   bytes[DECDOUBLE_Bytes];   /* fields: 1, 5, 8, 50 bits */\r\n    uint16_t shorts[DECDOUBLE_Bytes/2];\r\n    uint32_t  words[DECDOUBLE_Bytes/4];\r\n    #if DECUSE64\r\n    uint64_t  longs[DECDOUBLE_Bytes/8];\r\n    #endif\r\n    } decDouble;\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* Routines -- implemented as decFloat routines in common files     */\r\n  /* ---------------------------------------------------------------- */\r\n\r\n  /* Utilities and conversions, extractors, etc.) */\r\n  extern decDouble * decDoubleFromBCD(decDouble *, int32_t, const uint8_t *, int32_t);\r\n  extern decDouble * decDoubleFromInt32(decDouble *, int32_t);\r\n  extern decDouble * decDoubleFromPacked(decDouble *, int32_t, const uint8_t *);\r\n  extern decDouble * decDoubleFromPackedChecked(decDouble *, int32_t, const uint8_t *);\r\n  extern decDouble * decDoubleFromString(decDouble *, const char *, decContext *);\r\n  extern decDouble * decDoubleFromUInt32(decDouble *, uint32_t);\r\n  extern decDouble * decDoubleFromWider(decDouble *, const decQuad *, decContext *);\r\n  extern int32_t     decDoubleGetCoefficient(const decDouble *, uint8_t *);\r\n  extern int32_t     decDoubleGetExponent(const decDouble *);\r\n  extern decDouble * decDoubleSetCoefficient(decDouble *, const uint8_t *, int32_t);\r\n  extern decDouble * decDoubleSetExponent(decDouble *, decContext *, int32_t);\r\n  extern void        decDoubleShow(const decDouble *, const char *);\r\n  extern int32_t     decDoubleToBCD(const decDouble *, int32_t *, uint8_t *);\r\n  extern char      * decDoubleToEngString(const decDouble *, char *);\r\n  extern int32_t     decDoubleToInt32(const decDouble *, decContext *, enum rounding);\r\n  extern int32_t     decDoubleToInt32Exact(const decDouble *, decContext *, enum rounding);\r\n  extern int32_t     decDoubleToPacked(const decDouble *, int32_t *, uint8_t *);\r\n  extern char      * decDoubleToString(const decDouble *, char *);\r\n  extern uint32_t    decDoubleToUInt32(const decDouble *, decContext *, enum rounding);\r\n  extern uint32_t    decDoubleToUInt32Exact(const decDouble *, decContext *, enum rounding);\r\n  extern decQuad   * decDoubleToWider(const decDouble *, decQuad *);\r\n  extern decDouble * decDoubleZero(decDouble *);\r\n\r\n  /* Computational (result is a decDouble) */\r\n  extern decDouble * decDoubleAbs(decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleAdd(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleAnd(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleDivide(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleDivideInteger(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleFMA(decDouble *, const decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleInvert(decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleLogB(decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleMax(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleMaxMag(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleMin(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleMinMag(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleMinus(decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleMultiply(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleNextMinus(decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleNextPlus(decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleNextToward(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleOr(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoublePlus(decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleQuantize(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleReduce(decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleRemainder(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleRemainderNear(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleRotate(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleScaleB(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleShift(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleSubtract(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleToIntegralValue(decDouble *, const decDouble *, decContext *, enum rounding);\r\n  extern decDouble * decDoubleToIntegralExact(decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleXor(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n\r\n  /* Comparisons */\r\n  extern decDouble * decDoubleCompare(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleCompareSignal(decDouble *, const decDouble *, const decDouble *, decContext *);\r\n  extern decDouble * decDoubleCompareTotal(decDouble *, const decDouble *, const decDouble *);\r\n  extern decDouble * decDoubleCompareTotalMag(decDouble *, const decDouble *, const decDouble *);\r\n\r\n  /* Copies */\r\n  extern decDouble * decDoubleCanonical(decDouble *, const decDouble *);\r\n  extern decDouble * decDoubleCopy(decDouble *, const decDouble *);\r\n  extern decDouble * decDoubleCopyAbs(decDouble *, const decDouble *);\r\n  extern decDouble * decDoubleCopyNegate(decDouble *, const decDouble *);\r\n  extern decDouble * decDoubleCopySign(decDouble *, const decDouble *, const decDouble *);\r\n\r\n  /* Non-computational */\r\n  extern enum decClass decDoubleClass(const decDouble *);\r\n  extern const char *  decDoubleClassString(const decDouble *);\r\n  extern uint32_t      decDoubleDigits(const decDouble *);\r\n  extern uint32_t      decDoubleIsCanonical(const decDouble *);\r\n  extern uint32_t      decDoubleIsFinite(const decDouble *);\r\n  extern uint32_t      decDoubleIsInfinite(const decDouble *);\r\n  extern uint32_t      decDoubleIsInteger(const decDouble *);\r\n  extern uint32_t      decDoubleIsLogical(const decDouble *);\r\n  extern uint32_t      decDoubleIsNaN(const decDouble *);\r\n  extern uint32_t      decDoubleIsNegative(const decDouble *);\r\n  extern uint32_t      decDoubleIsNormal(const decDouble *);\r\n  extern uint32_t      decDoubleIsPositive(const decDouble *);\r\n  extern uint32_t      decDoubleIsSignaling(const decDouble *);\r\n  extern uint32_t      decDoubleIsSignalling(const decDouble *);\r\n  extern uint32_t      decDoubleIsSigned(const decDouble *);\r\n  extern uint32_t      decDoubleIsSubnormal(const decDouble *);\r\n  extern uint32_t      decDoubleIsZero(const decDouble *);\r\n  extern uint32_t      decDoubleRadix(const decDouble *);\r\n  extern uint32_t      decDoubleSameQuantum(const decDouble *, const decDouble *);\r\n  extern const char *  decDoubleVersion(void);\r\n\r\n  /* decNumber conversions; these are implemented as macros so as not  */\r\n  /* to force a dependency on decimal64 and decNumber in decDouble.    */\r\n  /* decDoubleFromNumber returns a decimal64 * to avoid warnings.      */\r\n  #define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn)\r\n  #define decDoubleFromNumber(dq, dn, set) decimal64FromNumber((decimal64 *)(dq), dn, set)\r\n\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decNumber.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Number arithmetic module                                   */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2009.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This module comprises the routines for arbitrary-precision General */\r\n/* Decimal Arithmetic as defined in the specification which may be    */\r\n/* found on the General Decimal Arithmetic pages.  It implements both */\r\n/* the full ('extended') arithmetic and the simpler ('subset')        */\r\n/* arithmetic.                                                        */\r\n/*                                                                    */\r\n/* Usage notes:                                                       */\r\n/*                                                                    */\r\n/* 1. This code is ANSI C89 except:                                   */\r\n/*                                                                    */\r\n/*    a) C99 line comments (double forward slash) are used.  (Most C  */\r\n/*       compilers accept these.  If yours does not, a simple script  */\r\n/*       can be used to convert them to ANSI C comments.)             */\r\n/*                                                                    */\r\n/*    b) Types from C99 stdint.h are used.  If you do not have this   */\r\n/*       header file, see the User's Guide section of the decNumber   */\r\n/*       documentation; this lists the necessary definitions.         */\r\n/*                                                                    */\r\n/*    c) If DECDPUN>4 or DECUSE64=1, the C99 64-bit int64_t and       */\r\n/*       uint64_t types may be used.  To avoid these, set DECUSE64=0  */\r\n/*       and DECDPUN<=4 (see documentation).                          */\r\n/*                                                                    */\r\n/*    The code also conforms to C99 restrictions; in particular,      */\r\n/*    strict aliasing rules are observed.                             */\r\n/*                                                                    */\r\n/* 2. The decNumber format which this library uses is optimized for   */\r\n/*    efficient processing of relatively short numbers; in particular */\r\n/*    it allows the use of fixed sized structures and minimizes copy  */\r\n/*    and move operations.  It does, however, support arbitrary       */\r\n/*    precision (up to 999,999,999 digits) and arbitrary exponent     */\r\n/*    range (Emax in the range 0 through 999,999,999 and Emin in the  */\r\n/*    range -999,999,999 through 0).  Mathematical functions (for     */\r\n/*    example decNumberExp) as identified below are restricted more   */\r\n/*    tightly: digits, emax, and -emin in the context must be <=      */\r\n/*    DEC_MAX_MATH (999999), and their operand(s) must be within      */\r\n/*    these bounds.                                                   */\r\n/*                                                                    */\r\n/* 3. Logical functions are further restricted; their operands must   */\r\n/*    be finite, positive, have an exponent of zero, and all digits   */\r\n/*    must be either 0 or 1.  The result will only contain digits     */\r\n/*    which are 0 or 1 (and will have exponent=0 and a sign of 0).    */\r\n/*                                                                    */\r\n/* 4. Operands to operator functions are never modified unless they   */\r\n/*    are also specified to be the result number (which is always     */\r\n/*    permitted).  Other than that case, operands must not overlap.   */\r\n/*                                                                    */\r\n/* 5. Error handling: the type of the error is ORed into the status   */\r\n/*    flags in the current context (decContext structure).  The       */\r\n/*    SIGFPE signal is then raised if the corresponding trap-enabler  */\r\n/*    flag in the decContext is set (is 1).                           */\r\n/*                                                                    */\r\n/*    It is the responsibility of the caller to clear the status      */\r\n/*    flags as required.                                              */\r\n/*                                                                    */\r\n/*    The result of any routine which returns a number will always    */\r\n/*    be a valid number (which may be a special value, such as an     */\r\n/*    Infinity or NaN).                                               */\r\n/*                                                                    */\r\n/* 6. The decNumber format is not an exchangeable concrete            */\r\n/*    representation as it comprises fields which may be machine-     */\r\n/*    dependent (packed or unpacked, or special length, for example). */\r\n/*    Canonical conversions to and from strings are provided; other   */\r\n/*    conversions are available in separate modules.                  */\r\n/*                                                                    */\r\n/* 7. Normally, input operands are assumed to be valid.  Set DECCHECK */\r\n/*    to 1 for extended operand checking (including NULL operands).   */\r\n/*    Results are undefined if a badly-formed structure (or a NULL    */\r\n/*    pointer to a structure) is provided, though with DECCHECK       */\r\n/*    enabled the operator routines are protected against exceptions. */\r\n/*    (Except if the result pointer is NULL, which is unrecoverable.) */\r\n/*                                                                    */\r\n/*    However, the routines will never cause exceptions if they are   */\r\n/*    given well-formed operands, even if the value of the operands   */\r\n/*    is inappropriate for the operation and DECCHECK is not set.     */\r\n/*    (Except for SIGFPE, as and where documented.)                   */\r\n/*                                                                    */\r\n/* 8. Subset arithmetic is available only if DECSUBSET is set to 1.   */\r\n/* ------------------------------------------------------------------ */\r\n/* Implementation notes for maintenance of this module:               */\r\n/*                                                                    */\r\n/* 1. Storage leak protection:  Routines which use malloc are not     */\r\n/*    permitted to use return for fastpath or error exits (i.e.,      */\r\n/*    they follow strict structured programming conventions).         */\r\n/*    Instead they have a do{}while(0); construct surrounding the     */\r\n/*    code which is protected -- break may be used to exit this.      */\r\n/*    Other routines can safely use the return statement inline.      */\r\n/*                                                                    */\r\n/*    Storage leak accounting can be enabled using DECALLOC.          */\r\n/*                                                                    */\r\n/* 2. All loops use the for(;;) construct.  Any do construct does     */\r\n/*    not loop; it is for allocation protection as just described.    */\r\n/*                                                                    */\r\n/* 3. Setting status in the context must always be the very last      */\r\n/*    action in a routine, as non-0 status may raise a trap and hence */\r\n/*    the call to set status may not return (if the handler uses long */\r\n/*    jump).  Therefore all cleanup must be done first.  In general,  */\r\n/*    to achieve this status is accumulated and is only applied just  */\r\n/*    before return by calling decContextSetStatus (via decStatus).   */\r\n/*                                                                    */\r\n/*    Routines which allocate storage cannot, in general, use the     */\r\n/*    'top level' routines which could cause a non-returning          */\r\n/*    transfer of control.  The decXxxxOp routines are safe (do not   */\r\n/*    call decStatus even if traps are set in the context) and should */\r\n/*    be used instead (they are also a little faster).                */\r\n/*                                                                    */\r\n/* 4. Exponent checking is minimized by allowing the exponent to      */\r\n/*    grow outside its limits during calculations, provided that      */\r\n/*    the decFinalize function is called later.  Multiplication and   */\r\n/*    division, and intermediate calculations in exponentiation,      */\r\n/*    require more careful checks because of the risk of 31-bit       */\r\n/*    overflow (the most negative valid exponent is -1999999997, for  */\r\n/*    a 999999999-digit number with adjusted exponent of -999999999). */\r\n/*                                                                    */\r\n/* 5. Rounding is deferred until finalization of results, with any    */\r\n/*    'off to the right' data being represented as a single digit     */\r\n/*    residue (in the range -1 through 9).  This avoids any double-   */\r\n/*    rounding when more than one shortening takes place (for         */\r\n/*    example, when a result is subnormal).                           */\r\n/*                                                                    */\r\n/* 6. The digits count is allowed to rise to a multiple of DECDPUN    */\r\n/*    during many operations, so whole Units are handled and exact    */\r\n/*    accounting of digits is not needed.  The correct digits value   */\r\n/*    is found by decGetDigits, which accounts for leading zeros.     */\r\n/*    This must be called before any rounding if the number of digits */\r\n/*    is not known exactly.                                           */\r\n/*                                                                    */\r\n/* 7. The multiply-by-reciprocal 'trick' is used for partitioning     */\r\n/*    numbers up to four digits, using appropriate constants.  This   */\r\n/*    is not useful for longer numbers because overflow of 32 bits    */\r\n/*    would lead to 4 multiplies, which is almost as expensive as     */\r\n/*    a divide (unless a floating-point or 64-bit multiply is         */\r\n/*    assumed to be available).                                       */\r\n/*                                                                    */\r\n/* 8. Unusual abbreviations that may be used in the commentary:       */\r\n/*      lhs -- left hand side (operand, of an operation)              */\r\n/*      lsd -- least significant digit (of coefficient)               */\r\n/*      lsu -- least significant Unit (of coefficient)                */\r\n/*      msd -- most significant digit (of coefficient)                */\r\n/*      msi -- most significant item (in an array)                    */\r\n/*      msu -- most significant Unit (of coefficient)                 */\r\n/*      rhs -- right hand side (operand, of an operation)             */\r\n/*      +ve -- positive                                               */\r\n/*      -ve -- negative                                               */\r\n/*      **  -- raise to the power                                     */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#include <stdlib.h>                // for malloc, free, etc.\r\n#include <stdio.h>                 // for printf [if needed]\r\n#include <string.h>                // for strcpy\r\n#include <ctype.h>                 // for lower\r\n#include \"decNumber.h\"             // base number library\r\n#include \"decNumberLocal.h\"        // decNumber local types, etc.\r\n\r\n/* Constants */\r\n// Public lookup table used by the D2U macro\r\nconst uByte d2utable[DECMAXD2U+1]=D2UTABLE;\r\n\r\n#define DECVERB     1              // set to 1 for verbose DECCHECK\r\n#define powers      DECPOWERS      // old internal name\r\n\r\n// Local constants\r\n#define DIVIDE      0x80           // Divide operators\r\n#define REMAINDER   0x40           // ..\r\n#define DIVIDEINT   0x20           // ..\r\n#define REMNEAR     0x10           // ..\r\n#define COMPARE     0x01           // Compare operators\r\n#define COMPMAX     0x02           // ..\r\n#define COMPMIN     0x03           // ..\r\n#define COMPTOTAL   0x04           // ..\r\n#define COMPNAN     0x05           // .. [NaN processing]\r\n#define COMPSIG     0x06           // .. [signaling COMPARE]\r\n#define COMPMAXMAG  0x07           // ..\r\n#define COMPMINMAG  0x08           // ..\r\n\r\n#define DEC_sNaN     0x40000000    // local status: sNaN signal\r\n#define BADINT  (Int)0x80000000    // most-negative Int; error indicator\r\n// Next two indicate an integer >= 10**6, and its parity (bottom bit)\r\n#define BIGEVEN (Int)0x80000002\r\n#define BIGODD  (Int)0x80000003\r\n\r\nstatic Unit uarrone[1]={1};   // Unit array of 1, used for incrementing\r\n\r\n/* Granularity-dependent code */\r\n#if DECDPUN<=4\r\n  #define eInt  Int           // extended integer\r\n  #define ueInt uInt          // unsigned extended integer\r\n  // Constant multipliers for divide-by-power-of five using reciprocal\r\n  // multiply, after removing powers of 2 by shifting, and final shift\r\n  // of 17 [we only need up to **4]\r\n  static const uInt multies[]={131073, 26215, 5243, 1049, 210};\r\n  // QUOT10 -- macro to return the quotient of unit u divided by 10**n\r\n  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)\r\n#else\r\n  // For DECDPUN>4 non-ANSI-89 64-bit types are needed.\r\n  #if !DECUSE64\r\n    #error decNumber.c: DECUSE64 must be 1 when DECDPUN>4\r\n  #endif\r\n  #define eInt  Long          // extended integer\r\n  #define ueInt uLong         // unsigned extended integer\r\n#endif\r\n\r\n/* Local routines */\r\nstatic decNumber * decAddOp(decNumber *, const decNumber *, const decNumber *,\r\n                              decContext *, uByte, uInt *);\r\nstatic Flag        decBiStr(const char *, const char *, const char *);\r\nstatic uInt        decCheckMath(const decNumber *, decContext *, uInt *);\r\nstatic void        decApplyRound(decNumber *, decContext *, Int, uInt *);\r\nstatic Int         decCompare(const decNumber *lhs, const decNumber *rhs, Flag);\r\nstatic decNumber * decCompareOp(decNumber *, const decNumber *,\r\n                              const decNumber *, decContext *,\r\n                              Flag, uInt *);\r\nstatic void        decCopyFit(decNumber *, const decNumber *, decContext *,\r\n                              Int *, uInt *);\r\nstatic decNumber * decDecap(decNumber *, Int);\r\nstatic decNumber * decDivideOp(decNumber *, const decNumber *,\r\n                              const decNumber *, decContext *, Flag, uInt *);\r\nstatic decNumber * decExpOp(decNumber *, const decNumber *,\r\n                              decContext *, uInt *);\r\nstatic void        decFinalize(decNumber *, decContext *, Int *, uInt *);\r\nstatic Int         decGetDigits(Unit *, Int);\r\nstatic Int         decGetInt(const decNumber *);\r\nstatic decNumber * decLnOp(decNumber *, const decNumber *,\r\n                              decContext *, uInt *);\r\nstatic decNumber * decMultiplyOp(decNumber *, const decNumber *,\r\n                              const decNumber *, decContext *,\r\n                              uInt *);\r\nstatic decNumber * decNaNs(decNumber *, const decNumber *,\r\n                              const decNumber *, decContext *, uInt *);\r\nstatic decNumber * decQuantizeOp(decNumber *, const decNumber *,\r\n                              const decNumber *, decContext *, Flag,\r\n                              uInt *);\r\nstatic void        decReverse(Unit *, Unit *);\r\nstatic void        decSetCoeff(decNumber *, decContext *, const Unit *,\r\n                              Int, Int *, uInt *);\r\nstatic void        decSetMaxValue(decNumber *, decContext *);\r\nstatic void        decSetOverflow(decNumber *, decContext *, uInt *);\r\nstatic void        decSetSubnormal(decNumber *, decContext *, Int *, uInt *);\r\nstatic Int         decShiftToLeast(Unit *, Int, Int);\r\nstatic Int         decShiftToMost(Unit *, Int, Int);\r\nstatic void        decStatus(decNumber *, uInt, decContext *);\r\nstatic void        decToString(const decNumber *, char[], Flag);\r\nstatic decNumber * decTrim(decNumber *, decContext *, Flag, Flag, Int *);\r\nstatic Int         decUnitAddSub(const Unit *, Int, const Unit *, Int, Int,\r\n                              Unit *, Int);\r\nstatic Int         decUnitCompare(const Unit *, Int, const Unit *, Int, Int);\r\n\r\n#if !DECSUBSET\r\n/* decFinish == decFinalize when no subset arithmetic needed */\r\n#define decFinish(a,b,c,d) decFinalize(a,b,c,d)\r\n#else\r\nstatic void        decFinish(decNumber *, decContext *, Int *, uInt *);\r\nstatic decNumber * decRoundOperand(const decNumber *, decContext *, uInt *);\r\n#endif\r\n\r\n/* Local macros */\r\n// masked special-values bits\r\n#define SPECIALARG  (rhs->bits & DECSPECIAL)\r\n#define SPECIALARGS ((lhs->bits | rhs->bits) & DECSPECIAL)\r\n\r\n/* Diagnostic macros, etc. */\r\n#if DECALLOC\r\n// Handle malloc/free accounting.  If enabled, our accountable routines\r\n// are used; otherwise the code just goes straight to the system malloc\r\n// and free routines.\r\n#define malloc(a) decMalloc(a)\r\n#define free(a) decFree(a)\r\n#define DECFENCE 0x5a              // corruption detector\r\n// 'Our' malloc and free:\r\nstatic void *decMalloc(size_t);\r\nstatic void  decFree(void *);\r\nuInt decAllocBytes=0;              // count of bytes allocated\r\n// Note that DECALLOC code only checks for storage buffer overflow.\r\n// To check for memory leaks, the decAllocBytes variable must be\r\n// checked to be 0 at appropriate times (e.g., after the test\r\n// harness completes a set of tests).  This checking may be unreliable\r\n// if the testing is done in a multi-thread environment.\r\n#endif\r\n\r\n#if DECCHECK\r\n// Optional checking routines.  Enabling these means that decNumber\r\n// and decContext operands to operator routines are checked for\r\n// correctness.  This roughly doubles the execution time of the\r\n// fastest routines (and adds 600+ bytes), so should not normally be\r\n// used in 'production'.\r\n// decCheckInexact is used to check that inexact results have a full\r\n// complement of digits (where appropriate -- this is not the case\r\n// for Quantize, for example)\r\n#define DECUNRESU ((decNumber *)(void *)0xffffffff)\r\n#define DECUNUSED ((const decNumber *)(void *)0xffffffff)\r\n#define DECUNCONT ((decContext *)(void *)(0xffffffff))\r\nstatic Flag decCheckOperands(decNumber *, const decNumber *,\r\n                             const decNumber *, decContext *);\r\nstatic Flag decCheckNumber(const decNumber *);\r\nstatic void decCheckInexact(const decNumber *, decContext *);\r\n#endif\r\n\r\n#if DECTRACE || DECCHECK\r\n// Optional trace/debugging routines (may or may not be used)\r\nvoid decNumberShow(const decNumber *);  // displays the components of a number\r\nstatic void decDumpAr(char, const Unit *, Int);\r\n#endif\r\n\r\n/* ================================================================== */\r\n/* Conversions                                                        */\r\n/* ================================================================== */\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* from-int32 -- conversion from Int or uInt                          */\r\n/*                                                                    */\r\n/*  dn is the decNumber to receive the integer                        */\r\n/*  in or uin is the integer to be converted                          */\r\n/*  returns dn                                                        */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberFromInt32(decNumber *dn, Int in) {\r\n  uInt unsig;\r\n  if (in>=0) unsig=in;\r\n   else {                               // negative (possibly BADINT)\r\n    if (in==BADINT) unsig=(uInt)1073741824*2; // special case\r\n     else unsig=-in;                    // invert\r\n    }\r\n  // in is now positive\r\n  decNumberFromUInt32(dn, unsig);\r\n  if (in<0) dn->bits=DECNEG;            // sign needed\r\n  return dn;\r\n  } // decNumberFromInt32\r\n\r\ndecNumber * decNumberFromUInt32(decNumber *dn, uInt uin) {\r\n  Unit *up;                             // work pointer\r\n  decNumberZero(dn);                    // clean\r\n  if (uin==0) return dn;                // [or decGetDigits bad call]\r\n  for (up=dn->lsu; uin>0; up++) {\r\n    *up=(Unit)(uin%(DECDPUNMAX+1));\r\n    uin=uin/(DECDPUNMAX+1);\r\n    }\r\n  dn->digits=decGetDigits(dn->lsu, up-dn->lsu);\r\n  return dn;\r\n  } // decNumberFromUInt32\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* to-int32 -- conversion to Int or uInt                              */\r\n/*                                                                    */\r\n/*  dn is the decNumber to convert                                    */\r\n/*  set is the context for reporting errors                           */\r\n/*  returns the converted decNumber, or 0 if Invalid is set           */\r\n/*                                                                    */\r\n/* Invalid is set if the decNumber does not have exponent==0 or if    */\r\n/* it is a NaN, Infinite, or out-of-range.                            */\r\n/* ------------------------------------------------------------------ */\r\nInt decNumberToInt32(const decNumber *dn, decContext *set) {\r\n  #if DECCHECK\r\n  if (decCheckOperands(DECUNRESU, DECUNUSED, dn, set)) return 0;\r\n  #endif\r\n\r\n  // special or too many digits, or bad exponent\r\n  if (dn->bits&DECSPECIAL || dn->digits>10 || dn->exponent!=0) ; // bad\r\n   else { // is a finite integer with 10 or fewer digits\r\n    Int d;                         // work\r\n    const Unit *up;                // ..\r\n    uInt hi=0, lo;                 // ..\r\n    up=dn->lsu;                    // -> lsu\r\n    lo=*up;                        // get 1 to 9 digits\r\n    #if DECDPUN>1                  // split to higher\r\n      hi=lo/10;\r\n      lo=lo%10;\r\n    #endif\r\n    up++;\r\n    // collect remaining Units, if any, into hi\r\n    for (d=DECDPUN; d<dn->digits; up++, d+=DECDPUN) hi+=*up*powers[d-1];\r\n    // now low has the lsd, hi the remainder\r\n    if (hi>214748364 || (hi==214748364 && lo>7)) { // out of range?\r\n      // most-negative is a reprieve\r\n      if (dn->bits&DECNEG && hi==214748364 && lo==8) return 0x80000000;\r\n      // bad -- drop through\r\n      }\r\n     else { // in-range always\r\n      Int i=X10(hi)+lo;\r\n      if (dn->bits&DECNEG) return -i;\r\n      return i;\r\n      }\r\n    } // integer\r\n  decContextSetStatus(set, DEC_Invalid_operation); // [may not return]\r\n  return 0;\r\n  } // decNumberToInt32\r\n\r\nuInt decNumberToUInt32(const decNumber *dn, decContext *set) {\r\n  #if DECCHECK\r\n  if (decCheckOperands(DECUNRESU, DECUNUSED, dn, set)) return 0;\r\n  #endif\r\n  // special or too many digits, or bad exponent, or negative (<0)\r\n  if (dn->bits&DECSPECIAL || dn->digits>10 || dn->exponent!=0\r\n    || (dn->bits&DECNEG && !ISZERO(dn)));                   // bad\r\n   else { // is a finite integer with 10 or fewer digits\r\n    Int d;                         // work\r\n    const Unit *up;                // ..\r\n    uInt hi=0, lo;                 // ..\r\n    up=dn->lsu;                    // -> lsu\r\n    lo=*up;                        // get 1 to 9 digits\r\n    #if DECDPUN>1                  // split to higher\r\n      hi=lo/10;\r\n      lo=lo%10;\r\n    #endif\r\n    up++;\r\n    // collect remaining Units, if any, into hi\r\n    for (d=DECDPUN; d<dn->digits; up++, d+=DECDPUN) hi+=*up*powers[d-1];\r\n\r\n    // now low has the lsd, hi the remainder\r\n    if (hi>429496729 || (hi==429496729 && lo>5)) ; // no reprieve possible\r\n     else return X10(hi)+lo;\r\n    } // integer\r\n  decContextSetStatus(set, DEC_Invalid_operation); // [may not return]\r\n  return 0;\r\n  } // decNumberToUInt32\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* to-scientific-string -- conversion to numeric string               */\r\n/* to-engineering-string -- conversion to numeric string              */\r\n/*                                                                    */\r\n/*   decNumberToString(dn, string);                                   */\r\n/*   decNumberToEngString(dn, string);                                */\r\n/*                                                                    */\r\n/*  dn is the decNumber to convert                                    */\r\n/*  string is the string where the result will be laid out            */\r\n/*                                                                    */\r\n/*  string must be at least dn->digits+14 characters long             */\r\n/*                                                                    */\r\n/*  No error is possible, and no status can be set.                   */\r\n/* ------------------------------------------------------------------ */\r\nchar * decNumberToString(const decNumber *dn, char *string){\r\n  decToString(dn, string, 0);\r\n  return string;\r\n  } // DecNumberToString\r\n\r\nchar * decNumberToEngString(const decNumber *dn, char *string){\r\n  decToString(dn, string, 1);\r\n  return string;\r\n  } // DecNumberToEngString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* to-number -- conversion from numeric string                        */\r\n/*                                                                    */\r\n/* decNumberFromString -- convert string to decNumber                 */\r\n/*   dn        -- the number structure to fill                        */\r\n/*   chars[]   -- the string to convert ('\\0' terminated)             */\r\n/*   set       -- the context used for processing any error,          */\r\n/*                determining the maximum precision available         */\r\n/*                (set.digits), determining the maximum and minimum   */\r\n/*                exponent (set.emax and set.emin), determining if    */\r\n/*                extended values are allowed, and checking the       */\r\n/*                rounding mode if overflow occurs or rounding is     */\r\n/*                needed.                                             */\r\n/*                                                                    */\r\n/* The length of the coefficient and the size of the exponent are     */\r\n/* checked by this routine, so the correct error (Underflow or        */\r\n/* Overflow) can be reported or rounding applied, as necessary.       */\r\n/*                                                                    */\r\n/* If bad syntax is detected, the result will be a quiet NaN.         */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberFromString(decNumber *dn, const char chars[],\r\n                                decContext *set) {\r\n  Int   exponent=0;                // working exponent [assume 0]\r\n  uByte bits=0;                    // working flags [assume +ve]\r\n  Unit  *res;                      // where result will be built\r\n  Unit  resbuff[SD2U(DECBUFFER+9)];// local buffer in case need temporary\r\n                                   // [+9 allows for ln() constants]\r\n  Unit  *allocres=NULL;            // -> allocated result, iff allocated\r\n  Int   d=0;                       // count of digits found in decimal part\r\n  const char *dotchar=NULL;        // where dot was found\r\n  const char *cfirst=chars;        // -> first character of decimal part\r\n  const char *last=NULL;           // -> last digit of decimal part\r\n  const char *c;                   // work\r\n  Unit  *up;                       // ..\r\n  #if DECDPUN>1\r\n  Int   cut, out;                  // ..\r\n  #endif\r\n  Int   residue;                   // rounding residue\r\n  uInt  status=0;                  // error code\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(DECUNRESU, DECUNUSED, DECUNUSED, set))\r\n    return decNumberZero(dn);\r\n  #endif\r\n\r\n  do {                             // status & malloc protection\r\n    for (c=chars;; c++) {          // -> input character\r\n      if (*c>='0' && *c<='9') {    // test for Arabic digit\r\n        last=c;\r\n        d++;                       // count of real digits\r\n        continue;                  // still in decimal part\r\n        }\r\n      if (*c=='.' && dotchar==NULL) { // first '.'\r\n        dotchar=c;                 // record offset into decimal part\r\n        if (c==cfirst) cfirst++;   // first digit must follow\r\n        continue;}\r\n      if (c==chars) {              // first in string...\r\n        if (*c=='-') {             // valid - sign\r\n          cfirst++;\r\n          bits=DECNEG;\r\n          continue;}\r\n        if (*c=='+') {             // valid + sign\r\n          cfirst++;\r\n          continue;}\r\n        }\r\n      // *c is not a digit, or a valid +, -, or '.'\r\n      break;\r\n      } // c\r\n\r\n    if (last==NULL) {              // no digits yet\r\n      status=DEC_Conversion_syntax;// assume the worst\r\n      if (*c=='\\0') break;         // and no more to come...\r\n      #if DECSUBSET\r\n      // if subset then infinities and NaNs are not allowed\r\n      if (!set->extended) break;   // hopeless\r\n      #endif\r\n      // Infinities and NaNs are possible, here\r\n      if (dotchar!=NULL) break;    // .. unless had a dot\r\n      decNumberZero(dn);           // be optimistic\r\n      if (decBiStr(c, \"infinity\", \"INFINITY\")\r\n       || decBiStr(c, \"inf\", \"INF\")) {\r\n        dn->bits=bits | DECINF;\r\n        status=0;                  // is OK\r\n        break; // all done\r\n        }\r\n      // a NaN expected\r\n      // 2003.09.10 NaNs are now permitted to have a sign\r\n      dn->bits=bits | DECNAN;      // assume simple NaN\r\n      if (*c=='s' || *c=='S') {    // looks like an sNaN\r\n        c++;\r\n        dn->bits=bits | DECSNAN;\r\n        }\r\n      if (*c!='n' && *c!='N') break;    // check caseless \"NaN\"\r\n      c++;\r\n      if (*c!='a' && *c!='A') break;    // ..\r\n      c++;\r\n      if (*c!='n' && *c!='N') break;    // ..\r\n      c++;\r\n      // now either nothing, or nnnn payload, expected\r\n      // -> start of integer and skip leading 0s [including plain 0]\r\n      for (cfirst=c; *cfirst=='0';) cfirst++;\r\n      if (*cfirst=='\\0') {         // \"NaN\" or \"sNaN\", maybe with all 0s\r\n        status=0;                  // it's good\r\n        break;                     // ..\r\n        }\r\n      // something other than 0s; setup last and d as usual [no dots]\r\n      for (c=cfirst;; c++, d++) {\r\n        if (*c<'0' || *c>'9') break; // test for Arabic digit\r\n        last=c;\r\n        }\r\n      if (*c!='\\0') break;         // not all digits\r\n      if (d>set->digits-1) {\r\n        // [NB: payload in a decNumber can be full length unless\r\n        // clamped, in which case can only be digits-1]\r\n        if (set->clamp) break;\r\n        if (d>set->digits) break;\r\n        } // too many digits?\r\n      // good; drop through to convert the integer to coefficient\r\n      status=0;                    // syntax is OK\r\n      bits=dn->bits;               // for copy-back\r\n      } // last==NULL\r\n\r\n     else if (*c!='\\0') {          // more to process...\r\n      // had some digits; exponent is only valid sequence now\r\n      Flag nege;                   // 1=negative exponent\r\n      const char *firstexp;        // -> first significant exponent digit\r\n      status=DEC_Conversion_syntax;// assume the worst\r\n      uInt expa=0;                 // accumulator for exponent\r\n      if (*c!='e' && *c!='E') break;\r\n      /* Found 'e' or 'E' -- now process explicit exponent */\r\n      // 1998.07.11: sign no longer required\r\n      nege=0;\r\n      c++;                         // to (possible) sign\r\n      if (*c=='-') {nege=1; c++;}\r\n       else if (*c=='+') c++;\r\n      if (*c=='\\0') break;\r\n\r\n      for (; *c=='0' && *(c+1)!='\\0';) c++;  // strip insignificant zeros\r\n      firstexp=c;                            // save exponent digit place\r\n      for (; ;c++) {\r\n        if (*c<'0' || *c>'9') break;         // not a digit\r\n        expa=X10(expa)+(Int)*c-(Int)'0';\r\n        } // c\r\n      // if not now on a '\\0', *c must not be a digit\r\n      if (*c!='\\0') break;\r\n\r\n      // (this next test must be after the syntax checks)\r\n      // if it was too long the exponent may have wrapped, so check\r\n      // carefully and set it to a certain overflow if wrap possible\r\n      if (c>=firstexp+9+1) {\r\n        if (c>firstexp+9+1 || *firstexp>'1') expa=DECNUMMAXE*2;\r\n        // [up to 1999999999 is OK, for example 1E-1000000998]\r\n        }\r\n      exponent=(Int)expa;               // save exponent\r\n      if (nege) exponent=-exponent;     // was negative\r\n      status=0;                         // is OK\r\n      } // stuff after digits\r\n\r\n    // Here when whole string has been inspected; syntax is good\r\n    // cfirst->first digit (never dot), last->last digit (ditto)\r\n\r\n    // strip leading zeros/dot [leave final 0 if all 0's]\r\n    if (*cfirst=='0') {                 // [cfirst has stepped over .]\r\n      for (c=cfirst; c<last; c++, cfirst++) {\r\n        if (*c=='.') continue;          // ignore dots\r\n        if (*c!='0') break;             // non-zero found\r\n        d--;                            // 0 stripped\r\n        } // c\r\n      #if DECSUBSET\r\n      // make a rapid exit for easy zeros if !extended\r\n      if (*cfirst=='0' && !set->extended) {\r\n        decNumberZero(dn);              // clean result\r\n        break;                          // [could be return]\r\n        }\r\n      #endif\r\n      } // at least one leading 0\r\n\r\n    // Handle decimal point...\r\n    if (dotchar!=NULL && dotchar<last)  // non-trailing '.' found?\r\n      exponent-=(last-dotchar);         // adjust exponent\r\n    // [we can now ignore the .]\r\n\r\n    // OK, the digits string is good.  Assemble in the decNumber, or in\r\n    // a temporary units array if rounding is needed\r\n    if (d<=set->digits) res=dn->lsu;    // fits into supplied decNumber\r\n     else {                             // rounding needed\r\n      Int needbytes=D2U(d)*sizeof(Unit);// bytes needed\r\n      res=resbuff;                      // assume use local buffer\r\n      if (needbytes>(Int)sizeof(resbuff)) { // too big for local\r\n        allocres=(Unit *)malloc(needbytes);\r\n        if (allocres==NULL) {status|=DEC_Insufficient_storage; break;}\r\n        res=allocres;\r\n        }\r\n      }\r\n    // res now -> number lsu, buffer, or allocated storage for Unit array\r\n\r\n    // Place the coefficient into the selected Unit array\r\n    // [this is often 70% of the cost of this function when DECDPUN>1]\r\n    #if DECDPUN>1\r\n    out=0;                         // accumulator\r\n    up=res+D2U(d)-1;               // -> msu\r\n    cut=d-(up-res)*DECDPUN;        // digits in top unit\r\n    for (c=cfirst;; c++) {         // along the digits\r\n      if (*c=='.') continue;       // ignore '.' [don't decrement cut]\r\n      out=X10(out)+(Int)*c-(Int)'0';\r\n      if (c==last) break;          // done [never get to trailing '.']\r\n      cut--;\r\n      if (cut>0) continue;         // more for this unit\r\n      *up=(Unit)out;               // write unit\r\n      up--;                        // prepare for unit below..\r\n      cut=DECDPUN;                 // ..\r\n      out=0;                       // ..\r\n      } // c\r\n    *up=(Unit)out;                 // write lsu\r\n\r\n    #else\r\n    // DECDPUN==1\r\n    up=res;                        // -> lsu\r\n    for (c=last; c>=cfirst; c--) { // over each character, from least\r\n      if (*c=='.') continue;       // ignore . [don't step up]\r\n      *up=(Unit)((Int)*c-(Int)'0');\r\n      up++;\r\n      } // c\r\n    #endif\r\n\r\n    dn->bits=bits;\r\n    dn->exponent=exponent;\r\n    dn->digits=d;\r\n\r\n    // if not in number (too long) shorten into the number\r\n    if (d>set->digits) {\r\n      residue=0;\r\n      decSetCoeff(dn, set, res, d, &residue, &status);\r\n      // always check for overflow or subnormal and round as needed\r\n      decFinalize(dn, set, &residue, &status);\r\n      }\r\n     else { // no rounding, but may still have overflow or subnormal\r\n      // [these tests are just for performance; finalize repeats them]\r\n      if ((dn->exponent-1<set->emin-dn->digits)\r\n       || (dn->exponent-1>set->emax-set->digits)) {\r\n        residue=0;\r\n        decFinalize(dn, set, &residue, &status);\r\n        }\r\n      }\r\n    // decNumberShow(dn);\r\n    } while(0);                         // [for break]\r\n\r\n  if (allocres!=NULL) free(allocres);   // drop any storage used\r\n  if (status!=0) decStatus(dn, status, set);\r\n  return dn;\r\n  } /* decNumberFromString */\r\n\r\n/* ================================================================== */\r\n/* Operators                                                          */\r\n/* ================================================================== */\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberAbs -- absolute value operator                            */\r\n/*                                                                    */\r\n/*   This computes C = abs(A)                                         */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* See also decNumberCopyAbs for a quiet bitwise version of this.     */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\n/* This has the same effect as decNumberPlus unless A is negative,    */\r\n/* in which case it has the same effect as decNumberMinus.            */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberAbs(decNumber *res, const decNumber *rhs,\r\n                         decContext *set) {\r\n  decNumber dzero;                      // for 0\r\n  uInt status=0;                        // accumulator\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  decNumberZero(&dzero);                // set 0\r\n  dzero.exponent=rhs->exponent;         // [no coefficient expansion]\r\n  decAddOp(res, &dzero, rhs, set, (uByte)(rhs->bits & DECNEG), &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberAbs\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberAdd -- add two Numbers                                    */\r\n/*                                                                    */\r\n/*   This computes C = A + B                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X+X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\n/* This just calls the routine shared with Subtract                   */\r\ndecNumber * decNumberAdd(decNumber *res, const decNumber *lhs,\r\n                         const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decAddOp(res, lhs, rhs, set, 0, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberAdd\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberAnd -- AND two Numbers, digitwise                         */\r\n/*                                                                    */\r\n/*   This computes C = A & B                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X&X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context (used for result length and error report)     */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Logical function restrictions apply (see above); a NaN is          */\r\n/* returned with Invalid_operation if a restriction is violated.      */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberAnd(decNumber *res, const decNumber *lhs,\r\n                         const decNumber *rhs, decContext *set) {\r\n  const Unit *ua, *ub;                  // -> operands\r\n  const Unit *msua, *msub;              // -> operand msus\r\n  Unit *uc,  *msuc;                     // -> result and its msu\r\n  Int   msudigs;                        // digits in res msu\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs)\r\n   || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {\r\n    decStatus(res, DEC_Invalid_operation, set);\r\n    return res;\r\n    }\r\n\r\n  // operands are valid\r\n  ua=lhs->lsu;                          // bottom-up\r\n  ub=rhs->lsu;                          // ..\r\n  uc=res->lsu;                          // ..\r\n  msua=ua+D2U(lhs->digits)-1;           // -> msu of lhs\r\n  msub=ub+D2U(rhs->digits)-1;           // -> msu of rhs\r\n  msuc=uc+D2U(set->digits)-1;           // -> msu of result\r\n  msudigs=MSUDIGITS(set->digits);       // [faster than remainder]\r\n  for (; uc<=msuc; ua++, ub++, uc++) {  // Unit loop\r\n    Unit a, b;                          // extract units\r\n    if (ua>msua) a=0;\r\n     else a=*ua;\r\n    if (ub>msub) b=0;\r\n     else b=*ub;\r\n    *uc=0;                              // can now write back\r\n    if (a|b) {                          // maybe 1 bits to examine\r\n      Int i, j;\r\n      *uc=0;                            // can now write back\r\n      // This loop could be unrolled and/or use BIN2BCD tables\r\n      for (i=0; i<DECDPUN; i++) {\r\n        if (a&b&1) *uc=*uc+(Unit)powers[i];  // effect AND\r\n        j=a%10;\r\n        a=a/10;\r\n        j|=b%10;\r\n        b=b/10;\r\n        if (j>1) {\r\n          decStatus(res, DEC_Invalid_operation, set);\r\n          return res;\r\n          }\r\n        if (uc==msuc && i==msudigs-1) break; // just did final digit\r\n        } // each digit\r\n      } // both OK\r\n    } // each unit\r\n  // [here uc-1 is the msu of the result]\r\n  res->digits=decGetDigits(res->lsu, uc-res->lsu);\r\n  res->exponent=0;                      // integer\r\n  res->bits=0;                          // sign=0\r\n  return res;  // [no status to set]\r\n  } // decNumberAnd\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberCompare -- compare two Numbers                            */\r\n/*                                                                    */\r\n/*   This computes C = A ? B                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for one digit (or NaN).                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberCompare(decNumber *res, const decNumber *lhs,\r\n                             const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decCompareOp(res, lhs, rhs, set, COMPARE, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberCompare\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberCompareSignal -- compare, signalling on all NaNs          */\r\n/*                                                                    */\r\n/*   This computes C = A ? B                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for one digit (or NaN).                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberCompareSignal(decNumber *res, const decNumber *lhs,\r\n                                   const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decCompareOp(res, lhs, rhs, set, COMPSIG, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberCompareSignal\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberCompareTotal -- compare two Numbers, using total ordering */\r\n/*                                                                    */\r\n/*   This computes C = A ? B, under total ordering                    */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for one digit; the result will always be one of  */\r\n/* -1, 0, or 1.                                                       */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberCompareTotal(decNumber *res, const decNumber *lhs,\r\n                                  const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberCompareTotal\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberCompareTotalMag -- compare, total ordering of magnitudes  */\r\n/*                                                                    */\r\n/*   This computes C = |A| ? |B|, under total ordering                */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for one digit; the result will always be one of  */\r\n/* -1, 0, or 1.                                                       */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberCompareTotalMag(decNumber *res, const decNumber *lhs,\r\n                                     const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                   // accumulator\r\n  uInt needbytes;                  // for space calculations\r\n  decNumber bufa[D2N(DECBUFFER+1)];// +1 in case DECBUFFER=0\r\n  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated\r\n  decNumber bufb[D2N(DECBUFFER+1)];\r\n  decNumber *allocbufb=NULL;       // -> allocated bufb, iff allocated\r\n  decNumber *a, *b;                // temporary pointers\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  do {                                  // protect allocated storage\r\n    // if either is negative, take a copy and absolute\r\n    if (decNumberIsNegative(lhs)) {     // lhs<0\r\n      a=bufa;\r\n      needbytes=sizeof(decNumber)+(D2U(lhs->digits)-1)*sizeof(Unit);\r\n      if (needbytes>sizeof(bufa)) {     // need malloc space\r\n        allocbufa=(decNumber *)malloc(needbytes);\r\n        if (allocbufa==NULL) {          // hopeless -- abandon\r\n          status|=DEC_Insufficient_storage;\r\n          break;}\r\n        a=allocbufa;                    // use the allocated space\r\n        }\r\n      decNumberCopy(a, lhs);            // copy content\r\n      a->bits&=~DECNEG;                 // .. and clear the sign\r\n      lhs=a;                            // use copy from here on\r\n      }\r\n    if (decNumberIsNegative(rhs)) {     // rhs<0\r\n      b=bufb;\r\n      needbytes=sizeof(decNumber)+(D2U(rhs->digits)-1)*sizeof(Unit);\r\n      if (needbytes>sizeof(bufb)) {     // need malloc space\r\n        allocbufb=(decNumber *)malloc(needbytes);\r\n        if (allocbufb==NULL) {          // hopeless -- abandon\r\n          status|=DEC_Insufficient_storage;\r\n          break;}\r\n        b=allocbufb;                    // use the allocated space\r\n        }\r\n      decNumberCopy(b, rhs);            // copy content\r\n      b->bits&=~DECNEG;                 // .. and clear the sign\r\n      rhs=b;                            // use copy from here on\r\n      }\r\n    decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status);\r\n    } while(0);                         // end protected\r\n\r\n  if (allocbufa!=NULL) free(allocbufa); // drop any storage used\r\n  if (allocbufb!=NULL) free(allocbufb); // ..\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberCompareTotalMag\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberDivide -- divide one number by another                    */\r\n/*                                                                    */\r\n/*   This computes C = A / B                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X/X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberDivide(decNumber *res, const decNumber *lhs,\r\n                            const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decDivideOp(res, lhs, rhs, set, DIVIDE, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberDivide\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberDivideInteger -- divide and return integer quotient       */\r\n/*                                                                    */\r\n/*   This computes C = A # B, where # is the integer divide operator  */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X#X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberDivideInteger(decNumber *res, const decNumber *lhs,\r\n                                   const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decDivideOp(res, lhs, rhs, set, DIVIDEINT, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberDivideInteger\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberExp -- exponentiation                                     */\r\n/*                                                                    */\r\n/*   This computes C = exp(A)                                         */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context; note that rounding mode has no effect        */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Mathematical function restrictions apply (see above); a NaN is     */\r\n/* returned with Invalid_operation if a restriction is violated.      */\r\n/*                                                                    */\r\n/* Finite results will always be full precision and Inexact, except   */\r\n/* when A is a zero or -Infinity (giving 1 or 0 respectively).        */\r\n/*                                                                    */\r\n/* An Inexact result is rounded using DEC_ROUND_HALF_EVEN; it will    */\r\n/* almost always be correctly rounded, but may be up to 1 ulp in      */\r\n/* error in rare cases.                                               */\r\n/* ------------------------------------------------------------------ */\r\n/* This is a wrapper for decExpOp which can handle the slightly wider */\r\n/* (double) range needed by Ln (which has to be able to calculate     */\r\n/* exp(-a) where a can be the tiniest number (Ntiny).                 */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberExp(decNumber *res, const decNumber *rhs,\r\n                         decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  #if DECSUBSET\r\n  decNumber *allocrhs=NULL;        // non-NULL if rounded rhs allocated\r\n  #endif\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  // Check restrictions; these restrictions ensure that if h=8 (see\r\n  // decExpOp) then the result will either overflow or underflow to 0.\r\n  // Other math functions restrict the input range, too, for inverses.\r\n  // If not violated then carry out the operation.\r\n  if (!decCheckMath(rhs, set, &status)) do { // protect allocation\r\n    #if DECSUBSET\r\n    if (!set->extended) {\r\n      // reduce operand and set lostDigits status, as needed\r\n      if (rhs->digits>set->digits) {\r\n        allocrhs=decRoundOperand(rhs, set, &status);\r\n        if (allocrhs==NULL) break;\r\n        rhs=allocrhs;\r\n        }\r\n      }\r\n    #endif\r\n    decExpOp(res, rhs, set, &status);\r\n    } while(0);                         // end protected\r\n\r\n  #if DECSUBSET\r\n  if (allocrhs !=NULL) free(allocrhs);  // drop any storage used\r\n  #endif\r\n  // apply significant status\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberExp\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberFMA -- fused multiply add                                 */\r\n/*                                                                    */\r\n/*   This computes D = (A * B) + C with only one rounding             */\r\n/*                                                                    */\r\n/*   res is D, the result.  D may be A or B or C (e.g., X=FMA(X,X,X)) */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   fhs is C [far hand side]                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* Mathematical function restrictions apply (see above); a NaN is     */\r\n/* returned with Invalid_operation if a restriction is violated.      */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberFMA(decNumber *res, const decNumber *lhs,\r\n                         const decNumber *rhs, const decNumber *fhs,\r\n                         decContext *set) {\r\n  uInt status=0;                   // accumulator\r\n  decContext dcmul;                // context for the multiplication\r\n  uInt needbytes;                  // for space calculations\r\n  decNumber bufa[D2N(DECBUFFER*2+1)];\r\n  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated\r\n  decNumber *acc;                  // accumulator pointer\r\n  decNumber dzero;                 // work\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  if (decCheckOperands(res, fhs, DECUNUSED, set)) return res;\r\n  #endif\r\n\r\n  do {                                  // protect allocated storage\r\n    #if DECSUBSET\r\n    if (!set->extended) {               // [undefined if subset]\r\n      status|=DEC_Invalid_operation;\r\n      break;}\r\n    #endif\r\n    // Check math restrictions [these ensure no overflow or underflow]\r\n    if ((!decNumberIsSpecial(lhs) && decCheckMath(lhs, set, &status))\r\n     || (!decNumberIsSpecial(rhs) && decCheckMath(rhs, set, &status))\r\n     || (!decNumberIsSpecial(fhs) && decCheckMath(fhs, set, &status))) break;\r\n    // set up context for multiply\r\n    dcmul=*set;\r\n    dcmul.digits=lhs->digits+rhs->digits; // just enough\r\n    // [The above may be an over-estimate for subset arithmetic, but that's OK]\r\n    dcmul.emax=DEC_MAX_EMAX;            // effectively unbounded ..\r\n    dcmul.emin=DEC_MIN_EMIN;            // [thanks to Math restrictions]\r\n    // set up decNumber space to receive the result of the multiply\r\n    acc=bufa;                           // may fit\r\n    needbytes=sizeof(decNumber)+(D2U(dcmul.digits)-1)*sizeof(Unit);\r\n    if (needbytes>sizeof(bufa)) {       // need malloc space\r\n      allocbufa=(decNumber *)malloc(needbytes);\r\n      if (allocbufa==NULL) {            // hopeless -- abandon\r\n        status|=DEC_Insufficient_storage;\r\n        break;}\r\n      acc=allocbufa;                    // use the allocated space\r\n      }\r\n    // multiply with extended range and necessary precision\r\n    //printf(\"emin=%ld\\n\", dcmul.emin);\r\n    decMultiplyOp(acc, lhs, rhs, &dcmul, &status);\r\n    // Only Invalid operation (from sNaN or Inf * 0) is possible in\r\n    // status; if either is seen than ignore fhs (in case it is\r\n    // another sNaN) and set acc to NaN unless we had an sNaN\r\n    // [decMultiplyOp leaves that to caller]\r\n    // Note sNaN has to go through addOp to shorten payload if\r\n    // necessary\r\n    if ((status&DEC_Invalid_operation)!=0) {\r\n      if (!(status&DEC_sNaN)) {         // but be true invalid\r\n        decNumberZero(res);             // acc not yet set\r\n        res->bits=DECNAN;\r\n        break;\r\n        }\r\n      decNumberZero(&dzero);            // make 0 (any non-NaN would do)\r\n      fhs=&dzero;                       // use that\r\n      }\r\n    #if DECCHECK\r\n     else { // multiply was OK\r\n      if (status!=0) printf(\"Status=%08lx after FMA multiply\\n\", (LI)status);\r\n      }\r\n    #endif\r\n    // add the third operand and result -> res, and all is done\r\n    decAddOp(res, acc, fhs, set, 0, &status);\r\n    } while(0);                         // end protected\r\n\r\n  if (allocbufa!=NULL) free(allocbufa); // drop any storage used\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberFMA\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberInvert -- invert a Number, digitwise                      */\r\n/*                                                                    */\r\n/*   This computes C = ~A                                             */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A (e.g., X=~X)                   */\r\n/*   rhs is A                                                         */\r\n/*   set is the context (used for result length and error report)     */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Logical function restrictions apply (see above); a NaN is          */\r\n/* returned with Invalid_operation if a restriction is violated.      */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberInvert(decNumber *res, const decNumber *rhs,\r\n                            decContext *set) {\r\n  const Unit *ua, *msua;                // -> operand and its msu\r\n  Unit  *uc, *msuc;                     // -> result and its msu\r\n  Int   msudigs;                        // digits in res msu\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  if (rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {\r\n    decStatus(res, DEC_Invalid_operation, set);\r\n    return res;\r\n    }\r\n  // operand is valid\r\n  ua=rhs->lsu;                          // bottom-up\r\n  uc=res->lsu;                          // ..\r\n  msua=ua+D2U(rhs->digits)-1;           // -> msu of rhs\r\n  msuc=uc+D2U(set->digits)-1;           // -> msu of result\r\n  msudigs=MSUDIGITS(set->digits);       // [faster than remainder]\r\n  for (; uc<=msuc; ua++, uc++) {        // Unit loop\r\n    Unit a;                             // extract unit\r\n    Int  i, j;                          // work\r\n    if (ua>msua) a=0;\r\n     else a=*ua;\r\n    *uc=0;                              // can now write back\r\n    // always need to examine all bits in rhs\r\n    // This loop could be unrolled and/or use BIN2BCD tables\r\n    for (i=0; i<DECDPUN; i++) {\r\n      if ((~a)&1) *uc=*uc+(Unit)powers[i];   // effect INVERT\r\n      j=a%10;\r\n      a=a/10;\r\n      if (j>1) {\r\n        decStatus(res, DEC_Invalid_operation, set);\r\n        return res;\r\n        }\r\n      if (uc==msuc && i==msudigs-1) break;   // just did final digit\r\n      } // each digit\r\n    } // each unit\r\n  // [here uc-1 is the msu of the result]\r\n  res->digits=decGetDigits(res->lsu, uc-res->lsu);\r\n  res->exponent=0;                      // integer\r\n  res->bits=0;                          // sign=0\r\n  return res;  // [no status to set]\r\n  } // decNumberInvert\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberLn -- natural logarithm                                   */\r\n/*                                                                    */\r\n/*   This computes C = ln(A)                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context; note that rounding mode has no effect        */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Notable cases:                                                     */\r\n/*   A<0 -> Invalid                                                   */\r\n/*   A=0 -> -Infinity (Exact)                                         */\r\n/*   A=+Infinity -> +Infinity (Exact)                                 */\r\n/*   A=1 exactly -> 0 (Exact)                                         */\r\n/*                                                                    */\r\n/* Mathematical function restrictions apply (see above); a NaN is     */\r\n/* returned with Invalid_operation if a restriction is violated.      */\r\n/*                                                                    */\r\n/* An Inexact result is rounded using DEC_ROUND_HALF_EVEN; it will    */\r\n/* almost always be correctly rounded, but may be up to 1 ulp in      */\r\n/* error in rare cases.                                               */\r\n/* ------------------------------------------------------------------ */\r\n/* This is a wrapper for decLnOp which can handle the slightly wider  */\r\n/* (+11) range needed by Ln, Log10, etc. (which may have to be able   */\r\n/* to calculate at p+e+2).                                            */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberLn(decNumber *res, const decNumber *rhs,\r\n                        decContext *set) {\r\n  uInt status=0;                   // accumulator\r\n  #if DECSUBSET\r\n  decNumber *allocrhs=NULL;        // non-NULL if rounded rhs allocated\r\n  #endif\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  // Check restrictions; this is a math function; if not violated\r\n  // then carry out the operation.\r\n  if (!decCheckMath(rhs, set, &status)) do { // protect allocation\r\n    #if DECSUBSET\r\n    if (!set->extended) {\r\n      // reduce operand and set lostDigits status, as needed\r\n      if (rhs->digits>set->digits) {\r\n        allocrhs=decRoundOperand(rhs, set, &status);\r\n        if (allocrhs==NULL) break;\r\n        rhs=allocrhs;\r\n        }\r\n      // special check in subset for rhs=0\r\n      if (ISZERO(rhs)) {                // +/- zeros -> error\r\n        status|=DEC_Invalid_operation;\r\n        break;}\r\n      } // extended=0\r\n    #endif\r\n    decLnOp(res, rhs, set, &status);\r\n    } while(0);                         // end protected\r\n\r\n  #if DECSUBSET\r\n  if (allocrhs !=NULL) free(allocrhs);  // drop any storage used\r\n  #endif\r\n  // apply significant status\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberLn\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberLogB - get adjusted exponent, by 754 rules                */\r\n/*                                                                    */\r\n/*   This computes C = adjustedexponent(A)                            */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context, used only for digits and status              */\r\n/*                                                                    */\r\n/* For an unrounded result, digits may need to be 10 (A might have    */\r\n/* 10**9 digits and an exponent of +999999999, or one digit and an    */\r\n/* exponent of -1999999999).                                          */\r\n/*                                                                    */\r\n/* This returns the adjusted exponent of A after (in theory) padding  */\r\n/* with zeros on the right to set->digits digits while keeping the    */\r\n/* same value.  The exponent is not limited by emin/emax.             */\r\n/*                                                                    */\r\n/* Notable cases:                                                     */\r\n/*   A<0 -> Use |A|                                                   */\r\n/*   A=0 -> -Infinity (Division by zero)                              */\r\n/*   A=Infinite -> +Infinity (Exact)                                  */\r\n/*   A=1 exactly -> 0 (Exact)                                         */\r\n/*   NaNs are propagated as usual                                     */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberLogB(decNumber *res, const decNumber *rhs,\r\n                          decContext *set) {\r\n  uInt status=0;                   // accumulator\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  // NaNs as usual; Infinities return +Infinity; 0->oops\r\n  if (decNumberIsNaN(rhs)) decNaNs(res, rhs, NULL, set, &status);\r\n   else if (decNumberIsInfinite(rhs)) decNumberCopyAbs(res, rhs);\r\n   else if (decNumberIsZero(rhs)) {\r\n    decNumberZero(res);                 // prepare for Infinity\r\n    res->bits=DECNEG|DECINF;            // -Infinity\r\n    status|=DEC_Division_by_zero;       // as per 754\r\n    }\r\n   else { // finite non-zero\r\n    Int ae=rhs->exponent+rhs->digits-1; // adjusted exponent\r\n    if (set->digits>=10) decNumberFromInt32(res, ae);  // lay it out\r\n     else {\r\n      decNumber buft[D2N(10)];          // temporary number\r\n      decNumber *t=buft;                // ..\r\n      decNumberFromInt32(t, ae);        // lay it out\r\n      decNumberPlus(res, t, set);       // round as necessary\r\n      }\r\n    }\r\n\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberLogB\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberLog10 -- logarithm in base 10                             */\r\n/*                                                                    */\r\n/*   This computes C = log10(A)                                       */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context; note that rounding mode has no effect        */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Notable cases:                                                     */\r\n/*   A<0 -> Invalid                                                   */\r\n/*   A=0 -> -Infinity (Exact)                                         */\r\n/*   A=+Infinity -> +Infinity (Exact)                                 */\r\n/*   A=10**n (if n is an integer) -> n (Exact)                        */\r\n/*                                                                    */\r\n/* Mathematical function restrictions apply (see above); a NaN is     */\r\n/* returned with Invalid_operation if a restriction is violated.      */\r\n/*                                                                    */\r\n/* An Inexact result is rounded using DEC_ROUND_HALF_EVEN; it will    */\r\n/* almost always be correctly rounded, but may be up to 1 ulp in      */\r\n/* error in rare cases.                                               */\r\n/* ------------------------------------------------------------------ */\r\n/* This calculates ln(A)/ln(10) using appropriate precision.  For     */\r\n/* ln(A) this is the max(p, rhs->digits + t) + 3, where p is the      */\r\n/* requested digits and t is the number of digits in the exponent     */\r\n/* (maximum 6).  For ln(10) it is p + 3; this is often handled by the */\r\n/* fastpath in decLnOp.  The final division is done to the requested  */\r\n/* precision.                                                         */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberLog10(decNumber *res, const decNumber *rhs,\r\n                          decContext *set) {\r\n  uInt status=0, ignore=0;         // status accumulators\r\n  uInt needbytes;                  // for space calculations\r\n  Int p;                           // working precision\r\n  Int t;                           // digits in exponent of A\r\n\r\n  // buffers for a and b working decimals\r\n  // (adjustment calculator, same size)\r\n  decNumber bufa[D2N(DECBUFFER+2)];\r\n  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated\r\n  decNumber *a=bufa;               // temporary a\r\n  decNumber bufb[D2N(DECBUFFER+2)];\r\n  decNumber *allocbufb=NULL;       // -> allocated bufb, iff allocated\r\n  decNumber *b=bufb;               // temporary b\r\n  decNumber bufw[D2N(10)];         // working 2-10 digit number\r\n  decNumber *w=bufw;               // ..\r\n  #if DECSUBSET\r\n  decNumber *allocrhs=NULL;        // non-NULL if rounded rhs allocated\r\n  #endif\r\n\r\n  decContext aset;                 // working context\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  // Check restrictions; this is a math function; if not violated\r\n  // then carry out the operation.\r\n  if (!decCheckMath(rhs, set, &status)) do { // protect malloc\r\n    #if DECSUBSET\r\n    if (!set->extended) {\r\n      // reduce operand and set lostDigits status, as needed\r\n      if (rhs->digits>set->digits) {\r\n        allocrhs=decRoundOperand(rhs, set, &status);\r\n        if (allocrhs==NULL) break;\r\n        rhs=allocrhs;\r\n        }\r\n      // special check in subset for rhs=0\r\n      if (ISZERO(rhs)) {                // +/- zeros -> error\r\n        status|=DEC_Invalid_operation;\r\n        break;}\r\n      } // extended=0\r\n    #endif\r\n\r\n    decContextDefault(&aset, DEC_INIT_DECIMAL64); // clean context\r\n\r\n    // handle exact powers of 10; only check if +ve finite\r\n    if (!(rhs->bits&(DECNEG|DECSPECIAL)) && !ISZERO(rhs)) {\r\n      Int residue=0;               // (no residue)\r\n      uInt copystat=0;             // clean status\r\n\r\n      // round to a single digit...\r\n      aset.digits=1;\r\n      decCopyFit(w, rhs, &aset, &residue, &copystat); // copy & shorten\r\n      // if exact and the digit is 1, rhs is a power of 10\r\n      if (!(copystat&DEC_Inexact) && w->lsu[0]==1) {\r\n        // the exponent, conveniently, is the power of 10; making\r\n        // this the result needs a little care as it might not fit,\r\n        // so first convert it into the working number, and then move\r\n        // to res\r\n        decNumberFromInt32(w, w->exponent);\r\n        residue=0;\r\n        decCopyFit(res, w, set, &residue, &status); // copy & round\r\n        decFinish(res, set, &residue, &status);     // cleanup/set flags\r\n        break;\r\n        } // not a power of 10\r\n      } // not a candidate for exact\r\n\r\n    // simplify the information-content calculation to use 'total\r\n    // number of digits in a, including exponent' as compared to the\r\n    // requested digits, as increasing this will only rarely cost an\r\n    // iteration in ln(a) anyway\r\n    t=6;                                // it can never be >6\r\n\r\n    // allocate space when needed...\r\n    p=(rhs->digits+t>set->digits?rhs->digits+t:set->digits)+3;\r\n    needbytes=sizeof(decNumber)+(D2U(p)-1)*sizeof(Unit);\r\n    if (needbytes>sizeof(bufa)) {       // need malloc space\r\n      allocbufa=(decNumber *)malloc(needbytes);\r\n      if (allocbufa==NULL) {            // hopeless -- abandon\r\n        status|=DEC_Insufficient_storage;\r\n        break;}\r\n      a=allocbufa;                      // use the allocated space\r\n      }\r\n    aset.digits=p;                      // as calculated\r\n    aset.emax=DEC_MAX_MATH;             // usual bounds\r\n    aset.emin=-DEC_MAX_MATH;            // ..\r\n    aset.clamp=0;                       // and no concrete format\r\n    decLnOp(a, rhs, &aset, &status);    // a=ln(rhs)\r\n\r\n    // skip the division if the result so far is infinite, NaN, or\r\n    // zero, or there was an error; note NaN from sNaN needs copy\r\n    if (status&DEC_NaNs && !(status&DEC_sNaN)) break;\r\n    if (a->bits&DECSPECIAL || ISZERO(a)) {\r\n      decNumberCopy(res, a);            // [will fit]\r\n      break;}\r\n\r\n    // for ln(10) an extra 3 digits of precision are needed\r\n    p=set->digits+3;\r\n    needbytes=sizeof(decNumber)+(D2U(p)-1)*sizeof(Unit);\r\n    if (needbytes>sizeof(bufb)) {       // need malloc space\r\n      allocbufb=(decNumber *)malloc(needbytes);\r\n      if (allocbufb==NULL) {            // hopeless -- abandon\r\n        status|=DEC_Insufficient_storage;\r\n        break;}\r\n      b=allocbufb;                      // use the allocated space\r\n      }\r\n    decNumberZero(w);                   // set up 10...\r\n    #if DECDPUN==1\r\n    w->lsu[1]=1; w->lsu[0]=0;           // ..\r\n    #else\r\n    w->lsu[0]=10;                       // ..\r\n    #endif\r\n    w->digits=2;                        // ..\r\n\r\n    aset.digits=p;\r\n    decLnOp(b, w, &aset, &ignore);      // b=ln(10)\r\n\r\n    aset.digits=set->digits;            // for final divide\r\n    decDivideOp(res, a, b, &aset, DIVIDE, &status); // into result\r\n    } while(0);                         // [for break]\r\n\r\n  if (allocbufa!=NULL) free(allocbufa); // drop any storage used\r\n  if (allocbufb!=NULL) free(allocbufb); // ..\r\n  #if DECSUBSET\r\n  if (allocrhs !=NULL) free(allocrhs);  // ..\r\n  #endif\r\n  // apply significant status\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberLog10\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberMax -- compare two Numbers and return the maximum         */\r\n/*                                                                    */\r\n/*   This computes C = A ? B, returning the maximum by 754 rules      */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberMax(decNumber *res, const decNumber *lhs,\r\n                         const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decCompareOp(res, lhs, rhs, set, COMPMAX, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberMax\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberMaxMag -- compare and return the maximum by magnitude     */\r\n/*                                                                    */\r\n/*   This computes C = A ? B, returning the maximum by 754 rules      */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberMaxMag(decNumber *res, const decNumber *lhs,\r\n                         const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decCompareOp(res, lhs, rhs, set, COMPMAXMAG, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberMaxMag\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberMin -- compare two Numbers and return the minimum         */\r\n/*                                                                    */\r\n/*   This computes C = A ? B, returning the minimum by 754 rules      */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberMin(decNumber *res, const decNumber *lhs,\r\n                         const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decCompareOp(res, lhs, rhs, set, COMPMIN, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberMin\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberMinMag -- compare and return the minimum by magnitude     */\r\n/*                                                                    */\r\n/*   This computes C = A ? B, returning the minimum by 754 rules      */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberMinMag(decNumber *res, const decNumber *lhs,\r\n                         const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decCompareOp(res, lhs, rhs, set, COMPMINMAG, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberMinMag\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberMinus -- prefix minus operator                            */\r\n/*                                                                    */\r\n/*   This computes C = 0 - A                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* See also decNumberCopyNegate for a quiet bitwise version of this.  */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\n/* Simply use AddOp for the subtract, which will do the necessary.    */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberMinus(decNumber *res, const decNumber *rhs,\r\n                           decContext *set) {\r\n  decNumber dzero;\r\n  uInt status=0;                        // accumulator\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  decNumberZero(&dzero);                // make 0\r\n  dzero.exponent=rhs->exponent;         // [no coefficient expansion]\r\n  decAddOp(res, &dzero, rhs, set, DECNEG, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberMinus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberNextMinus -- next towards -Infinity                       */\r\n/*                                                                    */\r\n/*   This computes C = A - infinitesimal, rounded towards -Infinity   */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* This is a generalization of 754 NextDown.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberNextMinus(decNumber *res, const decNumber *rhs,\r\n                               decContext *set) {\r\n  decNumber dtiny;                           // constant\r\n  decContext workset=*set;                   // work\r\n  uInt status=0;                             // accumulator\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  // +Infinity is the special case\r\n  if ((rhs->bits&(DECINF|DECNEG))==DECINF) {\r\n    decSetMaxValue(res, set);                // is +ve\r\n    // there is no status to set\r\n    return res;\r\n    }\r\n  decNumberZero(&dtiny);                     // start with 0\r\n  dtiny.lsu[0]=1;                            // make number that is ..\r\n  dtiny.exponent=DEC_MIN_EMIN-1;             // .. smaller than tiniest\r\n  workset.round=DEC_ROUND_FLOOR;\r\n  decAddOp(res, rhs, &dtiny, &workset, DECNEG, &status);\r\n  status&=DEC_Invalid_operation|DEC_sNaN;    // only sNaN Invalid please\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberNextMinus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberNextPlus -- next towards +Infinity                        */\r\n/*                                                                    */\r\n/*   This computes C = A + infinitesimal, rounded towards +Infinity   */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* This is a generalization of 754 NextUp.                            */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberNextPlus(decNumber *res, const decNumber *rhs,\r\n                              decContext *set) {\r\n  decNumber dtiny;                           // constant\r\n  decContext workset=*set;                   // work\r\n  uInt status=0;                             // accumulator\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  // -Infinity is the special case\r\n  if ((rhs->bits&(DECINF|DECNEG))==(DECINF|DECNEG)) {\r\n    decSetMaxValue(res, set);\r\n    res->bits=DECNEG;                        // negative\r\n    // there is no status to set\r\n    return res;\r\n    }\r\n  decNumberZero(&dtiny);                     // start with 0\r\n  dtiny.lsu[0]=1;                            // make number that is ..\r\n  dtiny.exponent=DEC_MIN_EMIN-1;             // .. smaller than tiniest\r\n  workset.round=DEC_ROUND_CEILING;\r\n  decAddOp(res, rhs, &dtiny, &workset, 0, &status);\r\n  status&=DEC_Invalid_operation|DEC_sNaN;    // only sNaN Invalid please\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberNextPlus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberNextToward -- next towards rhs                            */\r\n/*                                                                    */\r\n/*   This computes C = A +/- infinitesimal, rounded towards           */\r\n/*   +/-Infinity in the direction of B, as per 754-1985 nextafter     */\r\n/*   modified during revision but dropped from 754-2008.              */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A or B.                          */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* This is a generalization of 754-1985 NextAfter.                    */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberNextToward(decNumber *res, const decNumber *lhs,\r\n                                const decNumber *rhs, decContext *set) {\r\n  decNumber dtiny;                           // constant\r\n  decContext workset=*set;                   // work\r\n  Int result;                                // ..\r\n  uInt status=0;                             // accumulator\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs)) {\r\n    decNaNs(res, lhs, rhs, set, &status);\r\n    }\r\n   else { // Is numeric, so no chance of sNaN Invalid, etc.\r\n    result=decCompare(lhs, rhs, 0);     // sign matters\r\n    if (result==BADINT) status|=DEC_Insufficient_storage; // rare\r\n     else { // valid compare\r\n      if (result==0) decNumberCopySign(res, lhs, rhs); // easy\r\n       else { // differ: need NextPlus or NextMinus\r\n        uByte sub;                      // add or subtract\r\n        if (result<0) {                 // lhs<rhs, do nextplus\r\n          // -Infinity is the special case\r\n          if ((lhs->bits&(DECINF|DECNEG))==(DECINF|DECNEG)) {\r\n            decSetMaxValue(res, set);\r\n            res->bits=DECNEG;           // negative\r\n            return res;                 // there is no status to set\r\n            }\r\n          workset.round=DEC_ROUND_CEILING;\r\n          sub=0;                        // add, please\r\n          } // plus\r\n         else {                         // lhs>rhs, do nextminus\r\n          // +Infinity is the special case\r\n          if ((lhs->bits&(DECINF|DECNEG))==DECINF) {\r\n            decSetMaxValue(res, set);\r\n            return res;                 // there is no status to set\r\n            }\r\n          workset.round=DEC_ROUND_FLOOR;\r\n          sub=DECNEG;                   // subtract, please\r\n          } // minus\r\n        decNumberZero(&dtiny);          // start with 0\r\n        dtiny.lsu[0]=1;                 // make number that is ..\r\n        dtiny.exponent=DEC_MIN_EMIN-1;  // .. smaller than tiniest\r\n        decAddOp(res, lhs, &dtiny, &workset, sub, &status); // + or -\r\n        // turn off exceptions if the result is a normal number\r\n        // (including Nmin), otherwise let all status through\r\n        if (decNumberIsNormal(res, set)) status=0;\r\n        } // unequal\r\n      } // compare OK\r\n    } // numeric\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberNextToward\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberOr -- OR two Numbers, digitwise                           */\r\n/*                                                                    */\r\n/*   This computes C = A | B                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X|X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context (used for result length and error report)     */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Logical function restrictions apply (see above); a NaN is          */\r\n/* returned with Invalid_operation if a restriction is violated.      */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberOr(decNumber *res, const decNumber *lhs,\r\n                        const decNumber *rhs, decContext *set) {\r\n  const Unit *ua, *ub;                  // -> operands\r\n  const Unit *msua, *msub;              // -> operand msus\r\n  Unit  *uc, *msuc;                     // -> result and its msu\r\n  Int   msudigs;                        // digits in res msu\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs)\r\n   || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {\r\n    decStatus(res, DEC_Invalid_operation, set);\r\n    return res;\r\n    }\r\n  // operands are valid\r\n  ua=lhs->lsu;                          // bottom-up\r\n  ub=rhs->lsu;                          // ..\r\n  uc=res->lsu;                          // ..\r\n  msua=ua+D2U(lhs->digits)-1;           // -> msu of lhs\r\n  msub=ub+D2U(rhs->digits)-1;           // -> msu of rhs\r\n  msuc=uc+D2U(set->digits)-1;           // -> msu of result\r\n  msudigs=MSUDIGITS(set->digits);       // [faster than remainder]\r\n  for (; uc<=msuc; ua++, ub++, uc++) {  // Unit loop\r\n    Unit a, b;                          // extract units\r\n    if (ua>msua) a=0;\r\n     else a=*ua;\r\n    if (ub>msub) b=0;\r\n     else b=*ub;\r\n    *uc=0;                              // can now write back\r\n    if (a|b) {                          // maybe 1 bits to examine\r\n      Int i, j;\r\n      // This loop could be unrolled and/or use BIN2BCD tables\r\n      for (i=0; i<DECDPUN; i++) {\r\n        if ((a|b)&1) *uc=*uc+(Unit)powers[i];     // effect OR\r\n        j=a%10;\r\n        a=a/10;\r\n        j|=b%10;\r\n        b=b/10;\r\n        if (j>1) {\r\n          decStatus(res, DEC_Invalid_operation, set);\r\n          return res;\r\n          }\r\n        if (uc==msuc && i==msudigs-1) break;      // just did final digit\r\n        } // each digit\r\n      } // non-zero\r\n    } // each unit\r\n  // [here uc-1 is the msu of the result]\r\n  res->digits=decGetDigits(res->lsu, uc-res->lsu);\r\n  res->exponent=0;                      // integer\r\n  res->bits=0;                          // sign=0\r\n  return res;  // [no status to set]\r\n  } // decNumberOr\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberPlus -- prefix plus operator                              */\r\n/*                                                                    */\r\n/*   This computes C = 0 + A                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* See also decNumberCopy for a quiet bitwise version of this.        */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\n/* This simply uses AddOp; Add will take fast path after preparing A. */\r\n/* Performance is a concern here, as this routine is often used to    */\r\n/* check operands and apply rounding and overflow/underflow testing.  */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberPlus(decNumber *res, const decNumber *rhs,\r\n                          decContext *set) {\r\n  decNumber dzero;\r\n  uInt status=0;                        // accumulator\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  decNumberZero(&dzero);                // make 0\r\n  dzero.exponent=rhs->exponent;         // [no coefficient expansion]\r\n  decAddOp(res, &dzero, rhs, set, 0, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberPlus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberMultiply -- multiply two Numbers                          */\r\n/*                                                                    */\r\n/*   This computes C = A x B                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X+X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberMultiply(decNumber *res, const decNumber *lhs,\r\n                              const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                   // accumulator\r\n  decMultiplyOp(res, lhs, rhs, set, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberMultiply\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberPower -- raise a number to a power                        */\r\n/*                                                                    */\r\n/*   This computes C = A ** B                                         */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X**X)        */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Mathematical function restrictions apply (see above); a NaN is     */\r\n/* returned with Invalid_operation if a restriction is violated.      */\r\n/*                                                                    */\r\n/* However, if 1999999997<=B<=999999999 and B is an integer then the  */\r\n/* restrictions on A and the context are relaxed to the usual bounds, */\r\n/* for compatibility with the earlier (integer power only) version    */\r\n/* of this function.                                                  */\r\n/*                                                                    */\r\n/* When B is an integer, the result may be exact, even if rounded.    */\r\n/*                                                                    */\r\n/* The final result is rounded according to the context; it will      */\r\n/* almost always be correctly rounded, but may be up to 1 ulp in      */\r\n/* error in rare cases.                                               */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberPower(decNumber *res, const decNumber *lhs,\r\n                           const decNumber *rhs, decContext *set) {\r\n  #if DECSUBSET\r\n  decNumber *alloclhs=NULL;        // non-NULL if rounded lhs allocated\r\n  decNumber *allocrhs=NULL;        // .., rhs\r\n  #endif\r\n  decNumber *allocdac=NULL;        // -> allocated acc buffer, iff used\r\n  decNumber *allocinv=NULL;        // -> allocated 1/x buffer, iff used\r\n  Int   reqdigits=set->digits;     // requested DIGITS\r\n  Int   n;                         // rhs in binary\r\n  Flag  rhsint=0;                  // 1 if rhs is an integer\r\n  Flag  useint=0;                  // 1 if can use integer calculation\r\n  Flag  isoddint=0;                // 1 if rhs is an integer and odd\r\n  Int   i;                         // work\r\n  #if DECSUBSET\r\n  Int   dropped;                   // ..\r\n  #endif\r\n  uInt  needbytes;                 // buffer size needed\r\n  Flag  seenbit;                   // seen a bit while powering\r\n  Int   residue=0;                 // rounding residue\r\n  uInt  status=0;                  // accumulators\r\n  uByte bits=0;                    // result sign if errors\r\n  decContext aset;                 // working context\r\n  decNumber dnOne;                 // work value 1...\r\n  // local accumulator buffer [a decNumber, with digits+elength+1 digits]\r\n  decNumber dacbuff[D2N(DECBUFFER+9)];\r\n  decNumber *dac=dacbuff;          // -> result accumulator\r\n  // same again for possible 1/lhs calculation\r\n  decNumber invbuff[D2N(DECBUFFER+9)];\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  do {                             // protect allocated storage\r\n    #if DECSUBSET\r\n    if (!set->extended) { // reduce operands and set status, as needed\r\n      if (lhs->digits>reqdigits) {\r\n        alloclhs=decRoundOperand(lhs, set, &status);\r\n        if (alloclhs==NULL) break;\r\n        lhs=alloclhs;\r\n        }\r\n      if (rhs->digits>reqdigits) {\r\n        allocrhs=decRoundOperand(rhs, set, &status);\r\n        if (allocrhs==NULL) break;\r\n        rhs=allocrhs;\r\n        }\r\n      }\r\n    #endif\r\n    // [following code does not require input rounding]\r\n\r\n    // handle NaNs and rhs Infinity (lhs infinity is harder)\r\n    if (SPECIALARGS) {\r\n      if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs)) { // NaNs\r\n        decNaNs(res, lhs, rhs, set, &status);\r\n        break;}\r\n      if (decNumberIsInfinite(rhs)) {   // rhs Infinity\r\n        Flag rhsneg=rhs->bits&DECNEG;   // save rhs sign\r\n        if (decNumberIsNegative(lhs)    // lhs<0\r\n         && !decNumberIsZero(lhs))      // ..\r\n          status|=DEC_Invalid_operation;\r\n         else {                         // lhs >=0\r\n          decNumberZero(&dnOne);        // set up 1\r\n          dnOne.lsu[0]=1;\r\n          decNumberCompare(dac, lhs, &dnOne, set); // lhs ? 1\r\n          decNumberZero(res);           // prepare for 0/1/Infinity\r\n          if (decNumberIsNegative(dac)) {    // lhs<1\r\n            if (rhsneg) res->bits|=DECINF;   // +Infinity [else is +0]\r\n            }\r\n           else if (dac->lsu[0]==0) {        // lhs=1\r\n            // 1**Infinity is inexact, so return fully-padded 1.0000\r\n            Int shift=set->digits-1;\r\n            *res->lsu=1;                     // was 0, make int 1\r\n            res->digits=decShiftToMost(res->lsu, 1, shift);\r\n            res->exponent=-shift;            // make 1.0000...\r\n            status|=DEC_Inexact|DEC_Rounded; // deemed inexact\r\n            }\r\n           else {                            // lhs>1\r\n            if (!rhsneg) res->bits|=DECINF;  // +Infinity [else is +0]\r\n            }\r\n          } // lhs>=0\r\n        break;}\r\n      // [lhs infinity drops through]\r\n      } // specials\r\n\r\n    // Original rhs may be an integer that fits and is in range\r\n    n=decGetInt(rhs);\r\n    if (n!=BADINT) {                    // it is an integer\r\n      rhsint=1;                         // record the fact for 1**n\r\n      isoddint=(Flag)n&1;               // [works even if big]\r\n      if (n!=BIGEVEN && n!=BIGODD)      // can use integer path?\r\n        useint=1;                       // looks good\r\n      }\r\n\r\n    if (decNumberIsNegative(lhs)        // -x ..\r\n      && isoddint) bits=DECNEG;         // .. to an odd power\r\n\r\n    // handle LHS infinity\r\n    if (decNumberIsInfinite(lhs)) {     // [NaNs already handled]\r\n      uByte rbits=rhs->bits;            // save\r\n      decNumberZero(res);               // prepare\r\n      if (n==0) *res->lsu=1;            // [-]Inf**0 => 1\r\n       else {\r\n        // -Inf**nonint -> error\r\n        if (!rhsint && decNumberIsNegative(lhs)) {\r\n          status|=DEC_Invalid_operation;     // -Inf**nonint is error\r\n          break;}\r\n        if (!(rbits & DECNEG)) bits|=DECINF; // was not a **-n\r\n        // [otherwise will be 0 or -0]\r\n        res->bits=bits;\r\n        }\r\n      break;}\r\n\r\n    // similarly handle LHS zero\r\n    if (decNumberIsZero(lhs)) {\r\n      if (n==0) {                            // 0**0 => Error\r\n        #if DECSUBSET\r\n        if (!set->extended) {                // [unless subset]\r\n          decNumberZero(res);\r\n          *res->lsu=1;                       // return 1\r\n          break;}\r\n        #endif\r\n        status|=DEC_Invalid_operation;\r\n        }\r\n       else {                                // 0**x\r\n        uByte rbits=rhs->bits;               // save\r\n        if (rbits & DECNEG) {                // was a 0**(-n)\r\n          #if DECSUBSET\r\n          if (!set->extended) {              // [bad if subset]\r\n            status|=DEC_Invalid_operation;\r\n            break;}\r\n          #endif\r\n          bits|=DECINF;\r\n          }\r\n        decNumberZero(res);                  // prepare\r\n        // [otherwise will be 0 or -0]\r\n        res->bits=bits;\r\n        }\r\n      break;}\r\n\r\n    // here both lhs and rhs are finite; rhs==0 is handled in the\r\n    // integer path.  Next handle the non-integer cases\r\n    if (!useint) {                      // non-integral rhs\r\n      // any -ve lhs is bad, as is either operand or context out of\r\n      // bounds\r\n      if (decNumberIsNegative(lhs)) {\r\n        status|=DEC_Invalid_operation;\r\n        break;}\r\n      if (decCheckMath(lhs, set, &status)\r\n       || decCheckMath(rhs, set, &status)) break; // variable status\r\n\r\n      decContextDefault(&aset, DEC_INIT_DECIMAL64); // clean context\r\n      aset.emax=DEC_MAX_MATH;           // usual bounds\r\n      aset.emin=-DEC_MAX_MATH;          // ..\r\n      aset.clamp=0;                     // and no concrete format\r\n\r\n      // calculate the result using exp(ln(lhs)*rhs), which can\r\n      // all be done into the accumulator, dac.  The precision needed\r\n      // is enough to contain the full information in the lhs (which\r\n      // is the total digits, including exponent), or the requested\r\n      // precision, if larger, + 4; 6 is used for the exponent\r\n      // maximum length, and this is also used when it is shorter\r\n      // than the requested digits as it greatly reduces the >0.5 ulp\r\n      // cases at little cost (because Ln doubles digits each\r\n      // iteration so a few extra digits rarely causes an extra\r\n      // iteration)\r\n      aset.digits=MAXI(lhs->digits, set->digits)+6+4;\r\n      } // non-integer rhs\r\n\r\n     else { // rhs is in-range integer\r\n      if (n==0) {                       // x**0 = 1\r\n        // (0**0 was handled above)\r\n        decNumberZero(res);             // result=1\r\n        *res->lsu=1;                    // ..\r\n        break;}\r\n      // rhs is a non-zero integer\r\n      if (n<0) n=-n;                    // use abs(n)\r\n\r\n      aset=*set;                        // clone the context\r\n      aset.round=DEC_ROUND_HALF_EVEN;   // internally use balanced\r\n      // calculate the working DIGITS\r\n      aset.digits=reqdigits+(rhs->digits+rhs->exponent)+2;\r\n      #if DECSUBSET\r\n      if (!set->extended) aset.digits--;     // use classic precision\r\n      #endif\r\n      // it's an error if this is more than can be handled\r\n      if (aset.digits>DECNUMMAXP) {status|=DEC_Invalid_operation; break;}\r\n      } // integer path\r\n\r\n    // aset.digits is the count of digits for the accumulator needed\r\n    // if accumulator is too long for local storage, then allocate\r\n    needbytes=sizeof(decNumber)+(D2U(aset.digits)-1)*sizeof(Unit);\r\n    // [needbytes also used below if 1/lhs needed]\r\n    if (needbytes>sizeof(dacbuff)) {\r\n      allocdac=(decNumber *)malloc(needbytes);\r\n      if (allocdac==NULL) {   // hopeless -- abandon\r\n        status|=DEC_Insufficient_storage;\r\n        break;}\r\n      dac=allocdac;           // use the allocated space\r\n      }\r\n    // here, aset is set up and accumulator is ready for use\r\n\r\n    if (!useint) {                           // non-integral rhs\r\n      // x ** y; special-case x=1 here as it will otherwise always\r\n      // reduce to integer 1; decLnOp has a fastpath which detects\r\n      // the case of x=1\r\n      decLnOp(dac, lhs, &aset, &status);     // dac=ln(lhs)\r\n      // [no error possible, as lhs 0 already handled]\r\n      if (ISZERO(dac)) {                     // x==1, 1.0, etc.\r\n        // need to return fully-padded 1.0000 etc., but rhsint->1\r\n        *dac->lsu=1;                         // was 0, make int 1\r\n        if (!rhsint) {                       // add padding\r\n          Int shift=set->digits-1;\r\n          dac->digits=decShiftToMost(dac->lsu, 1, shift);\r\n          dac->exponent=-shift;              // make 1.0000...\r\n          status|=DEC_Inexact|DEC_Rounded;   // deemed inexact\r\n          }\r\n        }\r\n       else {\r\n        decMultiplyOp(dac, dac, rhs, &aset, &status);  // dac=dac*rhs\r\n        decExpOp(dac, dac, &aset, &status);            // dac=exp(dac)\r\n        }\r\n      // and drop through for final rounding\r\n      } // non-integer rhs\r\n\r\n     else {                             // carry on with integer\r\n      decNumberZero(dac);               // acc=1\r\n      *dac->lsu=1;                      // ..\r\n\r\n      // if a negative power the constant 1 is needed, and if not subset\r\n      // invert the lhs now rather than inverting the result later\r\n      if (decNumberIsNegative(rhs)) {   // was a **-n [hence digits>0]\r\n        decNumber *inv=invbuff;         // assume use fixed buffer\r\n        decNumberCopy(&dnOne, dac);     // dnOne=1;  [needed now or later]\r\n        #if DECSUBSET\r\n        if (set->extended) {            // need to calculate 1/lhs\r\n        #endif\r\n          // divide lhs into 1, putting result in dac [dac=1/dac]\r\n          decDivideOp(dac, &dnOne, lhs, &aset, DIVIDE, &status);\r\n          // now locate or allocate space for the inverted lhs\r\n          if (needbytes>sizeof(invbuff)) {\r\n            allocinv=(decNumber *)malloc(needbytes);\r\n            if (allocinv==NULL) {       // hopeless -- abandon\r\n              status|=DEC_Insufficient_storage;\r\n              break;}\r\n            inv=allocinv;               // use the allocated space\r\n            }\r\n          // [inv now points to big-enough buffer or allocated storage]\r\n          decNumberCopy(inv, dac);      // copy the 1/lhs\r\n          decNumberCopy(dac, &dnOne);   // restore acc=1\r\n          lhs=inv;                      // .. and go forward with new lhs\r\n        #if DECSUBSET\r\n          }\r\n        #endif\r\n        }\r\n\r\n      // Raise-to-the-power loop...\r\n      seenbit=0;                   // set once a 1-bit is encountered\r\n      for (i=1;;i++){              // for each bit [top bit ignored]\r\n        // abandon if had overflow or terminal underflow\r\n        if (status & (DEC_Overflow|DEC_Underflow)) { // interesting?\r\n          if (status&DEC_Overflow || ISZERO(dac)) break;\r\n          }\r\n        // [the following two lines revealed an optimizer bug in a C++\r\n        // compiler, with symptom: 5**3 -> 25, when n=n+n was used]\r\n        n=n<<1;                    // move next bit to testable position\r\n        if (n<0) {                 // top bit is set\r\n          seenbit=1;               // OK, significant bit seen\r\n          decMultiplyOp(dac, dac, lhs, &aset, &status); // dac=dac*x\r\n          }\r\n        if (i==31) break;          // that was the last bit\r\n        if (!seenbit) continue;    // no need to square 1\r\n        decMultiplyOp(dac, dac, dac, &aset, &status); // dac=dac*dac [square]\r\n        } /*i*/ // 32 bits\r\n\r\n      // complete internal overflow or underflow processing\r\n      if (status & (DEC_Overflow|DEC_Underflow)) {\r\n        #if DECSUBSET\r\n        // If subset, and power was negative, reverse the kind of -erflow\r\n        // [1/x not yet done]\r\n        if (!set->extended && decNumberIsNegative(rhs)) {\r\n          if (status & DEC_Overflow)\r\n            status^=DEC_Overflow | DEC_Underflow | DEC_Subnormal;\r\n           else { // trickier -- Underflow may or may not be set\r\n            status&=~(DEC_Underflow | DEC_Subnormal); // [one or both]\r\n            status|=DEC_Overflow;\r\n            }\r\n          }\r\n        #endif\r\n        dac->bits=(dac->bits & ~DECNEG) | bits; // force correct sign\r\n        // round subnormals [to set.digits rather than aset.digits]\r\n        // or set overflow result similarly as required\r\n        decFinalize(dac, set, &residue, &status);\r\n        decNumberCopy(res, dac);   // copy to result (is now OK length)\r\n        break;\r\n        }\r\n\r\n      #if DECSUBSET\r\n      if (!set->extended &&                  // subset math\r\n          decNumberIsNegative(rhs)) {        // was a **-n [hence digits>0]\r\n        // so divide result into 1 [dac=1/dac]\r\n        decDivideOp(dac, &dnOne, dac, &aset, DIVIDE, &status);\r\n        }\r\n      #endif\r\n      } // rhs integer path\r\n\r\n    // reduce result to the requested length and copy to result\r\n    decCopyFit(res, dac, set, &residue, &status);\r\n    decFinish(res, set, &residue, &status);  // final cleanup\r\n    #if DECSUBSET\r\n    if (!set->extended) decTrim(res, set, 0, 1, &dropped); // trailing zeros\r\n    #endif\r\n    } while(0);                         // end protected\r\n\r\n  if (allocdac!=NULL) free(allocdac);   // drop any storage used\r\n  if (allocinv!=NULL) free(allocinv);   // ..\r\n  #if DECSUBSET\r\n  if (alloclhs!=NULL) free(alloclhs);   // ..\r\n  if (allocrhs!=NULL) free(allocrhs);   // ..\r\n  #endif\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberPower\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberQuantize -- force exponent to requested value             */\r\n/*                                                                    */\r\n/*   This computes C = op(A, B), where op adjusts the coefficient     */\r\n/*   of C (by rounding or shifting) such that the exponent (-scale)   */\r\n/*   of C has exponent of B.  The numerical value of C will equal A,  */\r\n/*   except for the effects of any rounding that occurred.            */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A or B                           */\r\n/*   lhs is A, the number to adjust                                   */\r\n/*   rhs is B, the number with exponent to match                      */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Unless there is an error or the result is infinite, the exponent   */\r\n/* after the operation is guaranteed to be equal to that of B.        */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberQuantize(decNumber *res, const decNumber *lhs,\r\n                              const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decQuantizeOp(res, lhs, rhs, set, 1, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberQuantize\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberReduce -- remove trailing zeros                           */\r\n/*                                                                    */\r\n/*   This computes C = 0 + A, and normalizes the result               */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\n// Previously known as Normalize\r\ndecNumber * decNumberNormalize(decNumber *res, const decNumber *rhs,\r\n                               decContext *set) {\r\n  return decNumberReduce(res, rhs, set);\r\n  } // decNumberNormalize\r\n\r\ndecNumber * decNumberReduce(decNumber *res, const decNumber *rhs,\r\n                            decContext *set) {\r\n  #if DECSUBSET\r\n  decNumber *allocrhs=NULL;        // non-NULL if rounded rhs allocated\r\n  #endif\r\n  uInt status=0;                   // as usual\r\n  Int  residue=0;                  // as usual\r\n  Int  dropped;                    // work\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  do {                             // protect allocated storage\r\n    #if DECSUBSET\r\n    if (!set->extended) {\r\n      // reduce operand and set lostDigits status, as needed\r\n      if (rhs->digits>set->digits) {\r\n        allocrhs=decRoundOperand(rhs, set, &status);\r\n        if (allocrhs==NULL) break;\r\n        rhs=allocrhs;\r\n        }\r\n      }\r\n    #endif\r\n    // [following code does not require input rounding]\r\n\r\n    // Infinities copy through; NaNs need usual treatment\r\n    if (decNumberIsNaN(rhs)) {\r\n      decNaNs(res, rhs, NULL, set, &status);\r\n      break;\r\n      }\r\n\r\n    // reduce result to the requested length and copy to result\r\n    decCopyFit(res, rhs, set, &residue, &status); // copy & round\r\n    decFinish(res, set, &residue, &status);       // cleanup/set flags\r\n    decTrim(res, set, 1, 0, &dropped);            // normalize in place\r\n                                                  // [may clamp]\r\n    } while(0);                              // end protected\r\n\r\n  #if DECSUBSET\r\n  if (allocrhs !=NULL) free(allocrhs);       // ..\r\n  #endif\r\n  if (status!=0) decStatus(res, status, set);// then report status\r\n  return res;\r\n  } // decNumberReduce\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberRescale -- force exponent to requested value              */\r\n/*                                                                    */\r\n/*   This computes C = op(A, B), where op adjusts the coefficient     */\r\n/*   of C (by rounding or shifting) such that the exponent (-scale)   */\r\n/*   of C has the value B.  The numerical value of C will equal A,    */\r\n/*   except for the effects of any rounding that occurred.            */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A or B                           */\r\n/*   lhs is A, the number to adjust                                   */\r\n/*   rhs is B, the requested exponent                                 */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Unless there is an error or the result is infinite, the exponent   */\r\n/* after the operation is guaranteed to be equal to B.                */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberRescale(decNumber *res, const decNumber *lhs,\r\n                             const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decQuantizeOp(res, lhs, rhs, set, 0, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberRescale\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberRemainder -- divide and return remainder                  */\r\n/*                                                                    */\r\n/*   This computes C = A % B                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X%X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberRemainder(decNumber *res, const decNumber *lhs,\r\n                               const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decDivideOp(res, lhs, rhs, set, REMAINDER, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberRemainder\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberRemainderNear -- divide and return remainder from nearest */\r\n/*                                                                    */\r\n/*   This computes C = A % B, where % is the IEEE remainder operator  */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X%X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberRemainderNear(decNumber *res, const decNumber *lhs,\r\n                                   const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n  decDivideOp(res, lhs, rhs, set, REMNEAR, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberRemainderNear\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberRotate -- rotate the coefficient of a Number left/right   */\r\n/*                                                                    */\r\n/*   This computes C = A rot B  (in base ten and rotating set->digits */\r\n/*   digits).                                                         */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=XrotX)       */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B, the number of digits to rotate (-ve to right)          */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* The digits of the coefficient of A are rotated to the left (if B   */\r\n/* is positive) or to the right (if B is negative) without adjusting  */\r\n/* the exponent or the sign of A.  If lhs->digits is less than        */\r\n/* set->digits the coefficient is padded with zeros on the left       */\r\n/* before the rotate.  Any leading zeros in the result are removed    */\r\n/* as usual.                                                          */\r\n/*                                                                    */\r\n/* B must be an integer (q=0) and in the range -set->digits through   */\r\n/* +set->digits.                                                      */\r\n/* C must have space for set->digits digits.                          */\r\n/* NaNs are propagated as usual.  Infinities are unaffected (but      */\r\n/* B must be valid).  No status is set unless B is invalid or an      */\r\n/* operand is an sNaN.                                                */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberRotate(decNumber *res, const decNumber *lhs,\r\n                           const decNumber *rhs, decContext *set) {\r\n  uInt status=0;              // accumulator\r\n  Int  rotate;                // rhs as an Int\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  // NaNs propagate as normal\r\n  if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs))\r\n    decNaNs(res, lhs, rhs, set, &status);\r\n   // rhs must be an integer\r\n   else if (decNumberIsInfinite(rhs) || rhs->exponent!=0)\r\n    status=DEC_Invalid_operation;\r\n   else { // both numeric, rhs is an integer\r\n    rotate=decGetInt(rhs);                   // [cannot fail]\r\n    if (rotate==BADINT                       // something bad ..\r\n     || rotate==BIGODD || rotate==BIGEVEN    // .. very big ..\r\n     || abs(rotate)>set->digits)             // .. or out of range\r\n      status=DEC_Invalid_operation;\r\n     else {                                  // rhs is OK\r\n      decNumberCopy(res, lhs);\r\n      // convert -ve rotate to equivalent positive rotation\r\n      if (rotate<0) rotate=set->digits+rotate;\r\n      if (rotate!=0 && rotate!=set->digits   // zero or full rotation\r\n       && !decNumberIsInfinite(res)) {       // lhs was infinite\r\n        // left-rotate to do; 0 < rotate < set->digits\r\n        uInt units, shift;                   // work\r\n        uInt msudigits;                      // digits in result msu\r\n        Unit *msu=res->lsu+D2U(res->digits)-1;    // current msu\r\n        Unit *msumax=res->lsu+D2U(set->digits)-1; // rotation msu\r\n        for (msu++; msu<=msumax; msu++) *msu=0;   // ensure high units=0\r\n        res->digits=set->digits;                  // now full-length\r\n        msudigits=MSUDIGITS(res->digits);         // actual digits in msu\r\n\r\n        // rotation here is done in-place, in three steps\r\n        // 1. shift all to least up to one unit to unit-align final\r\n        //    lsd [any digits shifted out are rotated to the left,\r\n        //    abutted to the original msd (which may require split)]\r\n        //\r\n        //    [if there are no whole units left to rotate, the\r\n        //    rotation is now complete]\r\n        //\r\n        // 2. shift to least, from below the split point only, so that\r\n        //    the final msd is in the right place in its Unit [any\r\n        //    digits shifted out will fit exactly in the current msu,\r\n        //    left aligned, no split required]\r\n        //\r\n        // 3. rotate all the units by reversing left part, right\r\n        //    part, and then whole\r\n        //\r\n        // example: rotate right 8 digits (2 units + 2), DECDPUN=3.\r\n        //\r\n        //   start: 00a bcd efg hij klm npq\r\n        //\r\n        //      1a  000 0ab cde fgh|ijk lmn [pq saved]\r\n        //      1b  00p qab cde fgh|ijk lmn\r\n        //\r\n        //      2a  00p qab cde fgh|00i jkl [mn saved]\r\n        //      2b  mnp qab cde fgh|00i jkl\r\n        //\r\n        //      3a  fgh cde qab mnp|00i jkl\r\n        //      3b  fgh cde qab mnp|jkl 00i\r\n        //      3c  00i jkl mnp qab cde fgh\r\n\r\n        // Step 1: amount to shift is the partial right-rotate count\r\n        rotate=set->digits-rotate;      // make it right-rotate\r\n        units=rotate/DECDPUN;           // whole units to rotate\r\n        shift=rotate%DECDPUN;           // left-over digits count\r\n        if (shift>0) {                  // not an exact number of units\r\n          uInt save=res->lsu[0]%powers[shift];    // save low digit(s)\r\n          decShiftToLeast(res->lsu, D2U(res->digits), shift);\r\n          if (shift>msudigits) {        // msumax-1 needs >0 digits\r\n            uInt rem=save%powers[shift-msudigits];// split save\r\n            *msumax=(Unit)(save/powers[shift-msudigits]); // and insert\r\n            *(msumax-1)=*(msumax-1)\r\n                       +(Unit)(rem*powers[DECDPUN-(shift-msudigits)]); // ..\r\n            }\r\n           else { // all fits in msumax\r\n            *msumax=*msumax+(Unit)(save*powers[msudigits-shift]); // [maybe *1]\r\n            }\r\n          } // digits shift needed\r\n\r\n        // If whole units to rotate...\r\n        if (units>0) {                  // some to do\r\n          // Step 2: the units to touch are the whole ones in rotate,\r\n          //   if any, and the shift is DECDPUN-msudigits (which may be\r\n          //   0, again)\r\n          shift=DECDPUN-msudigits;\r\n          if (shift>0) {                // not an exact number of units\r\n            uInt save=res->lsu[0]%powers[shift];  // save low digit(s)\r\n            decShiftToLeast(res->lsu, units, shift);\r\n            *msumax=*msumax+(Unit)(save*powers[msudigits]);\r\n            } // partial shift needed\r\n\r\n          // Step 3: rotate the units array using triple reverse\r\n          // (reversing is easy and fast)\r\n          decReverse(res->lsu+units, msumax);     // left part\r\n          decReverse(res->lsu, res->lsu+units-1); // right part\r\n          decReverse(res->lsu, msumax);           // whole\r\n          } // whole units to rotate\r\n        // the rotation may have left an undetermined number of zeros\r\n        // on the left, so true length needs to be calculated\r\n        res->digits=decGetDigits(res->lsu, msumax-res->lsu+1);\r\n        } // rotate needed\r\n      } // rhs OK\r\n    } // numerics\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberRotate\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberSameQuantum -- test for equal exponents                   */\r\n/*                                                                    */\r\n/*   res is the result number, which will contain either 0 or 1       */\r\n/*   lhs is a number to test                                          */\r\n/*   rhs is the second (usually a pattern)                            */\r\n/*                                                                    */\r\n/* No errors are possible and no context is needed.                   */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberSameQuantum(decNumber *res, const decNumber *lhs,\r\n                                 const decNumber *rhs) {\r\n  Unit ret=0;                      // return value\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, DECUNCONT)) return res;\r\n  #endif\r\n\r\n  if (SPECIALARGS) {\r\n    if (decNumberIsNaN(lhs) && decNumberIsNaN(rhs)) ret=1;\r\n     else if (decNumberIsInfinite(lhs) && decNumberIsInfinite(rhs)) ret=1;\r\n     // [anything else with a special gives 0]\r\n    }\r\n   else if (lhs->exponent==rhs->exponent) ret=1;\r\n\r\n  decNumberZero(res);              // OK to overwrite an operand now\r\n  *res->lsu=ret;\r\n  return res;\r\n  } // decNumberSameQuantum\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberScaleB -- multiply by a power of 10                       */\r\n/*                                                                    */\r\n/* This computes C = A x 10**B where B is an integer (q=0) with       */\r\n/* maximum magnitude 2*(emax+digits)                                  */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A or B                           */\r\n/*   lhs is A, the number to adjust                                   */\r\n/*   rhs is B, the requested power of ten to use                      */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* The result may underflow or overflow.                              */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberScaleB(decNumber *res, const decNumber *lhs,\r\n                            const decNumber *rhs, decContext *set) {\r\n  Int  reqexp;                // requested exponent change [B]\r\n  uInt status=0;              // accumulator\r\n  Int  residue;               // work\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  // Handle special values except lhs infinite\r\n  if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs))\r\n    decNaNs(res, lhs, rhs, set, &status);\r\n    // rhs must be an integer\r\n   else if (decNumberIsInfinite(rhs) || rhs->exponent!=0)\r\n    status=DEC_Invalid_operation;\r\n   else {\r\n    // lhs is a number; rhs is a finite with q==0\r\n    reqexp=decGetInt(rhs);                   // [cannot fail]\r\n    // maximum range is larger than getInt can handle, so this is\r\n    // more restrictive than the specification\r\n    if (reqexp==BADINT                       // something bad ..\r\n     || reqexp==BIGODD || reqexp==BIGEVEN    // it was huge\r\n     || (abs(reqexp)+1)/2>(set->digits+set->emax)) // .. or out of range\r\n      status=DEC_Invalid_operation;\r\n     else {                                  // rhs is OK\r\n      decNumberCopy(res, lhs);               // all done if infinite lhs\r\n      if (!decNumberIsInfinite(res)) {       // prepare to scale\r\n        Int exp=res->exponent;               // save for overflow test\r\n        res->exponent+=reqexp;               // adjust the exponent\r\n        if (((exp^reqexp)>=0)                // same sign ...\r\n         && ((exp^res->exponent)<0)) {       // .. but result had different\r\n          // the calculation overflowed, so force right treatment\r\n          if (exp<0) res->exponent=DEC_MIN_EMIN-DEC_MAX_DIGITS;\r\n           else      res->exponent=DEC_MAX_EMAX+1;\r\n          }\r\n        residue=0;\r\n        decFinalize(res, set, &residue, &status); // final check\r\n        } // finite LHS\r\n      } // rhs OK\r\n    } // rhs finite\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberScaleB\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberShift -- shift the coefficient of a Number left or right  */\r\n/*                                                                    */\r\n/*   This computes C = A << B or C = A >> -B  (in base ten).          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X<<X)        */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B, the number of digits to shift (-ve to right)           */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* The digits of the coefficient of A are shifted to the left (if B   */\r\n/* is positive) or to the right (if B is negative) without adjusting  */\r\n/* the exponent or the sign of A.                                     */\r\n/*                                                                    */\r\n/* B must be an integer (q=0) and in the range -set->digits through   */\r\n/* +set->digits.                                                      */\r\n/* C must have space for set->digits digits.                          */\r\n/* NaNs are propagated as usual.  Infinities are unaffected (but      */\r\n/* B must be valid).  No status is set unless B is invalid or an      */\r\n/* operand is an sNaN.                                                */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberShift(decNumber *res, const decNumber *lhs,\r\n                           const decNumber *rhs, decContext *set) {\r\n  uInt status=0;              // accumulator\r\n  Int  shift;                 // rhs as an Int\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  // NaNs propagate as normal\r\n  if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs))\r\n    decNaNs(res, lhs, rhs, set, &status);\r\n   // rhs must be an integer\r\n   else if (decNumberIsInfinite(rhs) || rhs->exponent!=0)\r\n    status=DEC_Invalid_operation;\r\n   else { // both numeric, rhs is an integer\r\n    shift=decGetInt(rhs);                    // [cannot fail]\r\n    if (shift==BADINT                        // something bad ..\r\n     || shift==BIGODD || shift==BIGEVEN      // .. very big ..\r\n     || abs(shift)>set->digits)              // .. or out of range\r\n      status=DEC_Invalid_operation;\r\n     else {                                  // rhs is OK\r\n      decNumberCopy(res, lhs);\r\n      if (shift!=0 && !decNumberIsInfinite(res)) { // something to do\r\n        if (shift>0) {                       // to left\r\n          if (shift==set->digits) {          // removing all\r\n            *res->lsu=0;                     // so place 0\r\n            res->digits=1;                   // ..\r\n            }\r\n           else {                            //\r\n            // first remove leading digits if necessary\r\n            if (res->digits+shift>set->digits) {\r\n              decDecap(res, res->digits+shift-set->digits);\r\n              // that updated res->digits; may have gone to 1 (for a\r\n              // single digit or for zero\r\n              }\r\n            if (res->digits>1 || *res->lsu)  // if non-zero..\r\n              res->digits=decShiftToMost(res->lsu, res->digits, shift);\r\n            } // partial left\r\n          } // left\r\n         else { // to right\r\n          if (-shift>=res->digits) {         // discarding all\r\n            *res->lsu=0;                     // so place 0\r\n            res->digits=1;                   // ..\r\n            }\r\n           else {\r\n            decShiftToLeast(res->lsu, D2U(res->digits), -shift);\r\n            res->digits-=(-shift);\r\n            }\r\n          } // to right\r\n        } // non-0 non-Inf shift\r\n      } // rhs OK\r\n    } // numerics\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberShift\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberSquareRoot -- square root operator                        */\r\n/*                                                                    */\r\n/*   This computes C = squareroot(A)                                  */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context; note that rounding mode has no effect        */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\n/* This uses the following varying-precision algorithm in:            */\r\n/*                                                                    */\r\n/*   Properly Rounded Variable Precision Square Root, T. E. Hull and  */\r\n/*   A. Abrham, ACM Transactions on Mathematical Software, Vol 11 #3, */\r\n/*   pp229-237, ACM, September 1985.                                  */\r\n/*                                                                    */\r\n/* The square-root is calculated using Newton's method, after which   */\r\n/* a check is made to ensure the result is correctly rounded.         */\r\n/*                                                                    */\r\n/* % [Reformatted original Numerical Turing source code follows.]     */\r\n/* function sqrt(x : real) : real                                     */\r\n/* % sqrt(x) returns the properly rounded approximation to the square */\r\n/* % root of x, in the precision of the calling environment, or it    */\r\n/* % fails if x < 0.                                                  */\r\n/* % t e hull and a abrham, august, 1984                              */\r\n/* if x <= 0 then                                                     */\r\n/*   if x < 0 then                                                    */\r\n/*     assert false                                                   */\r\n/*   else                                                             */\r\n/*     result 0                                                       */\r\n/*   end if                                                           */\r\n/* end if                                                             */\r\n/* var f := setexp(x, 0)  % fraction part of x   [0.1 <= x < 1]       */\r\n/* var e := getexp(x)     % exponent part of x                        */\r\n/* var approx : real                                                  */\r\n/* if e mod 2 = 0  then                                               */\r\n/*   approx := .259 + .819 * f   % approx to root of f                */\r\n/* else                                                               */\r\n/*   f := f/l0                   % adjustments                        */\r\n/*   e := e + 1                  %   for odd                          */\r\n/*   approx := .0819 + 2.59 * f  %   exponent                         */\r\n/* end if                                                             */\r\n/*                                                                    */\r\n/* var p:= 3                                                          */\r\n/* const maxp := currentprecision + 2                                 */\r\n/* loop                                                               */\r\n/*   p := min(2*p - 2, maxp)     % p = 4,6,10, . . . , maxp           */\r\n/*   precision p                                                      */\r\n/*   approx := .5 * (approx + f/approx)                               */\r\n/*   exit when p = maxp                                               */\r\n/* end loop                                                           */\r\n/*                                                                    */\r\n/* % approx is now within 1 ulp of the properly rounded square root   */\r\n/* % of f; to ensure proper rounding, compare squares of (approx -    */\r\n/* % l/2 ulp) and (approx + l/2 ulp) with f.                          */\r\n/* p := currentprecision                                              */\r\n/* begin                                                              */\r\n/*   precision p + 2                                                  */\r\n/*   const approxsubhalf := approx - setexp(.5, -p)                   */\r\n/*   if mulru(approxsubhalf, approxsubhalf) > f then                  */\r\n/*     approx := approx - setexp(.l, -p + 1)                          */\r\n/*   else                                                             */\r\n/*     const approxaddhalf := approx + setexp(.5, -p)                 */\r\n/*     if mulrd(approxaddhalf, approxaddhalf) < f then                */\r\n/*       approx := approx + setexp(.l, -p + 1)                        */\r\n/*     end if                                                         */\r\n/*   end if                                                           */\r\n/* end                                                                */\r\n/* result setexp(approx, e div 2)  % fix exponent                     */\r\n/* end sqrt                                                           */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberSquareRoot(decNumber *res, const decNumber *rhs,\r\n                                decContext *set) {\r\n  decContext workset, approxset;   // work contexts\r\n  decNumber dzero;                 // used for constant zero\r\n  Int  maxp;                       // largest working precision\r\n  Int  workp;                      // working precision\r\n  Int  residue=0;                  // rounding residue\r\n  uInt status=0, ignore=0;         // status accumulators\r\n  uInt rstatus;                    // ..\r\n  Int  exp;                        // working exponent\r\n  Int  ideal;                      // ideal (preferred) exponent\r\n  Int  needbytes;                  // work\r\n  Int  dropped;                    // ..\r\n\r\n  #if DECSUBSET\r\n  decNumber *allocrhs=NULL;        // non-NULL if rounded rhs allocated\r\n  #endif\r\n  // buffer for f [needs +1 in case DECBUFFER 0]\r\n  decNumber buff[D2N(DECBUFFER+1)];\r\n  // buffer for a [needs +2 to match likely maxp]\r\n  decNumber bufa[D2N(DECBUFFER+2)];\r\n  // buffer for temporary, b [must be same size as a]\r\n  decNumber bufb[D2N(DECBUFFER+2)];\r\n  decNumber *allocbuff=NULL;       // -> allocated buff, iff allocated\r\n  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated\r\n  decNumber *allocbufb=NULL;       // -> allocated bufb, iff allocated\r\n  decNumber *f=buff;               // reduced fraction\r\n  decNumber *a=bufa;               // approximation to result\r\n  decNumber *b=bufb;               // intermediate result\r\n  // buffer for temporary variable, up to 3 digits\r\n  decNumber buft[D2N(3)];\r\n  decNumber *t=buft;               // up-to-3-digit constant or work\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  do {                             // protect allocated storage\r\n    #if DECSUBSET\r\n    if (!set->extended) {\r\n      // reduce operand and set lostDigits status, as needed\r\n      if (rhs->digits>set->digits) {\r\n        allocrhs=decRoundOperand(rhs, set, &status);\r\n        if (allocrhs==NULL) break;\r\n        // [Note: 'f' allocation below could reuse this buffer if\r\n        // used, but as this is rare they are kept separate for clarity.]\r\n        rhs=allocrhs;\r\n        }\r\n      }\r\n    #endif\r\n    // [following code does not require input rounding]\r\n\r\n    // handle infinities and NaNs\r\n    if (SPECIALARG) {\r\n      if (decNumberIsInfinite(rhs)) {         // an infinity\r\n        if (decNumberIsNegative(rhs)) status|=DEC_Invalid_operation;\r\n         else decNumberCopy(res, rhs);        // +Infinity\r\n        }\r\n       else decNaNs(res, rhs, NULL, set, &status); // a NaN\r\n      break;\r\n      }\r\n\r\n    // calculate the ideal (preferred) exponent [floor(exp/2)]\r\n    // [It would be nicer to write: ideal=rhs->exponent>>1, but this\r\n    // generates a compiler warning.  Generated code is the same.]\r\n    ideal=(rhs->exponent&~1)/2;         // target\r\n\r\n    // handle zeros\r\n    if (ISZERO(rhs)) {\r\n      decNumberCopy(res, rhs);          // could be 0 or -0\r\n      res->exponent=ideal;              // use the ideal [safe]\r\n      // use decFinish to clamp any out-of-range exponent, etc.\r\n      decFinish(res, set, &residue, &status);\r\n      break;\r\n      }\r\n\r\n    // any other -x is an oops\r\n    if (decNumberIsNegative(rhs)) {\r\n      status|=DEC_Invalid_operation;\r\n      break;\r\n      }\r\n\r\n    // space is needed for three working variables\r\n    //   f -- the same precision as the RHS, reduced to 0.01->0.99...\r\n    //   a -- Hull's approximation -- precision, when assigned, is\r\n    //        currentprecision+1 or the input argument precision,\r\n    //        whichever is larger (+2 for use as temporary)\r\n    //   b -- intermediate temporary result (same size as a)\r\n    // if any is too long for local storage, then allocate\r\n    workp=MAXI(set->digits+1, rhs->digits);  // actual rounding precision\r\n    workp=MAXI(workp, 7);                    // at least 7 for low cases\r\n    maxp=workp+2;                            // largest working precision\r\n\r\n    needbytes=sizeof(decNumber)+(D2U(rhs->digits)-1)*sizeof(Unit);\r\n    if (needbytes>(Int)sizeof(buff)) {\r\n      allocbuff=(decNumber *)malloc(needbytes);\r\n      if (allocbuff==NULL) {  // hopeless -- abandon\r\n        status|=DEC_Insufficient_storage;\r\n        break;}\r\n      f=allocbuff;            // use the allocated space\r\n      }\r\n    // a and b both need to be able to hold a maxp-length number\r\n    needbytes=sizeof(decNumber)+(D2U(maxp)-1)*sizeof(Unit);\r\n    if (needbytes>(Int)sizeof(bufa)) {            // [same applies to b]\r\n      allocbufa=(decNumber *)malloc(needbytes);\r\n      allocbufb=(decNumber *)malloc(needbytes);\r\n      if (allocbufa==NULL || allocbufb==NULL) {   // hopeless\r\n        status|=DEC_Insufficient_storage;\r\n        break;}\r\n      a=allocbufa;            // use the allocated spaces\r\n      b=allocbufb;            // ..\r\n      }\r\n\r\n    // copy rhs -> f, save exponent, and reduce so 0.1 <= f < 1\r\n    decNumberCopy(f, rhs);\r\n    exp=f->exponent+f->digits;               // adjusted to Hull rules\r\n    f->exponent=-(f->digits);                // to range\r\n\r\n    // set up working context\r\n    decContextDefault(&workset, DEC_INIT_DECIMAL64);\r\n    workset.emax=DEC_MAX_EMAX;\r\n    workset.emin=DEC_MIN_EMIN;\r\n\r\n    // [Until further notice, no error is possible and status bits\r\n    // (Rounded, etc.) should be ignored, not accumulated.]\r\n\r\n    // Calculate initial approximation, and allow for odd exponent\r\n    workset.digits=workp;                    // p for initial calculation\r\n    t->bits=0; t->digits=3;\r\n    a->bits=0; a->digits=3;\r\n    if ((exp & 1)==0) {                      // even exponent\r\n      // Set t=0.259, a=0.819\r\n      t->exponent=-3;\r\n      a->exponent=-3;\r\n      #if DECDPUN>=3\r\n        t->lsu[0]=259;\r\n        a->lsu[0]=819;\r\n      #elif DECDPUN==2\r\n        t->lsu[0]=59; t->lsu[1]=2;\r\n        a->lsu[0]=19; a->lsu[1]=8;\r\n      #else\r\n        t->lsu[0]=9; t->lsu[1]=5; t->lsu[2]=2;\r\n        a->lsu[0]=9; a->lsu[1]=1; a->lsu[2]=8;\r\n      #endif\r\n      }\r\n     else {                                  // odd exponent\r\n      // Set t=0.0819, a=2.59\r\n      f->exponent--;                         // f=f/10\r\n      exp++;                                 // e=e+1\r\n      t->exponent=-4;\r\n      a->exponent=-2;\r\n      #if DECDPUN>=3\r\n        t->lsu[0]=819;\r\n        a->lsu[0]=259;\r\n      #elif DECDPUN==2\r\n        t->lsu[0]=19; t->lsu[1]=8;\r\n        a->lsu[0]=59; a->lsu[1]=2;\r\n      #else\r\n        t->lsu[0]=9; t->lsu[1]=1; t->lsu[2]=8;\r\n        a->lsu[0]=9; a->lsu[1]=5; a->lsu[2]=2;\r\n      #endif\r\n      }\r\n\r\n    decMultiplyOp(a, a, f, &workset, &ignore);    // a=a*f\r\n    decAddOp(a, a, t, &workset, 0, &ignore);      // ..+t\r\n    // [a is now the initial approximation for sqrt(f), calculated with\r\n    // currentprecision, which is also a's precision.]\r\n\r\n    // the main calculation loop\r\n    decNumberZero(&dzero);                   // make 0\r\n    decNumberZero(t);                        // set t = 0.5\r\n    t->lsu[0]=5;                             // ..\r\n    t->exponent=-1;                          // ..\r\n    workset.digits=3;                        // initial p\r\n    for (; workset.digits<maxp;) {\r\n      // set p to min(2*p - 2, maxp)  [hence 3; or: 4, 6, 10, ... , maxp]\r\n      workset.digits=MINI(workset.digits*2-2, maxp);\r\n      // a = 0.5 * (a + f/a)\r\n      // [calculated at p then rounded to currentprecision]\r\n      decDivideOp(b, f, a, &workset, DIVIDE, &ignore); // b=f/a\r\n      decAddOp(b, b, a, &workset, 0, &ignore);         // b=b+a\r\n      decMultiplyOp(a, b, t, &workset, &ignore);       // a=b*0.5\r\n      } // loop\r\n\r\n    // Here, 0.1 <= a < 1 [Hull], and a has maxp digits\r\n    // now reduce to length, etc.; this needs to be done with a\r\n    // having the correct exponent so as to handle subnormals\r\n    // correctly\r\n    approxset=*set;                          // get emin, emax, etc.\r\n    approxset.round=DEC_ROUND_HALF_EVEN;\r\n    a->exponent+=exp/2;                      // set correct exponent\r\n    rstatus=0;                               // clear status\r\n    residue=0;                               // .. and accumulator\r\n    decCopyFit(a, a, &approxset, &residue, &rstatus);  // reduce (if needed)\r\n    decFinish(a, &approxset, &residue, &rstatus);      // clean and finalize\r\n\r\n    // Overflow was possible if the input exponent was out-of-range,\r\n    // in which case quit\r\n    if (rstatus&DEC_Overflow) {\r\n      status=rstatus;                        // use the status as-is\r\n      decNumberCopy(res, a);                 // copy to result\r\n      break;\r\n      }\r\n\r\n    // Preserve status except Inexact/Rounded\r\n    status|=(rstatus & ~(DEC_Rounded|DEC_Inexact));\r\n\r\n    // Carry out the Hull correction\r\n    a->exponent-=exp/2;                      // back to 0.1->1\r\n\r\n    // a is now at final precision and within 1 ulp of the properly\r\n    // rounded square root of f; to ensure proper rounding, compare\r\n    // squares of (a - l/2 ulp) and (a + l/2 ulp) with f.\r\n    // Here workset.digits=maxp and t=0.5, and a->digits determines\r\n    // the ulp\r\n    workset.digits--;                             // maxp-1 is OK now\r\n    t->exponent=-a->digits-1;                     // make 0.5 ulp\r\n    decAddOp(b, a, t, &workset, DECNEG, &ignore); // b = a - 0.5 ulp\r\n    workset.round=DEC_ROUND_UP;\r\n    decMultiplyOp(b, b, b, &workset, &ignore);    // b = mulru(b, b)\r\n    decCompareOp(b, f, b, &workset, COMPARE, &ignore); // b ? f, reversed\r\n    if (decNumberIsNegative(b)) {                 // f < b [i.e., b > f]\r\n      // this is the more common adjustment, though both are rare\r\n      t->exponent++;                              // make 1.0 ulp\r\n      t->lsu[0]=1;                                // ..\r\n      decAddOp(a, a, t, &workset, DECNEG, &ignore); // a = a - 1 ulp\r\n      // assign to approx [round to length]\r\n      approxset.emin-=exp/2;                      // adjust to match a\r\n      approxset.emax-=exp/2;\r\n      decAddOp(a, &dzero, a, &approxset, 0, &ignore);\r\n      }\r\n     else {\r\n      decAddOp(b, a, t, &workset, 0, &ignore);    // b = a + 0.5 ulp\r\n      workset.round=DEC_ROUND_DOWN;\r\n      decMultiplyOp(b, b, b, &workset, &ignore);  // b = mulrd(b, b)\r\n      decCompareOp(b, b, f, &workset, COMPARE, &ignore);   // b ? f\r\n      if (decNumberIsNegative(b)) {               // b < f\r\n        t->exponent++;                            // make 1.0 ulp\r\n        t->lsu[0]=1;                              // ..\r\n        decAddOp(a, a, t, &workset, 0, &ignore);  // a = a + 1 ulp\r\n        // assign to approx [round to length]\r\n        approxset.emin-=exp/2;                    // adjust to match a\r\n        approxset.emax-=exp/2;\r\n        decAddOp(a, &dzero, a, &approxset, 0, &ignore);\r\n        }\r\n      }\r\n    // [no errors are possible in the above, and rounding/inexact during\r\n    // estimation are irrelevant, so status was not accumulated]\r\n\r\n    // Here, 0.1 <= a < 1  (still), so adjust back\r\n    a->exponent+=exp/2;                      // set correct exponent\r\n\r\n    // count droppable zeros [after any subnormal rounding] by\r\n    // trimming a copy\r\n    decNumberCopy(b, a);\r\n    decTrim(b, set, 1, 1, &dropped);         // [drops trailing zeros]\r\n\r\n    // Set Inexact and Rounded.  The answer can only be exact if\r\n    // it is short enough so that squaring it could fit in workp\r\n    // digits, so this is the only (relatively rare) condition that\r\n    // a careful check is needed\r\n    if (b->digits*2-1 > workp) {             // cannot fit\r\n      status|=DEC_Inexact|DEC_Rounded;\r\n      }\r\n     else {                                  // could be exact/unrounded\r\n      uInt mstatus=0;                        // local status\r\n      decMultiplyOp(b, b, b, &workset, &mstatus); // try the multiply\r\n      if (mstatus&DEC_Overflow) {            // result just won't fit\r\n        status|=DEC_Inexact|DEC_Rounded;\r\n        }\r\n       else {                                // plausible\r\n        decCompareOp(t, b, rhs, &workset, COMPARE, &mstatus); // b ? rhs\r\n        if (!ISZERO(t)) status|=DEC_Inexact|DEC_Rounded; // not equal\r\n         else {                              // is Exact\r\n          // here, dropped is the count of trailing zeros in 'a'\r\n          // use closest exponent to ideal...\r\n          Int todrop=ideal-a->exponent;      // most that can be dropped\r\n          if (todrop<0) status|=DEC_Rounded; // ideally would add 0s\r\n           else {                            // unrounded\r\n            // there are some to drop, but emax may not allow all\r\n            Int maxexp=set->emax-set->digits+1;\r\n            Int maxdrop=maxexp-a->exponent;\r\n            if (todrop>maxdrop && set->clamp) { // apply clamping\r\n              todrop=maxdrop;\r\n              status|=DEC_Clamped;\r\n              }\r\n            if (dropped<todrop) {            // clamp to those available\r\n              todrop=dropped;\r\n              status|=DEC_Clamped;\r\n              }\r\n            if (todrop>0) {                  // have some to drop\r\n              decShiftToLeast(a->lsu, D2U(a->digits), todrop);\r\n              a->exponent+=todrop;           // maintain numerical value\r\n              a->digits-=todrop;             // new length\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n\r\n    // double-check Underflow, as perhaps the result could not have\r\n    // been subnormal (initial argument too big), or it is now Exact\r\n    if (status&DEC_Underflow) {\r\n      Int ae=rhs->exponent+rhs->digits-1;    // adjusted exponent\r\n      // check if truly subnormal\r\n      #if DECEXTFLAG                         // DEC_Subnormal too\r\n        if (ae>=set->emin*2) status&=~(DEC_Subnormal|DEC_Underflow);\r\n      #else\r\n        if (ae>=set->emin*2) status&=~DEC_Underflow;\r\n      #endif\r\n      // check if truly inexact\r\n      if (!(status&DEC_Inexact)) status&=~DEC_Underflow;\r\n      }\r\n\r\n    decNumberCopy(res, a);                   // a is now the result\r\n    } while(0);                              // end protected\r\n\r\n  if (allocbuff!=NULL) free(allocbuff);      // drop any storage used\r\n  if (allocbufa!=NULL) free(allocbufa);      // ..\r\n  if (allocbufb!=NULL) free(allocbufb);      // ..\r\n  #if DECSUBSET\r\n  if (allocrhs !=NULL) free(allocrhs);       // ..\r\n  #endif\r\n  if (status!=0) decStatus(res, status, set);// then report status\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberSquareRoot\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberSubtract -- subtract two Numbers                          */\r\n/*                                                                    */\r\n/*   This computes C = A - B                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X-X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberSubtract(decNumber *res, const decNumber *lhs,\r\n                              const decNumber *rhs, decContext *set) {\r\n  uInt status=0;                        // accumulator\r\n\r\n  decAddOp(res, lhs, rhs, set, DECNEG, &status);\r\n  if (status!=0) decStatus(res, status, set);\r\n  #if DECCHECK\r\n  decCheckInexact(res, set);\r\n  #endif\r\n  return res;\r\n  } // decNumberSubtract\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberToIntegralExact -- round-to-integral-value with InExact   */\r\n/* decNumberToIntegralValue -- round-to-integral-value                */\r\n/*                                                                    */\r\n/*   res is the result                                                */\r\n/*   rhs is input number                                              */\r\n/*   set is the context                                               */\r\n/*                                                                    */\r\n/* res must have space for any value of rhs.                          */\r\n/*                                                                    */\r\n/* This implements the IEEE special operators and therefore treats    */\r\n/* special values as valid.  For finite numbers it returns            */\r\n/* rescale(rhs, 0) if rhs->exponent is <0.                            */\r\n/* Otherwise the result is rhs (so no error is possible, except for   */\r\n/* sNaN).                                                             */\r\n/*                                                                    */\r\n/* The context is used for rounding mode and status after sNaN, but   */\r\n/* the digits setting is ignored.  The Exact version will signal      */\r\n/* Inexact if the result differs numerically from rhs; the other      */\r\n/* never signals Inexact.                                             */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberToIntegralExact(decNumber *res, const decNumber *rhs,\r\n                                     decContext *set) {\r\n  decNumber dn;\r\n  decContext workset;              // working context\r\n  uInt status=0;                   // accumulator\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  // handle infinities and NaNs\r\n  if (SPECIALARG) {\r\n    if (decNumberIsInfinite(rhs)) decNumberCopy(res, rhs); // an Infinity\r\n     else decNaNs(res, rhs, NULL, set, &status); // a NaN\r\n    }\r\n   else { // finite\r\n    // have a finite number; no error possible (res must be big enough)\r\n    if (rhs->exponent>=0) return decNumberCopy(res, rhs);\r\n    // that was easy, but if negative exponent there is work to do...\r\n    workset=*set;                  // clone rounding, etc.\r\n    workset.digits=rhs->digits;    // no length rounding\r\n    workset.traps=0;               // no traps\r\n    decNumberZero(&dn);            // make a number with exponent 0\r\n    decNumberQuantize(res, rhs, &dn, &workset);\r\n    status|=workset.status;\r\n    }\r\n  if (status!=0) decStatus(res, status, set);\r\n  return res;\r\n  } // decNumberToIntegralExact\r\n\r\ndecNumber * decNumberToIntegralValue(decNumber *res, const decNumber *rhs,\r\n                                     decContext *set) {\r\n  decContext workset=*set;         // working context\r\n  workset.traps=0;                 // no traps\r\n  decNumberToIntegralExact(res, rhs, &workset);\r\n  // this never affects set, except for sNaNs; NaN will have been set\r\n  // or propagated already, so no need to call decStatus\r\n  set->status|=workset.status&DEC_Invalid_operation;\r\n  return res;\r\n  } // decNumberToIntegralValue\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberXor -- XOR two Numbers, digitwise                         */\r\n/*                                                                    */\r\n/*   This computes C = A ^ B                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X^X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context (used for result length and error report)     */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Logical function restrictions apply (see above); a NaN is          */\r\n/* returned with Invalid_operation if a restriction is violated.      */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberXor(decNumber *res, const decNumber *lhs,\r\n                         const decNumber *rhs, decContext *set) {\r\n  const Unit *ua, *ub;                  // -> operands\r\n  const Unit *msua, *msub;              // -> operand msus\r\n  Unit  *uc, *msuc;                     // -> result and its msu\r\n  Int   msudigs;                        // digits in res msu\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs)\r\n   || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {\r\n    decStatus(res, DEC_Invalid_operation, set);\r\n    return res;\r\n    }\r\n  // operands are valid\r\n  ua=lhs->lsu;                          // bottom-up\r\n  ub=rhs->lsu;                          // ..\r\n  uc=res->lsu;                          // ..\r\n  msua=ua+D2U(lhs->digits)-1;           // -> msu of lhs\r\n  msub=ub+D2U(rhs->digits)-1;           // -> msu of rhs\r\n  msuc=uc+D2U(set->digits)-1;           // -> msu of result\r\n  msudigs=MSUDIGITS(set->digits);       // [faster than remainder]\r\n  for (; uc<=msuc; ua++, ub++, uc++) {  // Unit loop\r\n    Unit a, b;                          // extract units\r\n    if (ua>msua) a=0;\r\n     else a=*ua;\r\n    if (ub>msub) b=0;\r\n     else b=*ub;\r\n    *uc=0;                              // can now write back\r\n    if (a|b) {                          // maybe 1 bits to examine\r\n      Int i, j;\r\n      // This loop could be unrolled and/or use BIN2BCD tables\r\n      for (i=0; i<DECDPUN; i++) {\r\n        if ((a^b)&1) *uc=*uc+(Unit)powers[i];     // effect XOR\r\n        j=a%10;\r\n        a=a/10;\r\n        j|=b%10;\r\n        b=b/10;\r\n        if (j>1) {\r\n          decStatus(res, DEC_Invalid_operation, set);\r\n          return res;\r\n          }\r\n        if (uc==msuc && i==msudigs-1) break;      // just did final digit\r\n        } // each digit\r\n      } // non-zero\r\n    } // each unit\r\n  // [here uc-1 is the msu of the result]\r\n  res->digits=decGetDigits(res->lsu, uc-res->lsu);\r\n  res->exponent=0;                      // integer\r\n  res->bits=0;                          // sign=0\r\n  return res;  // [no status to set]\r\n  } // decNumberXor\r\n\r\n\r\n/* ================================================================== */\r\n/* Utility routines                                                   */\r\n/* ================================================================== */\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberClass -- return the decClass of a decNumber               */\r\n/*   dn -- the decNumber to test                                      */\r\n/*   set -- the context to use for Emin                               */\r\n/*   returns the decClass enum                                        */\r\n/* ------------------------------------------------------------------ */\r\nenum decClass decNumberClass(const decNumber *dn, decContext *set) {\r\n  if (decNumberIsSpecial(dn)) {\r\n    if (decNumberIsQNaN(dn)) return DEC_CLASS_QNAN;\r\n    if (decNumberIsSNaN(dn)) return DEC_CLASS_SNAN;\r\n    // must be an infinity\r\n    if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_INF;\r\n    return DEC_CLASS_POS_INF;\r\n    }\r\n  // is finite\r\n  if (decNumberIsNormal(dn, set)) { // most common\r\n    if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_NORMAL;\r\n    return DEC_CLASS_POS_NORMAL;\r\n    }\r\n  // is subnormal or zero\r\n  if (decNumberIsZero(dn)) {    // most common\r\n    if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_ZERO;\r\n    return DEC_CLASS_POS_ZERO;\r\n    }\r\n  if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_SUBNORMAL;\r\n  return DEC_CLASS_POS_SUBNORMAL;\r\n  } // decNumberClass\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberClassToString -- convert decClass to a string             */\r\n/*                                                                    */\r\n/*  eclass is a valid decClass                                        */\r\n/*  returns a constant string describing the class (max 13+1 chars)   */\r\n/* ------------------------------------------------------------------ */\r\nconst char *decNumberClassToString(enum decClass eclass) {\r\n  if (eclass==DEC_CLASS_POS_NORMAL)    return DEC_ClassString_PN;\r\n  if (eclass==DEC_CLASS_NEG_NORMAL)    return DEC_ClassString_NN;\r\n  if (eclass==DEC_CLASS_POS_ZERO)      return DEC_ClassString_PZ;\r\n  if (eclass==DEC_CLASS_NEG_ZERO)      return DEC_ClassString_NZ;\r\n  if (eclass==DEC_CLASS_POS_SUBNORMAL) return DEC_ClassString_PS;\r\n  if (eclass==DEC_CLASS_NEG_SUBNORMAL) return DEC_ClassString_NS;\r\n  if (eclass==DEC_CLASS_POS_INF)       return DEC_ClassString_PI;\r\n  if (eclass==DEC_CLASS_NEG_INF)       return DEC_ClassString_NI;\r\n  if (eclass==DEC_CLASS_QNAN)          return DEC_ClassString_QN;\r\n  if (eclass==DEC_CLASS_SNAN)          return DEC_ClassString_SN;\r\n  return DEC_ClassString_UN;           // Unknown\r\n  } // decNumberClassToString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberCopy -- copy a number                                     */\r\n/*                                                                    */\r\n/*   dest is the target decNumber                                     */\r\n/*   src  is the source decNumber                                     */\r\n/*   returns dest                                                     */\r\n/*                                                                    */\r\n/* (dest==src is allowed and is a no-op)                              */\r\n/* All fields are updated as required.  This is a utility operation,  */\r\n/* so special values are unchanged and no error is possible.          */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberCopy(decNumber *dest, const decNumber *src) {\r\n\r\n  #if DECCHECK\r\n  if (src==NULL) return decNumberZero(dest);\r\n  #endif\r\n\r\n  if (dest==src) return dest;                // no copy required\r\n\r\n  // Use explicit assignments here as structure assignment could copy\r\n  // more than just the lsu (for small DECDPUN).  This would not affect\r\n  // the value of the results, but could disturb test harness spill\r\n  // checking.\r\n  dest->bits=src->bits;\r\n  dest->exponent=src->exponent;\r\n  dest->digits=src->digits;\r\n  dest->lsu[0]=src->lsu[0];\r\n  if (src->digits>DECDPUN) {                 // more Units to come\r\n    const Unit *smsup, *s;                   // work\r\n    Unit  *d;                                // ..\r\n    // memcpy for the remaining Units would be safe as they cannot\r\n    // overlap.  However, this explicit loop is faster in short cases.\r\n    d=dest->lsu+1;                           // -> first destination\r\n    smsup=src->lsu+D2U(src->digits);         // -> source msu+1\r\n    for (s=src->lsu+1; s<smsup; s++, d++) *d=*s;\r\n    }\r\n  return dest;\r\n  } // decNumberCopy\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberCopyAbs -- quiet absolute value operator                  */\r\n/*                                                                    */\r\n/*   This sets C = abs(A)                                             */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* No exception or error can occur; this is a quiet bitwise operation.*/\r\n/* See also decNumberAbs for a checking version of this.              */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberCopyAbs(decNumber *res, const decNumber *rhs) {\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, DECUNCONT)) return res;\r\n  #endif\r\n  decNumberCopy(res, rhs);\r\n  res->bits&=~DECNEG;                   // turn off sign\r\n  return res;\r\n  } // decNumberCopyAbs\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberCopyNegate -- quiet negate value operator                 */\r\n/*                                                                    */\r\n/*   This sets C = negate(A)                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* No exception or error can occur; this is a quiet bitwise operation.*/\r\n/* See also decNumberMinus for a checking version of this.            */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberCopyNegate(decNumber *res, const decNumber *rhs) {\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, DECUNCONT)) return res;\r\n  #endif\r\n  decNumberCopy(res, rhs);\r\n  res->bits^=DECNEG;                    // invert the sign\r\n  return res;\r\n  } // decNumberCopyNegate\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberCopySign -- quiet copy and set sign operator              */\r\n/*                                                                    */\r\n/*   This sets C = A with the sign of B                               */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* No exception or error can occur; this is a quiet bitwise operation.*/\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberCopySign(decNumber *res, const decNumber *lhs,\r\n                              const decNumber *rhs) {\r\n  uByte sign;                           // rhs sign\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, DECUNUSED, rhs, DECUNCONT)) return res;\r\n  #endif\r\n  sign=rhs->bits & DECNEG;              // save sign bit\r\n  decNumberCopy(res, lhs);\r\n  res->bits&=~DECNEG;                   // clear the sign\r\n  res->bits|=sign;                      // set from rhs\r\n  return res;\r\n  } // decNumberCopySign\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberGetBCD -- get the coefficient in BCD8                     */\r\n/*   dn is the source decNumber                                       */\r\n/*   bcd is the uInt array that will receive dn->digits BCD bytes,    */\r\n/*     most-significant at offset 0                                   */\r\n/*   returns bcd                                                      */\r\n/*                                                                    */\r\n/* bcd must have at least dn->digits bytes.  No error is possible; if */\r\n/* dn is a NaN or Infinite, digits must be 1 and the coefficient 0.   */\r\n/* ------------------------------------------------------------------ */\r\nuByte * decNumberGetBCD(const decNumber *dn, uByte *bcd) {\r\n  uByte *ub=bcd+dn->digits-1;      // -> lsd\r\n  const Unit *up=dn->lsu;          // Unit pointer, -> lsu\r\n\r\n  #if DECDPUN==1                   // trivial simple copy\r\n    for (; ub>=bcd; ub--, up++) *ub=*up;\r\n  #else                            // chopping needed\r\n    uInt u=*up;                    // work\r\n    uInt cut=DECDPUN;              // downcounter through unit\r\n    for (; ub>=bcd; ub--) {\r\n      *ub=(uByte)(u%10);           // [*6554 trick inhibits, here]\r\n      u=u/10;\r\n      cut--;\r\n      if (cut>0) continue;         // more in this unit\r\n      up++;\r\n      u=*up;\r\n      cut=DECDPUN;\r\n      }\r\n  #endif\r\n  return bcd;\r\n  } // decNumberGetBCD\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberSetBCD -- set (replace) the coefficient from BCD8         */\r\n/*   dn is the target decNumber                                       */\r\n/*   bcd is the uInt array that will source n BCD bytes, most-        */\r\n/*     significant at offset 0                                        */\r\n/*   n is the number of digits in the source BCD array (bcd)          */\r\n/*   returns dn                                                       */\r\n/*                                                                    */\r\n/* dn must have space for at least n digits.  No error is possible;   */\r\n/* if dn is a NaN, or Infinite, or is to become a zero, n must be 1   */\r\n/* and bcd[0] zero.                                                   */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberSetBCD(decNumber *dn, const uByte *bcd, uInt n) {\r\n  Unit *up=dn->lsu+D2U(dn->digits)-1;   // -> msu [target pointer]\r\n  const uByte *ub=bcd;                  // -> source msd\r\n\r\n  #if DECDPUN==1                        // trivial simple copy\r\n    for (; ub<bcd+n; ub++, up--) *up=*ub;\r\n  #else                                 // some assembly needed\r\n    // calculate how many digits in msu, and hence first cut\r\n    Int cut=MSUDIGITS(n);               // [faster than remainder]\r\n    for (;up>=dn->lsu; up--) {          // each Unit from msu\r\n      *up=0;                            // will take <=DECDPUN digits\r\n      for (; cut>0; ub++, cut--) *up=X10(*up)+*ub;\r\n      cut=DECDPUN;                      // next Unit has all digits\r\n      }\r\n  #endif\r\n  dn->digits=n;                         // set digit count\r\n  return dn;\r\n  } // decNumberSetBCD\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberIsNormal -- test normality of a decNumber                 */\r\n/*   dn is the decNumber to test                                      */\r\n/*   set is the context to use for Emin                               */\r\n/*   returns 1 if |dn| is finite and >=Nmin, 0 otherwise              */\r\n/* ------------------------------------------------------------------ */\r\nInt decNumberIsNormal(const decNumber *dn, decContext *set) {\r\n  Int ae;                               // adjusted exponent\r\n  #if DECCHECK\r\n  if (decCheckOperands(DECUNRESU, DECUNUSED, dn, set)) return 0;\r\n  #endif\r\n\r\n  if (decNumberIsSpecial(dn)) return 0; // not finite\r\n  if (decNumberIsZero(dn)) return 0;    // not non-zero\r\n\r\n  ae=dn->exponent+dn->digits-1;         // adjusted exponent\r\n  if (ae<set->emin) return 0;           // is subnormal\r\n  return 1;\r\n  } // decNumberIsNormal\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberIsSubnormal -- test subnormality of a decNumber           */\r\n/*   dn is the decNumber to test                                      */\r\n/*   set is the context to use for Emin                               */\r\n/*   returns 1 if |dn| is finite, non-zero, and <Nmin, 0 otherwise    */\r\n/* ------------------------------------------------------------------ */\r\nInt decNumberIsSubnormal(const decNumber *dn, decContext *set) {\r\n  Int ae;                               // adjusted exponent\r\n  #if DECCHECK\r\n  if (decCheckOperands(DECUNRESU, DECUNUSED, dn, set)) return 0;\r\n  #endif\r\n\r\n  if (decNumberIsSpecial(dn)) return 0; // not finite\r\n  if (decNumberIsZero(dn)) return 0;    // not non-zero\r\n\r\n  ae=dn->exponent+dn->digits-1;         // adjusted exponent\r\n  if (ae<set->emin) return 1;           // is subnormal\r\n  return 0;\r\n  } // decNumberIsSubnormal\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberTrim -- remove insignificant zeros                        */\r\n/*                                                                    */\r\n/*   dn is the number to trim                                         */\r\n/*   returns dn                                                       */\r\n/*                                                                    */\r\n/* All fields are updated as required.  This is a utility operation,  */\r\n/* so special values are unchanged and no error is possible.  The     */\r\n/* zeros are removed unconditionally.                                 */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decNumberTrim(decNumber *dn) {\r\n  Int  dropped;                    // work\r\n  decContext set;                  // ..\r\n  #if DECCHECK\r\n  if (decCheckOperands(DECUNRESU, DECUNUSED, dn, DECUNCONT)) return dn;\r\n  #endif\r\n  decContextDefault(&set, DEC_INIT_BASE);    // clamp=0\r\n  return decTrim(dn, &set, 0, 1, &dropped);\r\n  } // decNumberTrim\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberVersion -- return the name and version of this module     */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\nconst char * decNumberVersion(void) {\r\n  return DECVERSION;\r\n  } // decNumberVersion\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberZero -- set a number to 0                                 */\r\n/*                                                                    */\r\n/*   dn is the number to set, with space for one digit                */\r\n/*   returns dn                                                       */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\n// Memset is not used as it is much slower in some environments.\r\ndecNumber * decNumberZero(decNumber *dn) {\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(dn, DECUNUSED, DECUNUSED, DECUNCONT)) return dn;\r\n  #endif\r\n\r\n  dn->bits=0;\r\n  dn->exponent=0;\r\n  dn->digits=1;\r\n  dn->lsu[0]=0;\r\n  return dn;\r\n  } // decNumberZero\r\n\r\n/* ================================================================== */\r\n/* Local routines                                                     */\r\n/* ================================================================== */\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decToString -- lay out a number into a string                      */\r\n/*                                                                    */\r\n/*   dn     is the number to lay out                                  */\r\n/*   string is where to lay out the number                            */\r\n/*   eng    is 1 if Engineering, 0 if Scientific                      */\r\n/*                                                                    */\r\n/* string must be at least dn->digits+14 characters long              */\r\n/* No error is possible.                                              */\r\n/*                                                                    */\r\n/* Note that this routine can generate a -0 or 0.000.  These are      */\r\n/* never generated in subset to-number or arithmetic, but can occur   */\r\n/* in non-subset arithmetic (e.g., -1*0 or 1.234-1.234).              */\r\n/* ------------------------------------------------------------------ */\r\n// If DECCHECK is enabled the string \"?\" is returned if a number is\r\n// invalid.\r\nstatic void decToString(const decNumber *dn, char *string, Flag eng) {\r\n  Int exp=dn->exponent;       // local copy\r\n  Int e;                      // E-part value\r\n  Int pre;                    // digits before the '.'\r\n  Int cut;                    // for counting digits in a Unit\r\n  char *c=string;             // work [output pointer]\r\n  const Unit *up=dn->lsu+D2U(dn->digits)-1; // -> msu [input pointer]\r\n  uInt u, pow;                // work\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(DECUNRESU, dn, DECUNUSED, DECUNCONT)) {\r\n    strcpy(string, \"?\");\r\n    return;}\r\n  #endif\r\n\r\n  if (decNumberIsNegative(dn)) {   // Negatives get a minus\r\n    *c='-';\r\n    c++;\r\n    }\r\n  if (dn->bits&DECSPECIAL) {       // Is a special value\r\n    if (decNumberIsInfinite(dn)) {\r\n      strcpy(c,   \"Inf\");\r\n      strcpy(c+3, \"inity\");\r\n      return;}\r\n    // a NaN\r\n    if (dn->bits&DECSNAN) {        // signalling NaN\r\n      *c='s';\r\n      c++;\r\n      }\r\n    strcpy(c, \"NaN\");\r\n    c+=3;                          // step past\r\n    // if not a clean non-zero coefficient, that's all there is in a\r\n    // NaN string\r\n    if (exp!=0 || (*dn->lsu==0 && dn->digits==1)) return;\r\n    // [drop through to add integer]\r\n    }\r\n\r\n  // calculate how many digits in msu, and hence first cut\r\n  cut=MSUDIGITS(dn->digits);       // [faster than remainder]\r\n  cut--;                           // power of ten for digit\r\n\r\n  if (exp==0) {                    // simple integer [common fastpath]\r\n    for (;up>=dn->lsu; up--) {     // each Unit from msu\r\n      u=*up;                       // contains DECDPUN digits to lay out\r\n      for (; cut>=0; c++, cut--) TODIGIT(u, cut, c, pow);\r\n      cut=DECDPUN-1;               // next Unit has all digits\r\n      }\r\n    *c='\\0';                       // terminate the string\r\n    return;}\r\n\r\n  /* non-0 exponent -- assume plain form */\r\n  pre=dn->digits+exp;              // digits before '.'\r\n  e=0;                             // no E\r\n  if ((exp>0) || (pre<-5)) {       // need exponential form\r\n    e=exp+dn->digits-1;            // calculate E value\r\n    pre=1;                         // assume one digit before '.'\r\n    if (eng && (e!=0)) {           // engineering: may need to adjust\r\n      Int adj;                     // adjustment\r\n      // The C remainder operator is undefined for negative numbers, so\r\n      // a positive remainder calculation must be used here\r\n      if (e<0) {\r\n        adj=(-e)%3;\r\n        if (adj!=0) adj=3-adj;\r\n        }\r\n       else { // e>0\r\n        adj=e%3;\r\n        }\r\n      e=e-adj;\r\n      // if dealing with zero still produce an exponent which is a\r\n      // multiple of three, as expected, but there will only be the\r\n      // one zero before the E, still.  Otherwise note the padding.\r\n      if (!ISZERO(dn)) pre+=adj;\r\n       else {  // is zero\r\n        if (adj!=0) {              // 0.00Esnn needed\r\n          e=e+3;\r\n          pre=-(2-adj);\r\n          }\r\n        } // zero\r\n      } // eng\r\n    } // need exponent\r\n\r\n  /* lay out the digits of the coefficient, adding 0s and . as needed */\r\n  u=*up;\r\n  if (pre>0) {                     // xxx.xxx or xx00 (engineering) form\r\n    Int n=pre;\r\n    for (; pre>0; pre--, c++, cut--) {\r\n      if (cut<0) {                 // need new Unit\r\n        if (up==dn->lsu) break;    // out of input digits (pre>digits)\r\n        up--;\r\n        cut=DECDPUN-1;\r\n        u=*up;\r\n        }\r\n      TODIGIT(u, cut, c, pow);\r\n      }\r\n    if (n<dn->digits) {            // more to come, after '.'\r\n      *c='.'; c++;\r\n      for (;; c++, cut--) {\r\n        if (cut<0) {               // need new Unit\r\n          if (up==dn->lsu) break;  // out of input digits\r\n          up--;\r\n          cut=DECDPUN-1;\r\n          u=*up;\r\n          }\r\n        TODIGIT(u, cut, c, pow);\r\n        }\r\n      }\r\n     else for (; pre>0; pre--, c++) *c='0'; // 0 padding (for engineering) needed\r\n    }\r\n   else {                          // 0.xxx or 0.000xxx form\r\n    *c='0'; c++;\r\n    *c='.'; c++;\r\n    for (; pre<0; pre++, c++) *c='0';   // add any 0's after '.'\r\n    for (; ; c++, cut--) {\r\n      if (cut<0) {                 // need new Unit\r\n        if (up==dn->lsu) break;    // out of input digits\r\n        up--;\r\n        cut=DECDPUN-1;\r\n        u=*up;\r\n        }\r\n      TODIGIT(u, cut, c, pow);\r\n      }\r\n    }\r\n\r\n  /* Finally add the E-part, if needed.  It will never be 0, has a\r\n     base maximum and minimum of +999999999 through -999999999, but\r\n     could range down to -1999999998 for anormal numbers */\r\n  if (e!=0) {\r\n    Flag had=0;               // 1=had non-zero\r\n    *c='E'; c++;\r\n    *c='+'; c++;              // assume positive\r\n    u=e;                      // ..\r\n    if (e<0) {\r\n      *(c-1)='-';             // oops, need -\r\n      u=-e;                   // uInt, please\r\n      }\r\n    // lay out the exponent [_itoa or equivalent is not ANSI C]\r\n    for (cut=9; cut>=0; cut--) {\r\n      TODIGIT(u, cut, c, pow);\r\n      if (*c=='0' && !had) continue;    // skip leading zeros\r\n      had=1;                            // had non-0\r\n      c++;                              // step for next\r\n      } // cut\r\n    }\r\n  *c='\\0';          // terminate the string (all paths)\r\n  return;\r\n  } // decToString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decAddOp -- add/subtract operation                                 */\r\n/*                                                                    */\r\n/*   This computes C = A + B                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X+X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*   negate is DECNEG if rhs should be negated, or 0 otherwise        */\r\n/*   status accumulates status for the caller                         */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/* Inexact in status must be 0 for correct Exact zero sign in result  */\r\n/* ------------------------------------------------------------------ */\r\n/* If possible, the coefficient is calculated directly into C.        */\r\n/* However, if:                                                       */\r\n/*   -- a digits+1 calculation is needed because the numbers are      */\r\n/*      unaligned and span more than set->digits digits               */\r\n/*   -- a carry to digits+1 digits looks possible                     */\r\n/*   -- C is the same as A or B, and the result would destructively   */\r\n/*      overlap the A or B coefficient                                */\r\n/* then the result must be calculated into a temporary buffer.  In    */\r\n/* this case a local (stack) buffer is used if possible, and only if  */\r\n/* too long for that does malloc become the final resort.             */\r\n/*                                                                    */\r\n/* Misalignment is handled as follows:                                */\r\n/*   Apad: (AExp>BExp) Swap operands and proceed as for BExp>AExp.    */\r\n/*   BPad: Apply the padding by a combination of shifting (whole      */\r\n/*         units) and multiplication (part units).                    */\r\n/*                                                                    */\r\n/* Addition, especially x=x+1, is speed-critical.                     */\r\n/* The static buffer is larger than might be expected to allow for    */\r\n/* calls from higher-level functions (notable exp).                    */\r\n/* ------------------------------------------------------------------ */\r\nstatic decNumber * decAddOp(decNumber *res, const decNumber *lhs,\r\n                            const decNumber *rhs, decContext *set,\r\n                            uByte negate, uInt *status) {\r\n  #if DECSUBSET\r\n  decNumber *alloclhs=NULL;        // non-NULL if rounded lhs allocated\r\n  decNumber *allocrhs=NULL;        // .., rhs\r\n  #endif\r\n  Int   rhsshift;                  // working shift (in Units)\r\n  Int   maxdigits;                 // longest logical length\r\n  Int   mult;                      // multiplier\r\n  Int   residue;                   // rounding accumulator\r\n  uByte bits;                      // result bits\r\n  Flag  diffsign;                  // non-0 if arguments have different sign\r\n  Unit  *acc;                      // accumulator for result\r\n  Unit  accbuff[SD2U(DECBUFFER*2+20)]; // local buffer [*2+20 reduces many\r\n                                   // allocations when called from\r\n                                   // other operations, notable exp]\r\n  Unit  *allocacc=NULL;            // -> allocated acc buffer, iff allocated\r\n  Int   reqdigits=set->digits;     // local copy; requested DIGITS\r\n  Int   padding;                   // work\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  do {                             // protect allocated storage\r\n    #if DECSUBSET\r\n    if (!set->extended) {\r\n      // reduce operands and set lostDigits status, as needed\r\n      if (lhs->digits>reqdigits) {\r\n        alloclhs=decRoundOperand(lhs, set, status);\r\n        if (alloclhs==NULL) break;\r\n        lhs=alloclhs;\r\n        }\r\n      if (rhs->digits>reqdigits) {\r\n        allocrhs=decRoundOperand(rhs, set, status);\r\n        if (allocrhs==NULL) break;\r\n        rhs=allocrhs;\r\n        }\r\n      }\r\n    #endif\r\n    // [following code does not require input rounding]\r\n\r\n    // note whether signs differ [used all paths]\r\n    diffsign=(Flag)((lhs->bits^rhs->bits^negate)&DECNEG);\r\n\r\n    // handle infinities and NaNs\r\n    if (SPECIALARGS) {                  // a special bit set\r\n      if (SPECIALARGS & (DECSNAN | DECNAN))  // a NaN\r\n        decNaNs(res, lhs, rhs, set, status);\r\n       else { // one or two infinities\r\n        if (decNumberIsInfinite(lhs)) { // LHS is infinity\r\n          // two infinities with different signs is invalid\r\n          if (decNumberIsInfinite(rhs) && diffsign) {\r\n            *status|=DEC_Invalid_operation;\r\n            break;\r\n            }\r\n          bits=lhs->bits & DECNEG;      // get sign from LHS\r\n          }\r\n         else bits=(rhs->bits^negate) & DECNEG;// RHS must be Infinity\r\n        bits|=DECINF;\r\n        decNumberZero(res);\r\n        res->bits=bits;                 // set +/- infinity\r\n        } // an infinity\r\n      break;\r\n      }\r\n\r\n    // Quick exit for add 0s; return the non-0, modified as need be\r\n    if (ISZERO(lhs)) {\r\n      Int adjust;                       // work\r\n      Int lexp=lhs->exponent;           // save in case LHS==RES\r\n      bits=lhs->bits;                   // ..\r\n      residue=0;                        // clear accumulator\r\n      decCopyFit(res, rhs, set, &residue, status); // copy (as needed)\r\n      res->bits^=negate;                // flip if rhs was negated\r\n      #if DECSUBSET\r\n      if (set->extended) {              // exponents on zeros count\r\n      #endif\r\n        // exponent will be the lower of the two\r\n        adjust=lexp-res->exponent;      // adjustment needed [if -ve]\r\n        if (ISZERO(res)) {              // both 0: special IEEE 754 rules\r\n          if (adjust<0) res->exponent=lexp;  // set exponent\r\n          // 0-0 gives +0 unless rounding to -infinity, and -0-0 gives -0\r\n          if (diffsign) {\r\n            if (set->round!=DEC_ROUND_FLOOR) res->bits=0;\r\n             else res->bits=DECNEG;     // preserve 0 sign\r\n            }\r\n          }\r\n         else { // non-0 res\r\n          if (adjust<0) {     // 0-padding needed\r\n            if ((res->digits-adjust)>set->digits) {\r\n              adjust=res->digits-set->digits;     // to fit exactly\r\n              *status|=DEC_Rounded;               // [but exact]\r\n              }\r\n            res->digits=decShiftToMost(res->lsu, res->digits, -adjust);\r\n            res->exponent+=adjust;                // set the exponent.\r\n            }\r\n          } // non-0 res\r\n      #if DECSUBSET\r\n        } // extended\r\n      #endif\r\n      decFinish(res, set, &residue, status);      // clean and finalize\r\n      break;}\r\n\r\n    if (ISZERO(rhs)) {                  // [lhs is non-zero]\r\n      Int adjust;                       // work\r\n      Int rexp=rhs->exponent;           // save in case RHS==RES\r\n      bits=rhs->bits;                   // be clean\r\n      residue=0;                        // clear accumulator\r\n      decCopyFit(res, lhs, set, &residue, status); // copy (as needed)\r\n      #if DECSUBSET\r\n      if (set->extended) {              // exponents on zeros count\r\n      #endif\r\n        // exponent will be the lower of the two\r\n        // [0-0 case handled above]\r\n        adjust=rexp-res->exponent;      // adjustment needed [if -ve]\r\n        if (adjust<0) {     // 0-padding needed\r\n          if ((res->digits-adjust)>set->digits) {\r\n            adjust=res->digits-set->digits;     // to fit exactly\r\n            *status|=DEC_Rounded;               // [but exact]\r\n            }\r\n          res->digits=decShiftToMost(res->lsu, res->digits, -adjust);\r\n          res->exponent+=adjust;                // set the exponent.\r\n          }\r\n      #if DECSUBSET\r\n        } // extended\r\n      #endif\r\n      decFinish(res, set, &residue, status);      // clean and finalize\r\n      break;}\r\n\r\n    // [NB: both fastpath and mainpath code below assume these cases\r\n    // (notably 0-0) have already been handled]\r\n\r\n    // calculate the padding needed to align the operands\r\n    padding=rhs->exponent-lhs->exponent;\r\n\r\n    // Fastpath cases where the numbers are aligned and normal, the RHS\r\n    // is all in one unit, no operand rounding is needed, and no carry,\r\n    // lengthening, or borrow is needed\r\n    if (padding==0\r\n        && rhs->digits<=DECDPUN\r\n        && rhs->exponent>=set->emin     // [some normals drop through]\r\n        && rhs->exponent<=set->emax-set->digits+1 // [could clamp]\r\n        && rhs->digits<=reqdigits\r\n        && lhs->digits<=reqdigits) {\r\n      Int partial=*lhs->lsu;\r\n      if (!diffsign) {                  // adding\r\n        partial+=*rhs->lsu;\r\n        if ((partial<=DECDPUNMAX)       // result fits in unit\r\n         && (lhs->digits>=DECDPUN ||    // .. and no digits-count change\r\n             partial<(Int)powers[lhs->digits])) { // ..\r\n          if (res!=lhs) decNumberCopy(res, lhs);  // not in place\r\n          *res->lsu=(Unit)partial;      // [copy could have overwritten RHS]\r\n          break;\r\n          }\r\n        // else drop out for careful add\r\n        }\r\n       else {                           // signs differ\r\n        partial-=*rhs->lsu;\r\n        if (partial>0) { // no borrow needed, and non-0 result\r\n          if (res!=lhs) decNumberCopy(res, lhs);  // not in place\r\n          *res->lsu=(Unit)partial;\r\n          // this could have reduced digits [but result>0]\r\n          res->digits=decGetDigits(res->lsu, D2U(res->digits));\r\n          break;\r\n          }\r\n        // else drop out for careful subtract\r\n        }\r\n      }\r\n\r\n    // Now align (pad) the lhs or rhs so they can be added or\r\n    // subtracted, as necessary.  If one number is much larger than\r\n    // the other (that is, if in plain form there is a least one\r\n    // digit between the lowest digit of one and the highest of the\r\n    // other) padding with up to DIGITS-1 trailing zeros may be\r\n    // needed; then apply rounding (as exotic rounding modes may be\r\n    // affected by the residue).\r\n    rhsshift=0;               // rhs shift to left (padding) in Units\r\n    bits=lhs->bits;           // assume sign is that of LHS\r\n    mult=1;                   // likely multiplier\r\n\r\n    // [if padding==0 the operands are aligned; no padding is needed]\r\n    if (padding!=0) {\r\n      // some padding needed; always pad the RHS, as any required\r\n      // padding can then be effected by a simple combination of\r\n      // shifts and a multiply\r\n      Flag swapped=0;\r\n      if (padding<0) {                  // LHS needs the padding\r\n        const decNumber *t;\r\n        padding=-padding;               // will be +ve\r\n        bits=(uByte)(rhs->bits^negate); // assumed sign is now that of RHS\r\n        t=lhs; lhs=rhs; rhs=t;\r\n        swapped=1;\r\n        }\r\n\r\n      // If, after pad, rhs would be longer than lhs by digits+1 or\r\n      // more then lhs cannot affect the answer, except as a residue,\r\n      // so only need to pad up to a length of DIGITS+1.\r\n      if (rhs->digits+padding > lhs->digits+reqdigits+1) {\r\n        // The RHS is sufficient\r\n        // for residue use the relative sign indication...\r\n        Int shift=reqdigits-rhs->digits;     // left shift needed\r\n        residue=1;                           // residue for rounding\r\n        if (diffsign) residue=-residue;      // signs differ\r\n        // copy, shortening if necessary\r\n        decCopyFit(res, rhs, set, &residue, status);\r\n        // if it was already shorter, then need to pad with zeros\r\n        if (shift>0) {\r\n          res->digits=decShiftToMost(res->lsu, res->digits, shift);\r\n          res->exponent-=shift;              // adjust the exponent.\r\n          }\r\n        // flip the result sign if unswapped and rhs was negated\r\n        if (!swapped) res->bits^=negate;\r\n        decFinish(res, set, &residue, status);    // done\r\n        break;}\r\n\r\n      // LHS digits may affect result\r\n      rhsshift=D2U(padding+1)-1;        // this much by Unit shift ..\r\n      mult=powers[padding-(rhsshift*DECDPUN)]; // .. this by multiplication\r\n      } // padding needed\r\n\r\n    if (diffsign) mult=-mult;           // signs differ\r\n\r\n    // determine the longer operand\r\n    maxdigits=rhs->digits+padding;      // virtual length of RHS\r\n    if (lhs->digits>maxdigits) maxdigits=lhs->digits;\r\n\r\n    // Decide on the result buffer to use; if possible place directly\r\n    // into result.\r\n    acc=res->lsu;                       // assume add direct to result\r\n    // If destructive overlap, or the number is too long, or a carry or\r\n    // borrow to DIGITS+1 might be possible, a buffer must be used.\r\n    // [Might be worth more sophisticated tests when maxdigits==reqdigits]\r\n    if ((maxdigits>=reqdigits)          // is, or could be, too large\r\n     || (res==rhs && rhsshift>0)) {     // destructive overlap\r\n      // buffer needed, choose it; units for maxdigits digits will be\r\n      // needed, +1 Unit for carry or borrow\r\n      Int need=D2U(maxdigits)+1;\r\n      acc=accbuff;                      // assume use local buffer\r\n      if (need*sizeof(Unit)>sizeof(accbuff)) {\r\n        // printf(\"malloc add %ld %ld\\n\", need, sizeof(accbuff));\r\n        allocacc=(Unit *)malloc(need*sizeof(Unit));\r\n        if (allocacc==NULL) {           // hopeless -- abandon\r\n          *status|=DEC_Insufficient_storage;\r\n          break;}\r\n        acc=allocacc;\r\n        }\r\n      }\r\n\r\n    res->bits=(uByte)(bits&DECNEG);     // it's now safe to overwrite..\r\n    res->exponent=lhs->exponent;        // .. operands (even if aliased)\r\n\r\n    #if DECTRACE\r\n      decDumpAr('A', lhs->lsu, D2U(lhs->digits));\r\n      decDumpAr('B', rhs->lsu, D2U(rhs->digits));\r\n      printf(\"  :h: %ld %ld\\n\", rhsshift, mult);\r\n    #endif\r\n\r\n    // add [A+B*m] or subtract [A+B*(-m)]\r\n    res->digits=decUnitAddSub(lhs->lsu, D2U(lhs->digits),\r\n                              rhs->lsu, D2U(rhs->digits),\r\n                              rhsshift, acc, mult)\r\n               *DECDPUN;           // [units -> digits]\r\n    if (res->digits<0) {           // borrowed...\r\n      res->digits=-res->digits;\r\n      res->bits^=DECNEG;           // flip the sign\r\n      }\r\n    #if DECTRACE\r\n      decDumpAr('+', acc, D2U(res->digits));\r\n    #endif\r\n\r\n    // If a buffer was used the result must be copied back, possibly\r\n    // shortening.  (If no buffer was used then the result must have\r\n    // fit, so can't need rounding and residue must be 0.)\r\n    residue=0;                     // clear accumulator\r\n    if (acc!=res->lsu) {\r\n      #if DECSUBSET\r\n      if (set->extended) {         // round from first significant digit\r\n      #endif\r\n        // remove leading zeros that were added due to rounding up to\r\n        // integral Units -- before the test for rounding.\r\n        if (res->digits>reqdigits)\r\n          res->digits=decGetDigits(acc, D2U(res->digits));\r\n        decSetCoeff(res, set, acc, res->digits, &residue, status);\r\n      #if DECSUBSET\r\n        }\r\n       else { // subset arithmetic rounds from original significant digit\r\n        // May have an underestimate.  This only occurs when both\r\n        // numbers fit in DECDPUN digits and are padding with a\r\n        // negative multiple (-10, -100...) and the top digit(s) become\r\n        // 0.  (This only matters when using X3.274 rules where the\r\n        // leading zero could be included in the rounding.)\r\n        if (res->digits<maxdigits) {\r\n          *(acc+D2U(res->digits))=0; // ensure leading 0 is there\r\n          res->digits=maxdigits;\r\n          }\r\n         else {\r\n          // remove leading zeros that added due to rounding up to\r\n          // integral Units (but only those in excess of the original\r\n          // maxdigits length, unless extended) before test for rounding.\r\n          if (res->digits>reqdigits) {\r\n            res->digits=decGetDigits(acc, D2U(res->digits));\r\n            if (res->digits<maxdigits) res->digits=maxdigits;\r\n            }\r\n          }\r\n        decSetCoeff(res, set, acc, res->digits, &residue, status);\r\n        // Now apply rounding if needed before removing leading zeros.\r\n        // This is safe because subnormals are not a possibility\r\n        if (residue!=0) {\r\n          decApplyRound(res, set, residue, status);\r\n          residue=0;                 // did what needed to be done\r\n          }\r\n        } // subset\r\n      #endif\r\n      } // used buffer\r\n\r\n    // strip leading zeros [these were left on in case of subset subtract]\r\n    res->digits=decGetDigits(res->lsu, D2U(res->digits));\r\n\r\n    // apply checks and rounding\r\n    decFinish(res, set, &residue, status);\r\n\r\n    // \"When the sum of two operands with opposite signs is exactly\r\n    // zero, the sign of that sum shall be '+' in all rounding modes\r\n    // except round toward -Infinity, in which mode that sign shall be\r\n    // '-'.\"  [Subset zeros also never have '-', set by decFinish.]\r\n    if (ISZERO(res) && diffsign\r\n     #if DECSUBSET\r\n     && set->extended\r\n     #endif\r\n     && (*status&DEC_Inexact)==0) {\r\n      if (set->round==DEC_ROUND_FLOOR) res->bits|=DECNEG;   // sign -\r\n                                  else res->bits&=~DECNEG;  // sign +\r\n      }\r\n    } while(0);                              // end protected\r\n\r\n  if (allocacc!=NULL) free(allocacc);        // drop any storage used\r\n  #if DECSUBSET\r\n  if (allocrhs!=NULL) free(allocrhs);        // ..\r\n  if (alloclhs!=NULL) free(alloclhs);        // ..\r\n  #endif\r\n  return res;\r\n  } // decAddOp\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decDivideOp -- division operation                                  */\r\n/*                                                                    */\r\n/*  This routine performs the calculations for all four division      */\r\n/*  operators (divide, divideInteger, remainder, remainderNear).      */\r\n/*                                                                    */\r\n/*  C=A op B                                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X/X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*   op  is DIVIDE, DIVIDEINT, REMAINDER, or REMNEAR respectively.    */\r\n/*   status is the usual accumulator                                  */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\n/*   The underlying algorithm of this routine is the same as in the   */\r\n/*   1981 S/370 implementation, that is, non-restoring long division  */\r\n/*   with bi-unit (rather than bi-digit) estimation for each unit     */\r\n/*   multiplier.  In this pseudocode overview, complications for the  */\r\n/*   Remainder operators and division residues for exact rounding are */\r\n/*   omitted for clarity.                                             */\r\n/*                                                                    */\r\n/*     Prepare operands and handle special values                     */\r\n/*     Test for x/0 and then 0/x                                      */\r\n/*     Exp =Exp1 - Exp2                                               */\r\n/*     Exp =Exp +len(var1) -len(var2)                                 */\r\n/*     Sign=Sign1 * Sign2                                             */\r\n/*     Pad accumulator (Var1) to double-length with 0's (pad1)        */\r\n/*     Pad Var2 to same length as Var1                                */\r\n/*     msu2pair/plus=1st 2 or 1 units of var2, +1 to allow for round  */\r\n/*     have=0                                                         */\r\n/*     Do until (have=digits+1 OR residue=0)                          */\r\n/*       if exp<0 then if integer divide/residue then leave           */\r\n/*       this_unit=0                                                  */\r\n/*       Do forever                                                   */\r\n/*          compare numbers                                           */\r\n/*          if <0 then leave inner_loop                               */\r\n/*          if =0 then (* quick exit without subtract *) do           */\r\n/*             this_unit=this_unit+1; output this_unit                */\r\n/*             leave outer_loop; end                                  */\r\n/*          Compare lengths of numbers (mantissae):                   */\r\n/*          If same then tops2=msu2pair -- {units 1&2 of var2}        */\r\n/*                  else tops2=msu2plus -- {0, unit 1 of var2}        */\r\n/*          tops1=first_unit_of_Var1*10**DECDPUN +second_unit_of_var1 */\r\n/*          mult=tops1/tops2  -- Good and safe guess at divisor       */\r\n/*          if mult=0 then mult=1                                     */\r\n/*          this_unit=this_unit+mult                                  */\r\n/*          subtract                                                  */\r\n/*          end inner_loop                                            */\r\n/*        if have\\=0 | this_unit\\=0 then do                           */\r\n/*          output this_unit                                          */\r\n/*          have=have+1; end                                          */\r\n/*        var2=var2/10                                                */\r\n/*        exp=exp-1                                                   */\r\n/*        end outer_loop                                              */\r\n/*     exp=exp+1   -- set the proper exponent                         */\r\n/*     if have=0 then generate answer=0                               */\r\n/*     Return (Result is defined by Var1)                             */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\n/* Two working buffers are needed during the division; one (digits+   */\r\n/* 1) to accumulate the result, and the other (up to 2*digits+1) for  */\r\n/* long subtractions.  These are acc and var1 respectively.           */\r\n/* var1 is a copy of the lhs coefficient, var2 is the rhs coefficient.*/\r\n/* The static buffers may be larger than might be expected to allow   */\r\n/* for calls from higher-level functions (notable exp).                */\r\n/* ------------------------------------------------------------------ */\r\nstatic decNumber * decDivideOp(decNumber *res,\r\n                               const decNumber *lhs, const decNumber *rhs,\r\n                               decContext *set, Flag op, uInt *status) {\r\n  #if DECSUBSET\r\n  decNumber *alloclhs=NULL;        // non-NULL if rounded lhs allocated\r\n  decNumber *allocrhs=NULL;        // .., rhs\r\n  #endif\r\n  Unit  accbuff[SD2U(DECBUFFER+DECDPUN+10)]; // local buffer\r\n  Unit  *acc=accbuff;              // -> accumulator array for result\r\n  Unit  *allocacc=NULL;            // -> allocated buffer, iff allocated\r\n  Unit  *accnext;                  // -> where next digit will go\r\n  Int   acclength;                 // length of acc needed [Units]\r\n  Int   accunits;                  // count of units accumulated\r\n  Int   accdigits;                 // count of digits accumulated\r\n\r\n  Unit  varbuff[SD2U(DECBUFFER*2+DECDPUN)];  // buffer for var1\r\n  Unit  *var1=varbuff;             // -> var1 array for long subtraction\r\n  Unit  *varalloc=NULL;            // -> allocated buffer, iff used\r\n  Unit  *msu1;                     // -> msu of var1\r\n\r\n  const Unit *var2;                // -> var2 array\r\n  const Unit *msu2;                // -> msu of var2\r\n  Int   msu2plus;                  // msu2 plus one [does not vary]\r\n  eInt  msu2pair;                  // msu2 pair plus one [does not vary]\r\n\r\n  Int   var1units, var2units;      // actual lengths\r\n  Int   var2ulen;                  // logical length (units)\r\n  Int   var1initpad=0;             // var1 initial padding (digits)\r\n  Int   maxdigits;                 // longest LHS or required acc length\r\n  Int   mult;                      // multiplier for subtraction\r\n  Unit  thisunit;                  // current unit being accumulated\r\n  Int   residue;                   // for rounding\r\n  Int   reqdigits=set->digits;     // requested DIGITS\r\n  Int   exponent;                  // working exponent\r\n  Int   maxexponent=0;             // DIVIDE maximum exponent if unrounded\r\n  uByte bits;                      // working sign\r\n  Unit  *target;                   // work\r\n  const Unit *source;              // ..\r\n  uInt  const *pow;                // ..\r\n  Int   shift, cut;                // ..\r\n  #if DECSUBSET\r\n  Int   dropped;                   // work\r\n  #endif\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  do {                             // protect allocated storage\r\n    #if DECSUBSET\r\n    if (!set->extended) {\r\n      // reduce operands and set lostDigits status, as needed\r\n      if (lhs->digits>reqdigits) {\r\n        alloclhs=decRoundOperand(lhs, set, status);\r\n        if (alloclhs==NULL) break;\r\n        lhs=alloclhs;\r\n        }\r\n      if (rhs->digits>reqdigits) {\r\n        allocrhs=decRoundOperand(rhs, set, status);\r\n        if (allocrhs==NULL) break;\r\n        rhs=allocrhs;\r\n        }\r\n      }\r\n    #endif\r\n    // [following code does not require input rounding]\r\n\r\n    bits=(lhs->bits^rhs->bits)&DECNEG;  // assumed sign for divisions\r\n\r\n    // handle infinities and NaNs\r\n    if (SPECIALARGS) {                  // a special bit set\r\n      if (SPECIALARGS & (DECSNAN | DECNAN)) { // one or two NaNs\r\n        decNaNs(res, lhs, rhs, set, status);\r\n        break;\r\n        }\r\n      // one or two infinities\r\n      if (decNumberIsInfinite(lhs)) {   // LHS (dividend) is infinite\r\n        if (decNumberIsInfinite(rhs) || // two infinities are invalid ..\r\n            op & (REMAINDER | REMNEAR)) { // as is remainder of infinity\r\n          *status|=DEC_Invalid_operation;\r\n          break;\r\n          }\r\n        // [Note that infinity/0 raises no exceptions]\r\n        decNumberZero(res);\r\n        res->bits=bits|DECINF;          // set +/- infinity\r\n        break;\r\n        }\r\n       else {                           // RHS (divisor) is infinite\r\n        residue=0;\r\n        if (op&(REMAINDER|REMNEAR)) {\r\n          // result is [finished clone of] lhs\r\n          decCopyFit(res, lhs, set, &residue, status);\r\n          }\r\n         else {  // a division\r\n          decNumberZero(res);\r\n          res->bits=bits;               // set +/- zero\r\n          // for DIVIDEINT the exponent is always 0.  For DIVIDE, result\r\n          // is a 0 with infinitely negative exponent, clamped to minimum\r\n          if (op&DIVIDE) {\r\n            res->exponent=set->emin-set->digits+1;\r\n            *status|=DEC_Clamped;\r\n            }\r\n          }\r\n        decFinish(res, set, &residue, status);\r\n        break;\r\n        }\r\n      }\r\n\r\n    // handle 0 rhs (x/0)\r\n    if (ISZERO(rhs)) {                  // x/0 is always exceptional\r\n      if (ISZERO(lhs)) {\r\n        decNumberZero(res);             // [after lhs test]\r\n        *status|=DEC_Division_undefined;// 0/0 will become NaN\r\n        }\r\n       else {\r\n        decNumberZero(res);\r\n        if (op&(REMAINDER|REMNEAR)) *status|=DEC_Invalid_operation;\r\n         else {\r\n          *status|=DEC_Division_by_zero; // x/0\r\n          res->bits=bits|DECINF;         // .. is +/- Infinity\r\n          }\r\n        }\r\n      break;}\r\n\r\n    // handle 0 lhs (0/x)\r\n    if (ISZERO(lhs)) {                  // 0/x [x!=0]\r\n      #if DECSUBSET\r\n      if (!set->extended) decNumberZero(res);\r\n       else {\r\n      #endif\r\n        if (op&DIVIDE) {\r\n          residue=0;\r\n          exponent=lhs->exponent-rhs->exponent; // ideal exponent\r\n          decNumberCopy(res, lhs);      // [zeros always fit]\r\n          res->bits=bits;               // sign as computed\r\n          res->exponent=exponent;       // exponent, too\r\n          decFinalize(res, set, &residue, status);   // check exponent\r\n          }\r\n         else if (op&DIVIDEINT) {\r\n          decNumberZero(res);           // integer 0\r\n          res->bits=bits;               // sign as computed\r\n          }\r\n         else {                         // a remainder\r\n          exponent=rhs->exponent;       // [save in case overwrite]\r\n          decNumberCopy(res, lhs);      // [zeros always fit]\r\n          if (exponent<res->exponent) res->exponent=exponent; // use lower\r\n          }\r\n      #if DECSUBSET\r\n        }\r\n      #endif\r\n      break;}\r\n\r\n    // Precalculate exponent.  This starts off adjusted (and hence fits\r\n    // in 31 bits) and becomes the usual unadjusted exponent as the\r\n    // division proceeds.  The order of evaluation is important, here,\r\n    // to avoid wrap.\r\n    exponent=(lhs->exponent+lhs->digits)-(rhs->exponent+rhs->digits);\r\n\r\n    // If the working exponent is -ve, then some quick exits are\r\n    // possible because the quotient is known to be <1\r\n    // [for REMNEAR, it needs to be < -1, as -0.5 could need work]\r\n    if (exponent<0 && !(op==DIVIDE)) {\r\n      if (op&DIVIDEINT) {\r\n        decNumberZero(res);                  // integer part is 0\r\n        #if DECSUBSET\r\n        if (set->extended)\r\n        #endif\r\n          res->bits=bits;                    // set +/- zero\r\n        break;}\r\n      // fastpath remainders so long as the lhs has the smaller\r\n      // (or equal) exponent\r\n      if (lhs->exponent<=rhs->exponent) {\r\n        if (op&REMAINDER || exponent<-1) {\r\n          // It is REMAINDER or safe REMNEAR; result is [finished\r\n          // clone of] lhs  (r = x - 0*y)\r\n          residue=0;\r\n          decCopyFit(res, lhs, set, &residue, status);\r\n          decFinish(res, set, &residue, status);\r\n          break;\r\n          }\r\n        // [unsafe REMNEAR drops through]\r\n        }\r\n      } // fastpaths\r\n\r\n    /* Long (slow) division is needed; roll up the sleeves... */\r\n\r\n    // The accumulator will hold the quotient of the division.\r\n    // If it needs to be too long for stack storage, then allocate.\r\n    acclength=D2U(reqdigits+DECDPUN);   // in Units\r\n    if (acclength*sizeof(Unit)>sizeof(accbuff)) {\r\n      // printf(\"malloc dvacc %ld units\\n\", acclength);\r\n      allocacc=(Unit *)malloc(acclength*sizeof(Unit));\r\n      if (allocacc==NULL) {             // hopeless -- abandon\r\n        *status|=DEC_Insufficient_storage;\r\n        break;}\r\n      acc=allocacc;                     // use the allocated space\r\n      }\r\n\r\n    // var1 is the padded LHS ready for subtractions.\r\n    // If it needs to be too long for stack storage, then allocate.\r\n    // The maximum units needed for var1 (long subtraction) is:\r\n    // Enough for\r\n    //     (rhs->digits+reqdigits-1) -- to allow full slide to right\r\n    // or  (lhs->digits)             -- to allow for long lhs\r\n    // whichever is larger\r\n    //   +1                -- for rounding of slide to right\r\n    //   +1                -- for leading 0s\r\n    //   +1                -- for pre-adjust if a remainder or DIVIDEINT\r\n    // [Note: unused units do not participate in decUnitAddSub data]\r\n    maxdigits=rhs->digits+reqdigits-1;\r\n    if (lhs->digits>maxdigits) maxdigits=lhs->digits;\r\n    var1units=D2U(maxdigits)+2;\r\n    // allocate a guard unit above msu1 for REMAINDERNEAR\r\n    if (!(op&DIVIDE)) var1units++;\r\n    if ((var1units+1)*sizeof(Unit)>sizeof(varbuff)) {\r\n      // printf(\"malloc dvvar %ld units\\n\", var1units+1);\r\n      varalloc=(Unit *)malloc((var1units+1)*sizeof(Unit));\r\n      if (varalloc==NULL) {             // hopeless -- abandon\r\n        *status|=DEC_Insufficient_storage;\r\n        break;}\r\n      var1=varalloc;                    // use the allocated space\r\n      }\r\n\r\n    // Extend the lhs and rhs to full long subtraction length.  The lhs\r\n    // is truly extended into the var1 buffer, with 0 padding, so a\r\n    // subtract in place is always possible.  The rhs (var2) has\r\n    // virtual padding (implemented by decUnitAddSub).\r\n    // One guard unit was allocated above msu1 for rem=rem+rem in\r\n    // REMAINDERNEAR.\r\n    msu1=var1+var1units-1;              // msu of var1\r\n    source=lhs->lsu+D2U(lhs->digits)-1; // msu of input array\r\n    for (target=msu1; source>=lhs->lsu; source--, target--) *target=*source;\r\n    for (; target>=var1; target--) *target=0;\r\n\r\n    // rhs (var2) is left-aligned with var1 at the start\r\n    var2ulen=var1units;                 // rhs logical length (units)\r\n    var2units=D2U(rhs->digits);         // rhs actual length (units)\r\n    var2=rhs->lsu;                      // -> rhs array\r\n    msu2=var2+var2units-1;              // -> msu of var2 [never changes]\r\n    // now set up the variables which will be used for estimating the\r\n    // multiplication factor.  If these variables are not exact, add\r\n    // 1 to make sure that the multiplier is never overestimated.\r\n    msu2plus=*msu2;                     // it's value ..\r\n    if (var2units>1) msu2plus++;        // .. +1 if any more\r\n    msu2pair=(eInt)*msu2*(DECDPUNMAX+1);// top two pair ..\r\n    if (var2units>1) {                  // .. [else treat 2nd as 0]\r\n      msu2pair+=*(msu2-1);              // ..\r\n      if (var2units>2) msu2pair++;      // .. +1 if any more\r\n      }\r\n\r\n    // The calculation is working in units, which may have leading zeros,\r\n    // but the exponent was calculated on the assumption that they are\r\n    // both left-aligned.  Adjust the exponent to compensate: add the\r\n    // number of leading zeros in var1 msu and subtract those in var2 msu.\r\n    // [This is actually done by counting the digits and negating, as\r\n    // lead1=DECDPUN-digits1, and similarly for lead2.]\r\n    for (pow=&powers[1]; *msu1>=*pow; pow++) exponent--;\r\n    for (pow=&powers[1]; *msu2>=*pow; pow++) exponent++;\r\n\r\n    // Now, if doing an integer divide or remainder, ensure that\r\n    // the result will be Unit-aligned.  To do this, shift the var1\r\n    // accumulator towards least if need be.  (It's much easier to\r\n    // do this now than to reassemble the residue afterwards, if\r\n    // doing a remainder.)  Also ensure the exponent is not negative.\r\n    if (!(op&DIVIDE)) {\r\n      Unit *u;                          // work\r\n      // save the initial 'false' padding of var1, in digits\r\n      var1initpad=(var1units-D2U(lhs->digits))*DECDPUN;\r\n      // Determine the shift to do.\r\n      if (exponent<0) cut=-exponent;\r\n       else cut=DECDPUN-exponent%DECDPUN;\r\n      decShiftToLeast(var1, var1units, cut);\r\n      exponent+=cut;                    // maintain numerical value\r\n      var1initpad-=cut;                 // .. and reduce padding\r\n      // clean any most-significant units which were just emptied\r\n      for (u=msu1; cut>=DECDPUN; cut-=DECDPUN, u--) *u=0;\r\n      } // align\r\n     else { // is DIVIDE\r\n      maxexponent=lhs->exponent-rhs->exponent;    // save\r\n      // optimization: if the first iteration will just produce 0,\r\n      // preadjust to skip it [valid for DIVIDE only]\r\n      if (*msu1<*msu2) {\r\n        var2ulen--;                     // shift down\r\n        exponent-=DECDPUN;              // update the exponent\r\n        }\r\n      }\r\n\r\n    // ---- start the long-division loops ------------------------------\r\n    accunits=0;                         // no units accumulated yet\r\n    accdigits=0;                        // .. or digits\r\n    accnext=acc+acclength-1;            // -> msu of acc [NB: allows digits+1]\r\n    for (;;) {                          // outer forever loop\r\n      thisunit=0;                       // current unit assumed 0\r\n      // find the next unit\r\n      for (;;) {                        // inner forever loop\r\n        // strip leading zero units [from either pre-adjust or from\r\n        // subtract last time around].  Leave at least one unit.\r\n        for (; *msu1==0 && msu1>var1; msu1--) var1units--;\r\n\r\n        if (var1units<var2ulen) break;       // var1 too low for subtract\r\n        if (var1units==var2ulen) {           // unit-by-unit compare needed\r\n          // compare the two numbers, from msu\r\n          const Unit *pv1, *pv2;\r\n          Unit v2;                           // units to compare\r\n          pv2=msu2;                          // -> msu\r\n          for (pv1=msu1; ; pv1--, pv2--) {\r\n            // v1=*pv1 -- always OK\r\n            v2=0;                            // assume in padding\r\n            if (pv2>=var2) v2=*pv2;          // in range\r\n            if (*pv1!=v2) break;             // no longer the same\r\n            if (pv1==var1) break;            // done; leave pv1 as is\r\n            }\r\n          // here when all inspected or a difference seen\r\n          if (*pv1<v2) break;                // var1 too low to subtract\r\n          if (*pv1==v2) {                    // var1 == var2\r\n            // reach here if var1 and var2 are identical; subtraction\r\n            // would increase digit by one, and the residue will be 0 so\r\n            // the calculation is done; leave the loop with residue=0.\r\n            thisunit++;                      // as though subtracted\r\n            *var1=0;                         // set var1 to 0\r\n            var1units=1;                     // ..\r\n            break;  // from inner\r\n            } // var1 == var2\r\n          // *pv1>v2.  Prepare for real subtraction; the lengths are equal\r\n          // Estimate the multiplier (there's always a msu1-1)...\r\n          // Bring in two units of var2 to provide a good estimate.\r\n          mult=(Int)(((eInt)*msu1*(DECDPUNMAX+1)+*(msu1-1))/msu2pair);\r\n          } // lengths the same\r\n         else { // var1units > var2ulen, so subtraction is safe\r\n          // The var2 msu is one unit towards the lsu of the var1 msu,\r\n          // so only one unit for var2 can be used.\r\n          mult=(Int)(((eInt)*msu1*(DECDPUNMAX+1)+*(msu1-1))/msu2plus);\r\n          }\r\n        if (mult==0) mult=1;                 // must always be at least 1\r\n        // subtraction needed; var1 is > var2\r\n        thisunit=(Unit)(thisunit+mult);      // accumulate\r\n        // subtract var1-var2, into var1; only the overlap needs\r\n        // processing, as this is an in-place calculation\r\n        shift=var2ulen-var2units;\r\n        #if DECTRACE\r\n          decDumpAr('1', &var1[shift], var1units-shift);\r\n          decDumpAr('2', var2, var2units);\r\n          printf(\"m=%ld\\n\", -mult);\r\n        #endif\r\n        decUnitAddSub(&var1[shift], var1units-shift,\r\n                      var2, var2units, 0,\r\n                      &var1[shift], -mult);\r\n        #if DECTRACE\r\n          decDumpAr('#', &var1[shift], var1units-shift);\r\n        #endif\r\n        // var1 now probably has leading zeros; these are removed at the\r\n        // top of the inner loop.\r\n        } // inner loop\r\n\r\n      // The next unit has been calculated in full; unless it's a\r\n      // leading zero, add to acc\r\n      if (accunits!=0 || thisunit!=0) {      // is first or non-zero\r\n        *accnext=thisunit;                   // store in accumulator\r\n        // account exactly for the new digits\r\n        if (accunits==0) {\r\n          accdigits++;                       // at least one\r\n          for (pow=&powers[1]; thisunit>=*pow; pow++) accdigits++;\r\n          }\r\n         else accdigits+=DECDPUN;\r\n        accunits++;                          // update count\r\n        accnext--;                           // ready for next\r\n        if (accdigits>reqdigits) break;      // have enough digits\r\n        }\r\n\r\n      // if the residue is zero, the operation is done (unless divide\r\n      // or divideInteger and still not enough digits yet)\r\n      if (*var1==0 && var1units==1) {        // residue is 0\r\n        if (op&(REMAINDER|REMNEAR)) break;\r\n        if ((op&DIVIDE) && (exponent<=maxexponent)) break;\r\n        // [drop through if divideInteger]\r\n        }\r\n      // also done enough if calculating remainder or integer\r\n      // divide and just did the last ('units') unit\r\n      if (exponent==0 && !(op&DIVIDE)) break;\r\n\r\n      // to get here, var1 is less than var2, so divide var2 by the per-\r\n      // Unit power of ten and go for the next digit\r\n      var2ulen--;                            // shift down\r\n      exponent-=DECDPUN;                     // update the exponent\r\n      } // outer loop\r\n\r\n    // ---- division is complete ---------------------------------------\r\n    // here: acc      has at least reqdigits+1 of good results (or fewer\r\n    //                if early stop), starting at accnext+1 (its lsu)\r\n    //       var1     has any residue at the stopping point\r\n    //       accunits is the number of digits collected in acc\r\n    if (accunits==0) {             // acc is 0\r\n      accunits=1;                  // show have a unit ..\r\n      accdigits=1;                 // ..\r\n      *accnext=0;                  // .. whose value is 0\r\n      }\r\n     else accnext++;               // back to last placed\r\n    // accnext now -> lowest unit of result\r\n\r\n    residue=0;                     // assume no residue\r\n    if (op&DIVIDE) {\r\n      // record the presence of any residue, for rounding\r\n      if (*var1!=0 || var1units>1) residue=1;\r\n       else { // no residue\r\n        // Had an exact division; clean up spurious trailing 0s.\r\n        // There will be at most DECDPUN-1, from the final multiply,\r\n        // and then only if the result is non-0 (and even) and the\r\n        // exponent is 'loose'.\r\n        #if DECDPUN>1\r\n        Unit lsu=*accnext;\r\n        if (!(lsu&0x01) && (lsu!=0)) {\r\n          // count the trailing zeros\r\n          Int drop=0;\r\n          for (;; drop++) {    // [will terminate because lsu!=0]\r\n            if (exponent>=maxexponent) break;     // don't chop real 0s\r\n            #if DECDPUN<=4\r\n              if ((lsu-QUOT10(lsu, drop+1)\r\n                  *powers[drop+1])!=0) break;     // found non-0 digit\r\n            #else\r\n              if (lsu%powers[drop+1]!=0) break;   // found non-0 digit\r\n            #endif\r\n            exponent++;\r\n            }\r\n          if (drop>0) {\r\n            accunits=decShiftToLeast(accnext, accunits, drop);\r\n            accdigits=decGetDigits(accnext, accunits);\r\n            accunits=D2U(accdigits);\r\n            // [exponent was adjusted in the loop]\r\n            }\r\n          } // neither odd nor 0\r\n        #endif\r\n        } // exact divide\r\n      } // divide\r\n     else /* op!=DIVIDE */ {\r\n      // check for coefficient overflow\r\n      if (accdigits+exponent>reqdigits) {\r\n        *status|=DEC_Division_impossible;\r\n        break;\r\n        }\r\n      if (op & (REMAINDER|REMNEAR)) {\r\n        // [Here, the exponent will be 0, because var1 was adjusted\r\n        // appropriately.]\r\n        Int postshift;                       // work\r\n        Flag wasodd=0;                       // integer was odd\r\n        Unit *quotlsu;                       // for save\r\n        Int  quotdigits;                     // ..\r\n\r\n        bits=lhs->bits;                      // remainder sign is always as lhs\r\n\r\n        // Fastpath when residue is truly 0 is worthwhile [and\r\n        // simplifies the code below]\r\n        if (*var1==0 && var1units==1) {      // residue is 0\r\n          Int exp=lhs->exponent;             // save min(exponents)\r\n          if (rhs->exponent<exp) exp=rhs->exponent;\r\n          decNumberZero(res);                // 0 coefficient\r\n          #if DECSUBSET\r\n          if (set->extended)\r\n          #endif\r\n          res->exponent=exp;                 // .. with proper exponent\r\n          res->bits=(uByte)(bits&DECNEG);          // [cleaned]\r\n          decFinish(res, set, &residue, status);   // might clamp\r\n          break;\r\n          }\r\n        // note if the quotient was odd\r\n        if (*accnext & 0x01) wasodd=1;       // acc is odd\r\n        quotlsu=accnext;                     // save in case need to reinspect\r\n        quotdigits=accdigits;                // ..\r\n\r\n        // treat the residue, in var1, as the value to return, via acc\r\n        // calculate the unused zero digits.  This is the smaller of:\r\n        //   var1 initial padding (saved above)\r\n        //   var2 residual padding, which happens to be given by:\r\n        postshift=var1initpad+exponent-lhs->exponent+rhs->exponent;\r\n        // [the 'exponent' term accounts for the shifts during divide]\r\n        if (var1initpad<postshift) postshift=var1initpad;\r\n\r\n        // shift var1 the requested amount, and adjust its digits\r\n        var1units=decShiftToLeast(var1, var1units, postshift);\r\n        accnext=var1;\r\n        accdigits=decGetDigits(var1, var1units);\r\n        accunits=D2U(accdigits);\r\n\r\n        exponent=lhs->exponent;         // exponent is smaller of lhs & rhs\r\n        if (rhs->exponent<exponent) exponent=rhs->exponent;\r\n\r\n        // Now correct the result if doing remainderNear; if it\r\n        // (looking just at coefficients) is > rhs/2, or == rhs/2 and\r\n        // the integer was odd then the result should be rem-rhs.\r\n        if (op&REMNEAR) {\r\n          Int compare, tarunits;        // work\r\n          Unit *up;                     // ..\r\n          // calculate remainder*2 into the var1 buffer (which has\r\n          // 'headroom' of an extra unit and hence enough space)\r\n          // [a dedicated 'double' loop would be faster, here]\r\n          tarunits=decUnitAddSub(accnext, accunits, accnext, accunits,\r\n                                 0, accnext, 1);\r\n          // decDumpAr('r', accnext, tarunits);\r\n\r\n          // Here, accnext (var1) holds tarunits Units with twice the\r\n          // remainder's coefficient, which must now be compared to the\r\n          // RHS.  The remainder's exponent may be smaller than the RHS's.\r\n          compare=decUnitCompare(accnext, tarunits, rhs->lsu, D2U(rhs->digits),\r\n                                 rhs->exponent-exponent);\r\n          if (compare==BADINT) {             // deep trouble\r\n            *status|=DEC_Insufficient_storage;\r\n            break;}\r\n\r\n          // now restore the remainder by dividing by two; the lsu\r\n          // is known to be even.\r\n          for (up=accnext; up<accnext+tarunits; up++) {\r\n            Int half;              // half to add to lower unit\r\n            half=*up & 0x01;\r\n            *up/=2;                // [shift]\r\n            if (!half) continue;\r\n            *(up-1)+=(DECDPUNMAX+1)/2;\r\n            }\r\n          // [accunits still describes the original remainder length]\r\n\r\n          if (compare>0 || (compare==0 && wasodd)) { // adjustment needed\r\n            Int exp, expunits, exprem;       // work\r\n            // This is effectively causing round-up of the quotient,\r\n            // so if it was the rare case where it was full and all\r\n            // nines, it would overflow and hence division-impossible\r\n            // should be raised\r\n            Flag allnines=0;                 // 1 if quotient all nines\r\n            if (quotdigits==reqdigits) {     // could be borderline\r\n              for (up=quotlsu; ; up++) {\r\n                if (quotdigits>DECDPUN) {\r\n                  if (*up!=DECDPUNMAX) break;// non-nines\r\n                  }\r\n                 else {                      // this is the last Unit\r\n                  if (*up==powers[quotdigits]-1) allnines=1;\r\n                  break;\r\n                  }\r\n                quotdigits-=DECDPUN;         // checked those digits\r\n                } // up\r\n              } // borderline check\r\n            if (allnines) {\r\n              *status|=DEC_Division_impossible;\r\n              break;}\r\n\r\n            // rem-rhs is needed; the sign will invert.  Again, var1\r\n            // can safely be used for the working Units array.\r\n            exp=rhs->exponent-exponent;      // RHS padding needed\r\n            // Calculate units and remainder from exponent.\r\n            expunits=exp/DECDPUN;\r\n            exprem=exp%DECDPUN;\r\n            // subtract [A+B*(-m)]; the result will always be negative\r\n            accunits=-decUnitAddSub(accnext, accunits,\r\n                                    rhs->lsu, D2U(rhs->digits),\r\n                                    expunits, accnext, -(Int)powers[exprem]);\r\n            accdigits=decGetDigits(accnext, accunits); // count digits exactly\r\n            accunits=D2U(accdigits);    // and recalculate the units for copy\r\n            // [exponent is as for original remainder]\r\n            bits^=DECNEG;               // flip the sign\r\n            }\r\n          } // REMNEAR\r\n        } // REMAINDER or REMNEAR\r\n      } // not DIVIDE\r\n\r\n    // Set exponent and bits\r\n    res->exponent=exponent;\r\n    res->bits=(uByte)(bits&DECNEG);          // [cleaned]\r\n\r\n    // Now the coefficient.\r\n    decSetCoeff(res, set, accnext, accdigits, &residue, status);\r\n\r\n    decFinish(res, set, &residue, status);   // final cleanup\r\n\r\n    #if DECSUBSET\r\n    // If a divide then strip trailing zeros if subset [after round]\r\n    if (!set->extended && (op==DIVIDE)) decTrim(res, set, 0, 1, &dropped);\r\n    #endif\r\n    } while(0);                              // end protected\r\n\r\n  if (varalloc!=NULL) free(varalloc);   // drop any storage used\r\n  if (allocacc!=NULL) free(allocacc);   // ..\r\n  #if DECSUBSET\r\n  if (allocrhs!=NULL) free(allocrhs);   // ..\r\n  if (alloclhs!=NULL) free(alloclhs);   // ..\r\n  #endif\r\n  return res;\r\n  } // decDivideOp\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decMultiplyOp -- multiplication operation                          */\r\n/*                                                                    */\r\n/*  This routine performs the multiplication C=A x B.                 */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X*X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*   status is the usual accumulator                                  */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\n/* 'Classic' multiplication is used rather than Karatsuba, as the     */\r\n/* latter would give only a minor improvement for the short numbers   */\r\n/* expected to be handled most (and uses much more memory).           */\r\n/*                                                                    */\r\n/* There are two major paths here: the general-purpose ('old code')   */\r\n/* path which handles all DECDPUN values, and a fastpath version      */\r\n/* which is used if 64-bit ints are available, DECDPUN<=4, and more   */\r\n/* than two calls to decUnitAddSub would be made.                     */\r\n/*                                                                    */\r\n/* The fastpath version lumps units together into 8-digit or 9-digit  */\r\n/* chunks, and also uses a lazy carry strategy to minimise expensive  */\r\n/* 64-bit divisions.  The chunks are then broken apart again into     */\r\n/* units for continuing processing.  Despite this overhead, the       */\r\n/* fastpath can speed up some 16-digit operations by 10x (and much    */\r\n/* more for higher-precision calculations).                           */\r\n/*                                                                    */\r\n/* A buffer always has to be used for the accumulator; in the         */\r\n/* fastpath, buffers are also always needed for the chunked copies of */\r\n/* of the operand coefficients.                                       */\r\n/* Static buffers are larger than needed just for multiply, to allow  */\r\n/* for calls from other operations (notably exp).                     */\r\n/* ------------------------------------------------------------------ */\r\n#define FASTMUL (DECUSE64 && DECDPUN<5)\r\nstatic decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,\r\n                                 const decNumber *rhs, decContext *set,\r\n                                 uInt *status) {\r\n  Int    accunits;                 // Units of accumulator in use\r\n  Int    exponent;                 // work\r\n  Int    residue=0;                // rounding residue\r\n  uByte  bits;                     // result sign\r\n  Unit  *acc;                      // -> accumulator Unit array\r\n  Int    needbytes;                // size calculator\r\n  void  *allocacc=NULL;            // -> allocated accumulator, iff allocated\r\n  Unit  accbuff[SD2U(DECBUFFER*4+1)]; // buffer (+1 for DECBUFFER==0,\r\n                                   // *4 for calls from other operations)\r\n  const Unit *mer, *mermsup;       // work\r\n  Int   madlength;                 // Units in multiplicand\r\n  Int   shift;                     // Units to shift multiplicand by\r\n\r\n  #if FASTMUL\r\n    // if DECDPUN is 1 or 3 work in base 10**9, otherwise\r\n    // (DECDPUN is 2 or 4) then work in base 10**8\r\n    #if DECDPUN & 1                // odd\r\n      #define FASTBASE 1000000000  // base\r\n      #define FASTDIGS          9  // digits in base\r\n      #define FASTLAZY         18  // carry resolution point [1->18]\r\n    #else\r\n      #define FASTBASE  100000000\r\n      #define FASTDIGS          8\r\n      #define FASTLAZY       1844  // carry resolution point [1->1844]\r\n    #endif\r\n    // three buffers are used, two for chunked copies of the operands\r\n    // (base 10**8 or base 10**9) and one base 2**64 accumulator with\r\n    // lazy carry evaluation\r\n    uInt   zlhibuff[(DECBUFFER*2+1)/8+1]; // buffer (+1 for DECBUFFER==0)\r\n    uInt  *zlhi=zlhibuff;                 // -> lhs array\r\n    uInt  *alloclhi=NULL;                 // -> allocated buffer, iff allocated\r\n    uInt   zrhibuff[(DECBUFFER*2+1)/8+1]; // buffer (+1 for DECBUFFER==0)\r\n    uInt  *zrhi=zrhibuff;                 // -> rhs array\r\n    uInt  *allocrhi=NULL;                 // -> allocated buffer, iff allocated\r\n    uLong  zaccbuff[(DECBUFFER*2+1)/4+2]; // buffer (+1 for DECBUFFER==0)\r\n    // [allocacc is shared for both paths, as only one will run]\r\n    uLong *zacc=zaccbuff;          // -> accumulator array for exact result\r\n    #if DECDPUN==1\r\n    Int    zoff;                   // accumulator offset\r\n    #endif\r\n    uInt  *lip, *rip;              // item pointers\r\n    uInt  *lmsi, *rmsi;            // most significant items\r\n    Int    ilhs, irhs, iacc;       // item counts in the arrays\r\n    Int    lazy;                   // lazy carry counter\r\n    uLong  lcarry;                 // uLong carry\r\n    uInt   carry;                  // carry (NB not uLong)\r\n    Int    count;                  // work\r\n    const  Unit *cup;              // ..\r\n    Unit  *up;                     // ..\r\n    uLong *lp;                     // ..\r\n    Int    p;                      // ..\r\n  #endif\r\n\r\n  #if DECSUBSET\r\n    decNumber *alloclhs=NULL;      // -> allocated buffer, iff allocated\r\n    decNumber *allocrhs=NULL;      // -> allocated buffer, iff allocated\r\n  #endif\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  // precalculate result sign\r\n  bits=(uByte)((lhs->bits^rhs->bits)&DECNEG);\r\n\r\n  // handle infinities and NaNs\r\n  if (SPECIALARGS) {               // a special bit set\r\n    if (SPECIALARGS & (DECSNAN | DECNAN)) { // one or two NaNs\r\n      decNaNs(res, lhs, rhs, set, status);\r\n      return res;}\r\n    // one or two infinities; Infinity * 0 is invalid\r\n    if (((lhs->bits & DECINF)==0 && ISZERO(lhs))\r\n      ||((rhs->bits & DECINF)==0 && ISZERO(rhs))) {\r\n      *status|=DEC_Invalid_operation;\r\n      return res;}\r\n    decNumberZero(res);\r\n    res->bits=bits|DECINF;         // infinity\r\n    return res;}\r\n\r\n  // For best speed, as in DMSRCN [the original Rexx numerics\r\n  // module], use the shorter number as the multiplier (rhs) and\r\n  // the longer as the multiplicand (lhs) to minimise the number of\r\n  // adds (partial products)\r\n  if (lhs->digits<rhs->digits) {   // swap...\r\n    const decNumber *hold=lhs;\r\n    lhs=rhs;\r\n    rhs=hold;\r\n    }\r\n\r\n  do {                             // protect allocated storage\r\n    #if DECSUBSET\r\n    if (!set->extended) {\r\n      // reduce operands and set lostDigits status, as needed\r\n      if (lhs->digits>set->digits) {\r\n        alloclhs=decRoundOperand(lhs, set, status);\r\n        if (alloclhs==NULL) break;\r\n        lhs=alloclhs;\r\n        }\r\n      if (rhs->digits>set->digits) {\r\n        allocrhs=decRoundOperand(rhs, set, status);\r\n        if (allocrhs==NULL) break;\r\n        rhs=allocrhs;\r\n        }\r\n      }\r\n    #endif\r\n    // [following code does not require input rounding]\r\n\r\n    #if FASTMUL                    // fastpath can be used\r\n    // use the fast path if there are enough digits in the shorter\r\n    // operand to make the setup and takedown worthwhile\r\n    #define NEEDTWO (DECDPUN*2)    // within two decUnitAddSub calls\r\n    if (rhs->digits>NEEDTWO) {     // use fastpath...\r\n      // calculate the number of elements in each array\r\n      ilhs=(lhs->digits+FASTDIGS-1)/FASTDIGS; // [ceiling]\r\n      irhs=(rhs->digits+FASTDIGS-1)/FASTDIGS; // ..\r\n      iacc=ilhs+irhs;\r\n\r\n      // allocate buffers if required, as usual\r\n      needbytes=ilhs*sizeof(uInt);\r\n      if (needbytes>(Int)sizeof(zlhibuff)) {\r\n        alloclhi=(uInt *)malloc(needbytes);\r\n        zlhi=alloclhi;}\r\n      needbytes=irhs*sizeof(uInt);\r\n      if (needbytes>(Int)sizeof(zrhibuff)) {\r\n        allocrhi=(uInt *)malloc(needbytes);\r\n        zrhi=allocrhi;}\r\n\r\n      // Allocating the accumulator space needs a special case when\r\n      // DECDPUN=1 because when converting the accumulator to Units\r\n      // after the multiplication each 8-byte item becomes 9 1-byte\r\n      // units.  Therefore iacc extra bytes are needed at the front\r\n      // (rounded up to a multiple of 8 bytes), and the uLong\r\n      // accumulator starts offset the appropriate number of units\r\n      // to the right to avoid overwrite during the unchunking.\r\n      needbytes=iacc*sizeof(uLong);\r\n      #if DECDPUN==1\r\n      zoff=(iacc+7)/8;        // items to offset by\r\n      needbytes+=zoff*8;\r\n      #endif\r\n      if (needbytes>(Int)sizeof(zaccbuff)) {\r\n        allocacc=(uLong *)malloc(needbytes);\r\n        zacc=(uLong *)allocacc;}\r\n      if (zlhi==NULL||zrhi==NULL||zacc==NULL) {\r\n        *status|=DEC_Insufficient_storage;\r\n        break;}\r\n\r\n      acc=(Unit *)zacc;       // -> target Unit array\r\n      #if DECDPUN==1\r\n      zacc+=zoff;             // start uLong accumulator to right\r\n      #endif\r\n\r\n      // assemble the chunked copies of the left and right sides\r\n      for (count=lhs->digits, cup=lhs->lsu, lip=zlhi; count>0; lip++)\r\n        for (p=0, *lip=0; p<FASTDIGS && count>0;\r\n             p+=DECDPUN, cup++, count-=DECDPUN)\r\n          *lip+=*cup*powers[p];\r\n      lmsi=lip-1;     // save -> msi\r\n      for (count=rhs->digits, cup=rhs->lsu, rip=zrhi; count>0; rip++)\r\n        for (p=0, *rip=0; p<FASTDIGS && count>0;\r\n             p+=DECDPUN, cup++, count-=DECDPUN)\r\n          *rip+=*cup*powers[p];\r\n      rmsi=rip-1;     // save -> msi\r\n\r\n      // zero the accumulator\r\n      for (lp=zacc; lp<zacc+iacc; lp++) *lp=0;\r\n\r\n      /* Start the multiplication */\r\n      // Resolving carries can dominate the cost of accumulating the\r\n      // partial products, so this is only done when necessary.\r\n      // Each uLong item in the accumulator can hold values up to\r\n      // 2**64-1, and each partial product can be as large as\r\n      // (10**FASTDIGS-1)**2.  When FASTDIGS=9, this can be added to\r\n      // itself 18.4 times in a uLong without overflowing, so during\r\n      // the main calculation resolution is carried out every 18th\r\n      // add -- every 162 digits.  Similarly, when FASTDIGS=8, the\r\n      // partial products can be added to themselves 1844.6 times in\r\n      // a uLong without overflowing, so intermediate carry\r\n      // resolution occurs only every 14752 digits.  Hence for common\r\n      // short numbers usually only the one final carry resolution\r\n      // occurs.\r\n      // (The count is set via FASTLAZY to simplify experiments to\r\n      // measure the value of this approach: a 35% improvement on a\r\n      // [34x34] multiply.)\r\n      lazy=FASTLAZY;                         // carry delay count\r\n      for (rip=zrhi; rip<=rmsi; rip++) {     // over each item in rhs\r\n        lp=zacc+(rip-zrhi);                  // where to add the lhs\r\n        for (lip=zlhi; lip<=lmsi; lip++, lp++) { // over each item in lhs\r\n          *lp+=(uLong)(*lip)*(*rip);         // [this should in-line]\r\n          } // lip loop\r\n        lazy--;\r\n        if (lazy>0 && rip!=rmsi) continue;\r\n        lazy=FASTLAZY;                       // reset delay count\r\n        // spin up the accumulator resolving overflows\r\n        for (lp=zacc; lp<zacc+iacc; lp++) {\r\n          if (*lp<FASTBASE) continue;        // it fits\r\n          lcarry=*lp/FASTBASE;               // top part [slow divide]\r\n          // lcarry can exceed 2**32-1, so check again; this check\r\n          // and occasional extra divide (slow) is well worth it, as\r\n          // it allows FASTLAZY to be increased to 18 rather than 4\r\n          // in the FASTDIGS=9 case\r\n          if (lcarry<FASTBASE) carry=(uInt)lcarry;  // [usual]\r\n           else { // two-place carry [fairly rare]\r\n            uInt carry2=(uInt)(lcarry/FASTBASE);    // top top part\r\n            *(lp+2)+=carry2;                        // add to item+2\r\n            *lp-=((uLong)FASTBASE*FASTBASE*carry2); // [slow]\r\n            carry=(uInt)(lcarry-((uLong)FASTBASE*carry2)); // [inline]\r\n            }\r\n          *(lp+1)+=carry;                    // add to item above [inline]\r\n          *lp-=((uLong)FASTBASE*carry);      // [inline]\r\n          } // carry resolution\r\n        } // rip loop\r\n\r\n      // The multiplication is complete; time to convert back into\r\n      // units.  This can be done in-place in the accumulator and in\r\n      // 32-bit operations, because carries were resolved after the\r\n      // final add.  This needs N-1 divides and multiplies for\r\n      // each item in the accumulator (which will become up to N\r\n      // units, where 2<=N<=9).\r\n      for (lp=zacc, up=acc; lp<zacc+iacc; lp++) {\r\n        uInt item=(uInt)*lp;                 // decapitate to uInt\r\n        for (p=0; p<FASTDIGS-DECDPUN; p+=DECDPUN, up++) {\r\n          uInt part=item/(DECDPUNMAX+1);\r\n          *up=(Unit)(item-(part*(DECDPUNMAX+1)));\r\n          item=part;\r\n          } // p\r\n        *up=(Unit)item; up++;                // [final needs no division]\r\n        } // lp\r\n      accunits=up-acc;                       // count of units\r\n      }\r\n     else { // here to use units directly, without chunking ['old code']\r\n    #endif\r\n\r\n      // if accumulator will be too long for local storage, then allocate\r\n      acc=accbuff;                 // -> assume buffer for accumulator\r\n      needbytes=(D2U(lhs->digits)+D2U(rhs->digits))*sizeof(Unit);\r\n      if (needbytes>(Int)sizeof(accbuff)) {\r\n        allocacc=(Unit *)malloc(needbytes);\r\n        if (allocacc==NULL) {*status|=DEC_Insufficient_storage; break;}\r\n        acc=(Unit *)allocacc;                // use the allocated space\r\n        }\r\n\r\n      /* Now the main long multiplication loop */\r\n      // Unlike the equivalent in the IBM Java implementation, there\r\n      // is no advantage in calculating from msu to lsu.  So, do it\r\n      // by the book, as it were.\r\n      // Each iteration calculates ACC=ACC+MULTAND*MULT\r\n      accunits=1;                  // accumulator starts at '0'\r\n      *acc=0;                      // .. (lsu=0)\r\n      shift=0;                     // no multiplicand shift at first\r\n      madlength=D2U(lhs->digits);  // this won't change\r\n      mermsup=rhs->lsu+D2U(rhs->digits); // -> msu+1 of multiplier\r\n\r\n      for (mer=rhs->lsu; mer<mermsup; mer++) {\r\n        // Here, *mer is the next Unit in the multiplier to use\r\n        // If non-zero [optimization] add it...\r\n        if (*mer!=0) accunits=decUnitAddSub(&acc[shift], accunits-shift,\r\n                                            lhs->lsu, madlength, 0,\r\n                                            &acc[shift], *mer)\r\n                                            + shift;\r\n         else { // extend acc with a 0; it will be used shortly\r\n          *(acc+accunits)=0;       // [this avoids length of <=0 later]\r\n          accunits++;\r\n          }\r\n        // multiply multiplicand by 10**DECDPUN for next Unit to left\r\n        shift++;                   // add this for 'logical length'\r\n        } // n\r\n    #if FASTMUL\r\n      } // unchunked units\r\n    #endif\r\n    // common end-path\r\n    #if DECTRACE\r\n      decDumpAr('*', acc, accunits);         // Show exact result\r\n    #endif\r\n\r\n    // acc now contains the exact result of the multiplication,\r\n    // possibly with a leading zero unit; build the decNumber from\r\n    // it, noting if any residue\r\n    res->bits=bits;                          // set sign\r\n    res->digits=decGetDigits(acc, accunits); // count digits exactly\r\n\r\n    // There can be a 31-bit wrap in calculating the exponent.\r\n    // This can only happen if both input exponents are negative and\r\n    // both their magnitudes are large.  If there was a wrap, set a\r\n    // safe very negative exponent, from which decFinalize() will\r\n    // raise a hard underflow shortly.\r\n    exponent=lhs->exponent+rhs->exponent;    // calculate exponent\r\n    if (lhs->exponent<0 && rhs->exponent<0 && exponent>0)\r\n      exponent=-2*DECNUMMAXE;                // force underflow\r\n    res->exponent=exponent;                  // OK to overwrite now\r\n\r\n\r\n    // Set the coefficient.  If any rounding, residue records\r\n    decSetCoeff(res, set, acc, res->digits, &residue, status);\r\n    decFinish(res, set, &residue, status);   // final cleanup\r\n    } while(0);                         // end protected\r\n\r\n  if (allocacc!=NULL) free(allocacc);   // drop any storage used\r\n  #if DECSUBSET\r\n  if (allocrhs!=NULL) free(allocrhs);   // ..\r\n  if (alloclhs!=NULL) free(alloclhs);   // ..\r\n  #endif\r\n  #if FASTMUL\r\n  if (allocrhi!=NULL) free(allocrhi);   // ..\r\n  if (alloclhi!=NULL) free(alloclhi);   // ..\r\n  #endif\r\n  return res;\r\n  } // decMultiplyOp\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decExpOp -- effect exponentiation                                  */\r\n/*                                                                    */\r\n/*   This computes C = exp(A)                                         */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context; note that rounding mode has no effect        */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits. status is updated but    */\r\n/* not set.                                                           */\r\n/*                                                                    */\r\n/* Restrictions:                                                      */\r\n/*                                                                    */\r\n/*   digits, emax, and -emin in the context must be less than         */\r\n/*   2*DEC_MAX_MATH (1999998), and the rhs must be within these       */\r\n/*   bounds or a zero.  This is an internal routine, so these         */\r\n/*   restrictions are contractual and not enforced.                   */\r\n/*                                                                    */\r\n/* A finite result is rounded using DEC_ROUND_HALF_EVEN; it will      */\r\n/* almost always be correctly rounded, but may be up to 1 ulp in      */\r\n/* error in rare cases.                                               */\r\n/*                                                                    */\r\n/* Finite results will always be full precision and Inexact, except   */\r\n/* when A is a zero or -Infinity (giving 1 or 0 respectively).        */\r\n/* ------------------------------------------------------------------ */\r\n/* This approach used here is similar to the algorithm described in   */\r\n/*                                                                    */\r\n/*   Variable Precision Exponential Function, T. E. Hull and          */\r\n/*   A. Abrham, ACM Transactions on Mathematical Software, Vol 12 #2, */\r\n/*   pp79-91, ACM, June 1986.                                         */\r\n/*                                                                    */\r\n/* with the main difference being that the iterations in the series   */\r\n/* evaluation are terminated dynamically (which does not require the  */\r\n/* extra variable-precision variables which are expensive in this     */\r\n/* context).                                                          */\r\n/*                                                                    */\r\n/* The error analysis in Hull & Abrham's paper applies except for the */\r\n/* round-off error accumulation during the series evaluation.  This   */\r\n/* code does not precalculate the number of iterations and so cannot  */\r\n/* use Horner's scheme.  Instead, the accumulation is done at double- */\r\n/* precision, which ensures that the additions of the terms are exact */\r\n/* and do not accumulate round-off (and any round-off errors in the   */\r\n/* terms themselves move 'to the right' faster than they can          */\r\n/* accumulate).  This code also extends the calculation by allowing,  */\r\n/* in the spirit of other decNumber operators, the input to be more   */\r\n/* precise than the result (the precision used is based on the more   */\r\n/* precise of the input or requested result).                         */\r\n/*                                                                    */\r\n/* Implementation notes:                                              */\r\n/*                                                                    */\r\n/* 1. This is separated out as decExpOp so it can be called from      */\r\n/*    other Mathematical functions (notably Ln) with a wider range    */\r\n/*    than normal.  In particular, it can handle the slightly wider   */\r\n/*    (double) range needed by Ln (which has to be able to calculate  */\r\n/*    exp(-x) where x can be the tiniest number (Ntiny).              */\r\n/*                                                                    */\r\n/* 2. Normalizing x to be <=0.1 (instead of <=1) reduces loop         */\r\n/*    iterations by approximately a third with additional (although    */\r\n/*    diminishing) returns as the range is reduced to even smaller    */\r\n/*    fractions.  However, h (the power of 10 used to correct the     */\r\n/*    result at the end, see below) must be kept <=8 as otherwise     */\r\n/*    the final result cannot be computed.  Hence the leverage is a   */\r\n/*    sliding value (8-h), where potentially the range is reduced     */\r\n/*    more for smaller values.                                        */\r\n/*                                                                    */\r\n/*    The leverage that can be applied in this way is severely        */\r\n/*    limited by the cost of the raise-to-the power at the end,       */\r\n/*    which dominates when the number of iterations is small (less    */\r\n/*    than ten) or when rhs is short.  As an example, the adjustment  */\r\n/*    x**10,000,000 needs 31 multiplications, all but one full-width. */\r\n/*                                                                    */\r\n/* 3. The restrictions (especially precision) could be raised with    */\r\n/*    care, but the full decNumber range seems very hard within the   */\r\n/*    32-bit limits.                                                  */\r\n/*                                                                    */\r\n/* 4. The working precisions for the static buffers are twice the     */\r\n/*    obvious size to allow for calls from decNumberPower.            */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decExpOp(decNumber *res, const decNumber *rhs,\r\n                         decContext *set, uInt *status) {\r\n  uInt ignore=0;                   // working status\r\n  Int h;                           // adjusted exponent for 0.xxxx\r\n  Int p;                           // working precision\r\n  Int residue;                     // rounding residue\r\n  uInt needbytes;                  // for space calculations\r\n  const decNumber *x=rhs;          // (may point to safe copy later)\r\n  decContext aset, tset, dset;     // working contexts\r\n  Int comp;                        // work\r\n\r\n  // the argument is often copied to normalize it, so (unusually) it\r\n  // is treated like other buffers, using DECBUFFER, +1 in case\r\n  // DECBUFFER is 0\r\n  decNumber bufr[D2N(DECBUFFER*2+1)];\r\n  decNumber *allocrhs=NULL;        // non-NULL if rhs buffer allocated\r\n\r\n  // the working precision will be no more than set->digits+8+1\r\n  // so for on-stack buffers DECBUFFER+9 is used, +1 in case DECBUFFER\r\n  // is 0 (and twice that for the accumulator)\r\n\r\n  // buffer for t, term (working precision plus)\r\n  decNumber buft[D2N(DECBUFFER*2+9+1)];\r\n  decNumber *allocbuft=NULL;       // -> allocated buft, iff allocated\r\n  decNumber *t=buft;               // term\r\n  // buffer for a, accumulator (working precision * 2), at least 9\r\n  decNumber bufa[D2N(DECBUFFER*4+18+1)];\r\n  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated\r\n  decNumber *a=bufa;               // accumulator\r\n  // decNumber for the divisor term; this needs at most 9 digits\r\n  // and so can be fixed size [16 so can use standard context]\r\n  decNumber bufd[D2N(16)];\r\n  decNumber *d=bufd;               // divisor\r\n  decNumber numone;                // constant 1\r\n\r\n  #if DECCHECK\r\n  Int iterations=0;                // for later sanity check\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  do {                                  // protect allocated storage\r\n    if (SPECIALARG) {                   // handle infinities and NaNs\r\n      if (decNumberIsInfinite(rhs)) {   // an infinity\r\n        if (decNumberIsNegative(rhs))   // -Infinity -> +0\r\n          decNumberZero(res);\r\n         else decNumberCopy(res, rhs);  // +Infinity -> self\r\n        }\r\n       else decNaNs(res, rhs, NULL, set, status); // a NaN\r\n      break;}\r\n\r\n    if (ISZERO(rhs)) {                  // zeros -> exact 1\r\n      decNumberZero(res);               // make clean 1\r\n      *res->lsu=1;                      // ..\r\n      break;}                           // [no status to set]\r\n\r\n    // e**x when 0 < x < 0.66 is < 1+3x/2, hence can fast-path\r\n    // positive and negative tiny cases which will result in inexact\r\n    // 1.  This also allows the later add-accumulate to always be\r\n    // exact (because its length will never be more than twice the\r\n    // working precision).\r\n    // The comparator (tiny) needs just one digit, so use the\r\n    // decNumber d for it (reused as the divisor, etc., below); its\r\n    // exponent is such that if x is positive it will have\r\n    // set->digits-1 zeros between the decimal point and the digit,\r\n    // which is 4, and if x is negative one more zero there as the\r\n    // more precise result will be of the form 0.9999999 rather than\r\n    // 1.0000001.  Hence, tiny will be 0.0000004  if digits=7 and x>0\r\n    // or 0.00000004 if digits=7 and x<0.  If RHS not larger than\r\n    // this then the result will be 1.000000\r\n    decNumberZero(d);                   // clean\r\n    *d->lsu=4;                          // set 4 ..\r\n    d->exponent=-set->digits;           // * 10**(-d)\r\n    if (decNumberIsNegative(rhs)) d->exponent--;  // negative case\r\n    comp=decCompare(d, rhs, 1);         // signless compare\r\n    if (comp==BADINT) {\r\n      *status|=DEC_Insufficient_storage;\r\n      break;}\r\n    if (comp>=0) {                      // rhs < d\r\n      Int shift=set->digits-1;\r\n      decNumberZero(res);               // set 1\r\n      *res->lsu=1;                      // ..\r\n      res->digits=decShiftToMost(res->lsu, 1, shift);\r\n      res->exponent=-shift;                  // make 1.0000...\r\n      *status|=DEC_Inexact | DEC_Rounded;    // .. inexactly\r\n      break;} // tiny\r\n\r\n    // set up the context to be used for calculating a, as this is\r\n    // used on both paths below\r\n    decContextDefault(&aset, DEC_INIT_DECIMAL64);\r\n    // accumulator bounds are as requested (could underflow)\r\n    aset.emax=set->emax;                // usual bounds\r\n    aset.emin=set->emin;                // ..\r\n    aset.clamp=0;                       // and no concrete format\r\n\r\n    // calculate the adjusted (Hull & Abrham) exponent (where the\r\n    // decimal point is just to the left of the coefficient msd)\r\n    h=rhs->exponent+rhs->digits;\r\n    // if h>8 then 10**h cannot be calculated safely; however, when\r\n    // h=8 then exp(|rhs|) will be at least exp(1E+7) which is at\r\n    // least 6.59E+4342944, so (due to the restriction on Emax/Emin)\r\n    // overflow (or underflow to 0) is guaranteed -- so this case can\r\n    // be handled by simply forcing the appropriate excess\r\n    if (h>8) {                          // overflow/underflow\r\n      // set up here so Power call below will over or underflow to\r\n      // zero; set accumulator to either 2 or 0.02\r\n      // [stack buffer for a is always big enough for this]\r\n      decNumberZero(a);\r\n      *a->lsu=2;                        // not 1 but < exp(1)\r\n      if (decNumberIsNegative(rhs)) a->exponent=-2; // make 0.02\r\n      h=8;                              // clamp so 10**h computable\r\n      p=9;                              // set a working precision\r\n      }\r\n     else {                             // h<=8\r\n      Int maxlever=(rhs->digits>8?1:0);\r\n      // [could/should increase this for precisions >40 or so, too]\r\n\r\n      // if h is 8, cannot normalize to a lower upper limit because\r\n      // the final result will not be computable (see notes above),\r\n      // but leverage can be applied whenever h is less than 8.\r\n      // Apply as much as possible, up to a MAXLEVER digits, which\r\n      // sets the tradeoff against the cost of the later a**(10**h).\r\n      // As h is increased, the working precision below also\r\n      // increases to compensate for the \"constant digits at the\r\n      // front\" effect.\r\n      Int lever=MINI(8-h, maxlever);    // leverage attainable\r\n      Int use=-rhs->digits-lever;       // exponent to use for RHS\r\n      h+=lever;                         // apply leverage selected\r\n      if (h<0) {                        // clamp\r\n        use+=h;                         // [may end up subnormal]\r\n        h=0;\r\n        }\r\n      // Take a copy of RHS if it needs normalization (true whenever x>=1)\r\n      if (rhs->exponent!=use) {\r\n        decNumber *newrhs=bufr;         // assume will fit on stack\r\n        needbytes=sizeof(decNumber)+(D2U(rhs->digits)-1)*sizeof(Unit);\r\n        if (needbytes>sizeof(bufr)) {   // need malloc space\r\n          allocrhs=(decNumber *)malloc(needbytes);\r\n          if (allocrhs==NULL) {         // hopeless -- abandon\r\n            *status|=DEC_Insufficient_storage;\r\n            break;}\r\n          newrhs=allocrhs;              // use the allocated space\r\n          }\r\n        decNumberCopy(newrhs, rhs);     // copy to safe space\r\n        newrhs->exponent=use;           // normalize; now <1\r\n        x=newrhs;                       // ready for use\r\n        // decNumberShow(x);\r\n        }\r\n\r\n      // Now use the usual power series to evaluate exp(x).  The\r\n      // series starts as 1 + x + x^2/2 ... so prime ready for the\r\n      // third term by setting the term variable t=x, the accumulator\r\n      // a=1, and the divisor d=2.\r\n\r\n      // First determine the working precision.  From Hull & Abrham\r\n      // this is set->digits+h+2.  However, if x is 'over-precise' we\r\n      // need to allow for all its digits to potentially participate\r\n      // (consider an x where all the excess digits are 9s) so in\r\n      // this case use x->digits+h+2\r\n      p=MAXI(x->digits, set->digits)+h+2;    // [h<=8]\r\n\r\n      // a and t are variable precision, and depend on p, so space\r\n      // must be allocated for them if necessary\r\n\r\n      // the accumulator needs to be able to hold 2p digits so that\r\n      // the additions on the second and subsequent iterations are\r\n      // sufficiently exact.\r\n      needbytes=sizeof(decNumber)+(D2U(p*2)-1)*sizeof(Unit);\r\n      if (needbytes>sizeof(bufa)) {     // need malloc space\r\n        allocbufa=(decNumber *)malloc(needbytes);\r\n        if (allocbufa==NULL) {          // hopeless -- abandon\r\n          *status|=DEC_Insufficient_storage;\r\n          break;}\r\n        a=allocbufa;                    // use the allocated space\r\n        }\r\n      // the term needs to be able to hold p digits (which is\r\n      // guaranteed to be larger than x->digits, so the initial copy\r\n      // is safe); it may also be used for the raise-to-power\r\n      // calculation below, which needs an extra two digits\r\n      needbytes=sizeof(decNumber)+(D2U(p+2)-1)*sizeof(Unit);\r\n      if (needbytes>sizeof(buft)) {     // need malloc space\r\n        allocbuft=(decNumber *)malloc(needbytes);\r\n        if (allocbuft==NULL) {          // hopeless -- abandon\r\n          *status|=DEC_Insufficient_storage;\r\n          break;}\r\n        t=allocbuft;                    // use the allocated space\r\n        }\r\n\r\n      decNumberCopy(t, x);              // term=x\r\n      decNumberZero(a); *a->lsu=1;      // accumulator=1\r\n      decNumberZero(d); *d->lsu=2;      // divisor=2\r\n      decNumberZero(&numone); *numone.lsu=1; // constant 1 for increment\r\n\r\n      // set up the contexts for calculating a, t, and d\r\n      decContextDefault(&tset, DEC_INIT_DECIMAL64);\r\n      dset=tset;\r\n      // accumulator bounds are set above, set precision now\r\n      aset.digits=p*2;                  // double\r\n      // term bounds avoid any underflow or overflow\r\n      tset.digits=p;\r\n      tset.emin=DEC_MIN_EMIN;           // [emax is plenty]\r\n      // [dset.digits=16, etc., are sufficient]\r\n\r\n      // finally ready to roll\r\n      for (;;) {\r\n        #if DECCHECK\r\n        iterations++;\r\n        #endif\r\n        // only the status from the accumulation is interesting\r\n        // [but it should remain unchanged after first add]\r\n        decAddOp(a, a, t, &aset, 0, status);           // a=a+t\r\n        decMultiplyOp(t, t, x, &tset, &ignore);        // t=t*x\r\n        decDivideOp(t, t, d, &tset, DIVIDE, &ignore);  // t=t/d\r\n        // the iteration ends when the term cannot affect the result,\r\n        // if rounded to p digits, which is when its value is smaller\r\n        // than the accumulator by p+1 digits.  There must also be\r\n        // full precision in a.\r\n        if (((a->digits+a->exponent)>=(t->digits+t->exponent+p+1))\r\n            && (a->digits>=p)) break;\r\n        decAddOp(d, d, &numone, &dset, 0, &ignore);    // d=d+1\r\n        } // iterate\r\n\r\n      #if DECCHECK\r\n      // just a sanity check; comment out test to show always\r\n      if (iterations>p+3)\r\n        printf(\"Exp iterations=%ld, status=%08lx, p=%ld, d=%ld\\n\",\r\n               (LI)iterations, (LI)*status, (LI)p, (LI)x->digits);\r\n      #endif\r\n      } // h<=8\r\n\r\n    // apply postconditioning: a=a**(10**h) -- this is calculated\r\n    // at a slightly higher precision than Hull & Abrham suggest\r\n    if (h>0) {\r\n      Int seenbit=0;               // set once a 1-bit is seen\r\n      Int i;                       // counter\r\n      Int n=powers[h];             // always positive\r\n      aset.digits=p+2;             // sufficient precision\r\n      // avoid the overhead and many extra digits of decNumberPower\r\n      // as all that is needed is the short 'multipliers' loop; here\r\n      // accumulate the answer into t\r\n      decNumberZero(t); *t->lsu=1; // acc=1\r\n      for (i=1;;i++){              // for each bit [top bit ignored]\r\n        // abandon if have had overflow or terminal underflow\r\n        if (*status & (DEC_Overflow|DEC_Underflow)) { // interesting?\r\n          if (*status&DEC_Overflow || ISZERO(t)) break;}\r\n        n=n<<1;                    // move next bit to testable position\r\n        if (n<0) {                 // top bit is set\r\n          seenbit=1;               // OK, have a significant bit\r\n          decMultiplyOp(t, t, a, &aset, status); // acc=acc*x\r\n          }\r\n        if (i==31) break;          // that was the last bit\r\n        if (!seenbit) continue;    // no need to square 1\r\n        decMultiplyOp(t, t, t, &aset, status); // acc=acc*acc [square]\r\n        } /*i*/ // 32 bits\r\n      // decNumberShow(t);\r\n      a=t;                         // and carry on using t instead of a\r\n      }\r\n\r\n    // Copy and round the result to res\r\n    residue=1;                          // indicate dirt to right ..\r\n    if (ISZERO(a)) residue=0;           // .. unless underflowed to 0\r\n    aset.digits=set->digits;            // [use default rounding]\r\n    decCopyFit(res, a, &aset, &residue, status); // copy & shorten\r\n    decFinish(res, set, &residue, status);       // cleanup/set flags\r\n    } while(0);                         // end protected\r\n\r\n  if (allocrhs !=NULL) free(allocrhs);  // drop any storage used\r\n  if (allocbufa!=NULL) free(allocbufa); // ..\r\n  if (allocbuft!=NULL) free(allocbuft); // ..\r\n  // [status is handled by caller]\r\n  return res;\r\n  } // decExpOp\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* Initial-estimate natural logarithm table                           */\r\n/*                                                                    */\r\n/*   LNnn -- 90-entry 16-bit table for values from .10 through .99.   */\r\n/*           The result is a 4-digit encode of the coefficient (c=the */\r\n/*           top 14 bits encoding 0-9999) and a 2-digit encode of the */\r\n/*           exponent (e=the bottom 2 bits encoding 0-3)              */\r\n/*                                                                    */\r\n/*           The resulting value is given by:                         */\r\n/*                                                                    */\r\n/*             v = -c * 10**(-e-3)                                    */\r\n/*                                                                    */\r\n/*           where e and c are extracted from entry k = LNnn[x-10]    */\r\n/*           where x is truncated (NB) into the range 10 through 99,  */\r\n/*           and then c = k>>2 and e = k&3.                           */\r\n/* ------------------------------------------------------------------ */\r\nconst uShort LNnn[90]={9016,  8652,  8316,  8008,  7724,  7456,  7208,\r\n  6972,  6748,  6540,  6340,  6148,  5968,  5792,  5628,  5464,  5312,\r\n  5164,  5020,  4884,  4748,  4620,  4496,  4376,  4256,  4144,  4032,\r\n 39233, 38181, 37157, 36157, 35181, 34229, 33297, 32389, 31501, 30629,\r\n 29777, 28945, 28129, 27329, 26545, 25777, 25021, 24281, 23553, 22837,\r\n 22137, 21445, 20769, 20101, 19445, 18801, 18165, 17541, 16925, 16321,\r\n 15721, 15133, 14553, 13985, 13421, 12865, 12317, 11777, 11241, 10717,\r\n 10197,  9685,  9177,  8677,  8185,  7697,  7213,  6737,  6269,  5801,\r\n  5341,  4889,  4437, 39930, 35534, 31186, 26886, 22630, 18418, 14254,\r\n 10130,  6046, 20055};\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decLnOp -- effect natural logarithm                                */\r\n/*                                                                    */\r\n/*   This computes C = ln(A)                                          */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A                                */\r\n/*   rhs is A                                                         */\r\n/*   set is the context; note that rounding mode has no effect        */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Notable cases:                                                     */\r\n/*   A<0 -> Invalid                                                   */\r\n/*   A=0 -> -Infinity (Exact)                                         */\r\n/*   A=+Infinity -> +Infinity (Exact)                                 */\r\n/*   A=1 exactly -> 0 (Exact)                                         */\r\n/*                                                                    */\r\n/* Restrictions (as for Exp):                                         */\r\n/*                                                                    */\r\n/*   digits, emax, and -emin in the context must be less than         */\r\n/*   DEC_MAX_MATH+11 (1000010), and the rhs must be within these      */\r\n/*   bounds or a zero.  This is an internal routine, so these         */\r\n/*   restrictions are contractual and not enforced.                   */\r\n/*                                                                    */\r\n/* A finite result is rounded using DEC_ROUND_HALF_EVEN; it will      */\r\n/* almost always be correctly rounded, but may be up to 1 ulp in      */\r\n/* error in rare cases.                                               */\r\n/* ------------------------------------------------------------------ */\r\n/* The result is calculated using Newton's method, with each          */\r\n/* iteration calculating a' = a + x * exp(-a) - 1.  See, for example, */\r\n/* Epperson 1989.                                                     */\r\n/*                                                                    */\r\n/* The iteration ends when the adjustment x*exp(-a)-1 is tiny enough. */\r\n/* This has to be calculated at the sum of the precision of x and the */\r\n/* working precision.                                                 */\r\n/*                                                                    */\r\n/* Implementation notes:                                              */\r\n/*                                                                    */\r\n/* 1. This is separated out as decLnOp so it can be called from       */\r\n/*    other Mathematical functions (e.g., Log 10) with a wider range  */\r\n/*    than normal.  In particular, it can handle the slightly wider   */\r\n/*    (+9+2) range needed by a power function.                        */\r\n/*                                                                    */\r\n/* 2. The speed of this function is about 10x slower than exp, as     */\r\n/*    it typically needs 4-6 iterations for short numbers, and the    */\r\n/*    extra precision needed adds a squaring effect, twice.           */\r\n/*                                                                    */\r\n/* 3. Fastpaths are included for ln(10) and ln(2), up to length 40,   */\r\n/*    as these are common requests.  ln(10) is used by log10(x).      */\r\n/*                                                                    */\r\n/* 4. An iteration might be saved by widening the LNnn table, and     */\r\n/*    would certainly save at least one if it were made ten times     */\r\n/*    bigger, too (for truncated fractions 0.100 through 0.999).      */\r\n/*    However, for most practical evaluations, at least four or five  */\r\n/*    iterations will be neede -- so this would only speed up by      */\r\n/*    20-25% and that probably does not justify increasing the table  */\r\n/*    size.                                                           */\r\n/*                                                                    */\r\n/* 5. The static buffers are larger than might be expected to allow   */\r\n/*    for calls from decNumberPower.                                  */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decLnOp(decNumber *res, const decNumber *rhs,\r\n                    decContext *set, uInt *status) {\r\n  uInt ignore=0;                   // working status accumulator\r\n  uInt needbytes;                  // for space calculations\r\n  Int residue;                     // rounding residue\r\n  Int r;                           // rhs=f*10**r [see below]\r\n  Int p;                           // working precision\r\n  Int pp;                          // precision for iteration\r\n  Int t;                           // work\r\n\r\n  // buffers for a (accumulator, typically precision+2) and b\r\n  // (adjustment calculator, same size)\r\n  decNumber bufa[D2N(DECBUFFER+12)];\r\n  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated\r\n  decNumber *a=bufa;               // accumulator/work\r\n  decNumber bufb[D2N(DECBUFFER*2+2)];\r\n  decNumber *allocbufb=NULL;       // -> allocated bufa, iff allocated\r\n  decNumber *b=bufb;               // adjustment/work\r\n\r\n  decNumber  numone;               // constant 1\r\n  decNumber  cmp;                  // work\r\n  decContext aset, bset;           // working contexts\r\n\r\n  #if DECCHECK\r\n  Int iterations=0;                // for later sanity check\r\n  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;\r\n  #endif\r\n\r\n  do {                                  // protect allocated storage\r\n    if (SPECIALARG) {                   // handle infinities and NaNs\r\n      if (decNumberIsInfinite(rhs)) {   // an infinity\r\n        if (decNumberIsNegative(rhs))   // -Infinity -> error\r\n          *status|=DEC_Invalid_operation;\r\n         else decNumberCopy(res, rhs);  // +Infinity -> self\r\n        }\r\n       else decNaNs(res, rhs, NULL, set, status); // a NaN\r\n      break;}\r\n\r\n    if (ISZERO(rhs)) {                  // +/- zeros -> -Infinity\r\n      decNumberZero(res);               // make clean\r\n      res->bits=DECINF|DECNEG;          // set - infinity\r\n      break;}                           // [no status to set]\r\n\r\n    // Non-zero negatives are bad...\r\n    if (decNumberIsNegative(rhs)) {     // -x -> error\r\n      *status|=DEC_Invalid_operation;\r\n      break;}\r\n\r\n    // Here, rhs is positive, finite, and in range\r\n\r\n    // lookaside fastpath code for ln(2) and ln(10) at common lengths\r\n    if (rhs->exponent==0 && set->digits<=40) {\r\n      #if DECDPUN==1\r\n      if (rhs->lsu[0]==0 && rhs->lsu[1]==1 && rhs->digits==2) { // ln(10)\r\n      #else\r\n      if (rhs->lsu[0]==10 && rhs->digits==2) {                  // ln(10)\r\n      #endif\r\n        aset=*set; aset.round=DEC_ROUND_HALF_EVEN;\r\n        #define LN10 \"2.302585092994045684017991454684364207601\"\r\n        decNumberFromString(res, LN10, &aset);\r\n        *status|=(DEC_Inexact | DEC_Rounded); // is inexact\r\n        break;}\r\n      if (rhs->lsu[0]==2 && rhs->digits==1) { // ln(2)\r\n        aset=*set; aset.round=DEC_ROUND_HALF_EVEN;\r\n        #define LN2 \"0.6931471805599453094172321214581765680755\"\r\n        decNumberFromString(res, LN2, &aset);\r\n        *status|=(DEC_Inexact | DEC_Rounded);\r\n        break;}\r\n      } // integer and short\r\n\r\n    // Determine the working precision.  This is normally the\r\n    // requested precision + 2, with a minimum of 9.  However, if\r\n    // the rhs is 'over-precise' then allow for all its digits to\r\n    // potentially participate (consider an rhs where all the excess\r\n    // digits are 9s) so in this case use rhs->digits+2.\r\n    p=MAXI(rhs->digits, MAXI(set->digits, 7))+2;\r\n\r\n    // Allocate space for the accumulator and the high-precision\r\n    // adjustment calculator, if necessary.  The accumulator must\r\n    // be able to hold p digits, and the adjustment up to\r\n    // rhs->digits+p digits.  They are also made big enough for 16\r\n    // digits so that they can be used for calculating the initial\r\n    // estimate.\r\n    needbytes=sizeof(decNumber)+(D2U(MAXI(p,16))-1)*sizeof(Unit);\r\n    if (needbytes>sizeof(bufa)) {     // need malloc space\r\n      allocbufa=(decNumber *)malloc(needbytes);\r\n      if (allocbufa==NULL) {          // hopeless -- abandon\r\n        *status|=DEC_Insufficient_storage;\r\n        break;}\r\n      a=allocbufa;                    // use the allocated space\r\n      }\r\n    pp=p+rhs->digits;\r\n    needbytes=sizeof(decNumber)+(D2U(MAXI(pp,16))-1)*sizeof(Unit);\r\n    if (needbytes>sizeof(bufb)) {     // need malloc space\r\n      allocbufb=(decNumber *)malloc(needbytes);\r\n      if (allocbufb==NULL) {          // hopeless -- abandon\r\n        *status|=DEC_Insufficient_storage;\r\n        break;}\r\n      b=allocbufb;                    // use the allocated space\r\n      }\r\n\r\n    // Prepare an initial estimate in acc. Calculate this by\r\n    // considering the coefficient of x to be a normalized fraction,\r\n    // f, with the decimal point at far left and multiplied by\r\n    // 10**r.  Then, rhs=f*10**r and 0.1<=f<1, and\r\n    //   ln(x) = ln(f) + ln(10)*r\r\n    // Get the initial estimate for ln(f) from a small lookup\r\n    // table (see above) indexed by the first two digits of f,\r\n    // truncated.\r\n\r\n    decContextDefault(&aset, DEC_INIT_DECIMAL64); // 16-digit extended\r\n    r=rhs->exponent+rhs->digits;        // 'normalised' exponent\r\n    decNumberFromInt32(a, r);           // a=r\r\n    decNumberFromInt32(b, 2302585);     // b=ln(10) (2.302585)\r\n    b->exponent=-6;                     //  ..\r\n    decMultiplyOp(a, a, b, &aset, &ignore);  // a=a*b\r\n    // now get top two digits of rhs into b by simple truncate and\r\n    // force to integer\r\n    residue=0;                          // (no residue)\r\n    aset.digits=2; aset.round=DEC_ROUND_DOWN;\r\n    decCopyFit(b, rhs, &aset, &residue, &ignore); // copy & shorten\r\n    b->exponent=0;                      // make integer\r\n    t=decGetInt(b);                     // [cannot fail]\r\n    if (t<10) t=X10(t);                 // adjust single-digit b\r\n    t=LNnn[t-10];                       // look up ln(b)\r\n    decNumberFromInt32(b, t>>2);        // b=ln(b) coefficient\r\n    b->exponent=-(t&3)-3;               // set exponent\r\n    b->bits=DECNEG;                     // ln(0.10)->ln(0.99) always -ve\r\n    aset.digits=16; aset.round=DEC_ROUND_HALF_EVEN; // restore\r\n    decAddOp(a, a, b, &aset, 0, &ignore); // acc=a+b\r\n    // the initial estimate is now in a, with up to 4 digits correct.\r\n    // When rhs is at or near Nmax the estimate will be low, so we\r\n    // will approach it from below, avoiding overflow when calling exp.\r\n\r\n    decNumberZero(&numone); *numone.lsu=1;   // constant 1 for adjustment\r\n\r\n    // accumulator bounds are as requested (could underflow, but\r\n    // cannot overflow)\r\n    aset.emax=set->emax;\r\n    aset.emin=set->emin;\r\n    aset.clamp=0;                       // no concrete format\r\n    // set up a context to be used for the multiply and subtract\r\n    bset=aset;\r\n    bset.emax=DEC_MAX_MATH*2;           // use double bounds for the\r\n    bset.emin=-DEC_MAX_MATH*2;          // adjustment calculation\r\n                                        // [see decExpOp call below]\r\n    // for each iteration double the number of digits to calculate,\r\n    // up to a maximum of p\r\n    pp=9;                               // initial precision\r\n    // [initially 9 as then the sequence starts 7+2, 16+2, and\r\n    // 34+2, which is ideal for standard-sized numbers]\r\n    aset.digits=pp;                     // working context\r\n    bset.digits=pp+rhs->digits;         // wider context\r\n    for (;;) {                          // iterate\r\n      #if DECCHECK\r\n      iterations++;\r\n      if (iterations>24) break;         // consider 9 * 2**24\r\n      #endif\r\n      // calculate the adjustment (exp(-a)*x-1) into b.  This is a\r\n      // catastrophic subtraction but it really is the difference\r\n      // from 1 that is of interest.\r\n      // Use the internal entry point to Exp as it allows the double\r\n      // range for calculating exp(-a) when a is the tiniest subnormal.\r\n      a->bits^=DECNEG;                  // make -a\r\n      decExpOp(b, a, &bset, &ignore);   // b=exp(-a)\r\n      a->bits^=DECNEG;                  // restore sign of a\r\n      // now multiply by rhs and subtract 1, at the wider precision\r\n      decMultiplyOp(b, b, rhs, &bset, &ignore);        // b=b*rhs\r\n      decAddOp(b, b, &numone, &bset, DECNEG, &ignore); // b=b-1\r\n\r\n      // the iteration ends when the adjustment cannot affect the\r\n      // result by >=0.5 ulp (at the requested digits), which\r\n      // is when its value is smaller than the accumulator by\r\n      // set->digits+1 digits (or it is zero) -- this is a looser\r\n      // requirement than for Exp because all that happens to the\r\n      // accumulator after this is the final rounding (but note that\r\n      // there must also be full precision in a, or a=0).\r\n\r\n      if (decNumberIsZero(b) ||\r\n          (a->digits+a->exponent)>=(b->digits+b->exponent+set->digits+1)) {\r\n        if (a->digits==p) break;\r\n        if (decNumberIsZero(a)) {\r\n          decCompareOp(&cmp, rhs, &numone, &aset, COMPARE, &ignore); // rhs=1 ?\r\n          if (cmp.lsu[0]==0) a->exponent=0;            // yes, exact 0\r\n           else *status|=(DEC_Inexact | DEC_Rounded);  // no, inexact\r\n          break;\r\n          }\r\n        // force padding if adjustment has gone to 0 before full length\r\n        if (decNumberIsZero(b)) b->exponent=a->exponent-p;\r\n        }\r\n\r\n      // not done yet ...\r\n      decAddOp(a, a, b, &aset, 0, &ignore);  // a=a+b for next estimate\r\n      if (pp==p) continue;                   // precision is at maximum\r\n      // lengthen the next calculation\r\n      pp=pp*2;                               // double precision\r\n      if (pp>p) pp=p;                        // clamp to maximum\r\n      aset.digits=pp;                        // working context\r\n      bset.digits=pp+rhs->digits;            // wider context\r\n      } // Newton's iteration\r\n\r\n    #if DECCHECK\r\n    // just a sanity check; remove the test to show always\r\n    if (iterations>24)\r\n      printf(\"Ln iterations=%ld, status=%08lx, p=%ld, d=%ld\\n\",\r\n            (LI)iterations, (LI)*status, (LI)p, (LI)rhs->digits);\r\n    #endif\r\n\r\n    // Copy and round the result to res\r\n    residue=1;                          // indicate dirt to right\r\n    if (ISZERO(a)) residue=0;           // .. unless underflowed to 0\r\n    aset.digits=set->digits;            // [use default rounding]\r\n    decCopyFit(res, a, &aset, &residue, status); // copy & shorten\r\n    decFinish(res, set, &residue, status);       // cleanup/set flags\r\n    } while(0);                         // end protected\r\n\r\n  if (allocbufa!=NULL) free(allocbufa); // drop any storage used\r\n  if (allocbufb!=NULL) free(allocbufb); // ..\r\n  // [status is handled by caller]\r\n  return res;\r\n  } // decLnOp\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decQuantizeOp  -- force exponent to requested value                */\r\n/*                                                                    */\r\n/*   This computes C = op(A, B), where op adjusts the coefficient     */\r\n/*   of C (by rounding or shifting) such that the exponent (-scale)   */\r\n/*   of C has the value B or matches the exponent of B.               */\r\n/*   The numerical value of C will equal A, except for the effects of */\r\n/*   any rounding that occurred.                                      */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A or B                           */\r\n/*   lhs is A, the number to adjust                                   */\r\n/*   rhs is B, the requested exponent                                 */\r\n/*   set is the context                                               */\r\n/*   quant is 1 for quantize or 0 for rescale                         */\r\n/*   status is the status accumulator (this can be called without     */\r\n/*          risk of control loss)                                     */\r\n/*                                                                    */\r\n/* C must have space for set->digits digits.                          */\r\n/*                                                                    */\r\n/* Unless there is an error or the result is infinite, the exponent   */\r\n/* after the operation is guaranteed to be that requested.            */\r\n/* ------------------------------------------------------------------ */\r\nstatic decNumber * decQuantizeOp(decNumber *res, const decNumber *lhs,\r\n                                 const decNumber *rhs, decContext *set,\r\n                                 Flag quant, uInt *status) {\r\n  #if DECSUBSET\r\n  decNumber *alloclhs=NULL;        // non-NULL if rounded lhs allocated\r\n  decNumber *allocrhs=NULL;        // .., rhs\r\n  #endif\r\n  const decNumber *inrhs=rhs;      // save original rhs\r\n  Int   reqdigits=set->digits;     // requested DIGITS\r\n  Int   reqexp;                    // requested exponent [-scale]\r\n  Int   residue=0;                 // rounding residue\r\n  Int   etiny=set->emin-(reqdigits-1);\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  do {                             // protect allocated storage\r\n    #if DECSUBSET\r\n    if (!set->extended) {\r\n      // reduce operands and set lostDigits status, as needed\r\n      if (lhs->digits>reqdigits) {\r\n        alloclhs=decRoundOperand(lhs, set, status);\r\n        if (alloclhs==NULL) break;\r\n        lhs=alloclhs;\r\n        }\r\n      if (rhs->digits>reqdigits) { // [this only checks lostDigits]\r\n        allocrhs=decRoundOperand(rhs, set, status);\r\n        if (allocrhs==NULL) break;\r\n        rhs=allocrhs;\r\n        }\r\n      }\r\n    #endif\r\n    // [following code does not require input rounding]\r\n\r\n    // Handle special values\r\n    if (SPECIALARGS) {\r\n      // NaNs get usual processing\r\n      if (SPECIALARGS & (DECSNAN | DECNAN))\r\n        decNaNs(res, lhs, rhs, set, status);\r\n      // one infinity but not both is bad\r\n      else if ((lhs->bits ^ rhs->bits) & DECINF)\r\n        *status|=DEC_Invalid_operation;\r\n      // both infinity: return lhs\r\n      else decNumberCopy(res, lhs);          // [nop if in place]\r\n      break;\r\n      }\r\n\r\n    // set requested exponent\r\n    if (quant) reqexp=inrhs->exponent;  // quantize -- match exponents\r\n     else {                             // rescale -- use value of rhs\r\n      // Original rhs must be an integer that fits and is in range,\r\n      // which could be from -1999999997 to +999999999, thanks to\r\n      // subnormals\r\n      reqexp=decGetInt(inrhs);               // [cannot fail]\r\n      }\r\n\r\n    #if DECSUBSET\r\n    if (!set->extended) etiny=set->emin;     // no subnormals\r\n    #endif\r\n\r\n    if (reqexp==BADINT                       // bad (rescale only) or ..\r\n     || reqexp==BIGODD || reqexp==BIGEVEN    // very big (ditto) or ..\r\n     || (reqexp<etiny)                       // < lowest\r\n     || (reqexp>set->emax)) {                // > emax\r\n      *status|=DEC_Invalid_operation;\r\n      break;}\r\n\r\n    // the RHS has been processed, so it can be overwritten now if necessary\r\n    if (ISZERO(lhs)) {                       // zero coefficient unchanged\r\n      decNumberCopy(res, lhs);               // [nop if in place]\r\n      res->exponent=reqexp;                  // .. just set exponent\r\n      #if DECSUBSET\r\n      if (!set->extended) res->bits=0;       // subset specification; no -0\r\n      #endif\r\n      }\r\n     else {                                  // non-zero lhs\r\n      Int adjust=reqexp-lhs->exponent;       // digit adjustment needed\r\n      // if adjusted coefficient will definitely not fit, give up now\r\n      if ((lhs->digits-adjust)>reqdigits) {\r\n        *status|=DEC_Invalid_operation;\r\n        break;\r\n        }\r\n\r\n      if (adjust>0) {                        // increasing exponent\r\n        // this will decrease the length of the coefficient by adjust\r\n        // digits, and must round as it does so\r\n        decContext workset;                  // work\r\n        workset=*set;                        // clone rounding, etc.\r\n        workset.digits=lhs->digits-adjust;   // set requested length\r\n        // [note that the latter can be <1, here]\r\n        decCopyFit(res, lhs, &workset, &residue, status); // fit to result\r\n        decApplyRound(res, &workset, residue, status);    // .. and round\r\n        residue=0;                                        // [used]\r\n        // If just rounded a 999s case, exponent will be off by one;\r\n        // adjust back (after checking space), if so.\r\n        if (res->exponent>reqexp) {\r\n          // re-check needed, e.g., for quantize(0.9999, 0.001) under\r\n          // set->digits==3\r\n          if (res->digits==reqdigits) {      // cannot shift by 1\r\n            *status&=~(DEC_Inexact | DEC_Rounded); // [clean these]\r\n            *status|=DEC_Invalid_operation;\r\n            break;\r\n            }\r\n          res->digits=decShiftToMost(res->lsu, res->digits, 1); // shift\r\n          res->exponent--;                   // (re)adjust the exponent.\r\n          }\r\n        #if DECSUBSET\r\n        if (ISZERO(res) && !set->extended) res->bits=0; // subset; no -0\r\n        #endif\r\n        } // increase\r\n       else /* adjust<=0 */ {                // decreasing or = exponent\r\n        // this will increase the length of the coefficient by -adjust\r\n        // digits, by adding zero or more trailing zeros; this is\r\n        // already checked for fit, above\r\n        decNumberCopy(res, lhs);             // [it will fit]\r\n        // if padding needed (adjust<0), add it now...\r\n        if (adjust<0) {\r\n          res->digits=decShiftToMost(res->lsu, res->digits, -adjust);\r\n          res->exponent+=adjust;             // adjust the exponent\r\n          }\r\n        } // decrease\r\n      } // non-zero\r\n\r\n    // Check for overflow [do not use Finalize in this case, as an\r\n    // overflow here is a \"don't fit\" situation]\r\n    if (res->exponent>set->emax-res->digits+1) {  // too big\r\n      *status|=DEC_Invalid_operation;\r\n      break;\r\n      }\r\n     else {\r\n      decFinalize(res, set, &residue, status);    // set subnormal flags\r\n      *status&=~DEC_Underflow;          // suppress Underflow [as per 754]\r\n      }\r\n    } while(0);                         // end protected\r\n\r\n  #if DECSUBSET\r\n  if (allocrhs!=NULL) free(allocrhs);   // drop any storage used\r\n  if (alloclhs!=NULL) free(alloclhs);   // ..\r\n  #endif\r\n  return res;\r\n  } // decQuantizeOp\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decCompareOp -- compare, min, or max two Numbers                   */\r\n/*                                                                    */\r\n/*   This computes C = A ? B and carries out one of four operations:  */\r\n/*     COMPARE    -- returns the signum (as a number) giving the      */\r\n/*                   result of a comparison unless one or both        */\r\n/*                   operands is a NaN (in which case a NaN results)  */\r\n/*     COMPSIG    -- as COMPARE except that a quiet NaN raises        */\r\n/*                   Invalid operation.                               */\r\n/*     COMPMAX    -- returns the larger of the operands, using the    */\r\n/*                   754 maxnum operation                             */\r\n/*     COMPMAXMAG -- ditto, comparing absolute values                 */\r\n/*     COMPMIN    -- the 754 minnum operation                         */\r\n/*     COMPMINMAG -- ditto, comparing absolute values                 */\r\n/*     COMTOTAL   -- returns the signum (as a number) giving the      */\r\n/*                   result of a comparison using 754 total ordering  */\r\n/*                                                                    */\r\n/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */\r\n/*   lhs is A                                                         */\r\n/*   rhs is B                                                         */\r\n/*   set is the context                                               */\r\n/*   op  is the operation flag                                        */\r\n/*   status is the usual accumulator                                  */\r\n/*                                                                    */\r\n/* C must have space for one digit for COMPARE or set->digits for     */\r\n/* COMPMAX, COMPMIN, COMPMAXMAG, or COMPMINMAG.                       */\r\n/* ------------------------------------------------------------------ */\r\n/* The emphasis here is on speed for common cases, and avoiding       */\r\n/* coefficient comparison if possible.                                */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decCompareOp(decNumber *res, const decNumber *lhs,\r\n                         const decNumber *rhs, decContext *set,\r\n                         Flag op, uInt *status) {\r\n  #if DECSUBSET\r\n  decNumber *alloclhs=NULL;        // non-NULL if rounded lhs allocated\r\n  decNumber *allocrhs=NULL;        // .., rhs\r\n  #endif\r\n  Int   result=0;                  // default result value\r\n  uByte merged;                    // work\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(res, lhs, rhs, set)) return res;\r\n  #endif\r\n\r\n  do {                             // protect allocated storage\r\n    #if DECSUBSET\r\n    if (!set->extended) {\r\n      // reduce operands and set lostDigits status, as needed\r\n      if (lhs->digits>set->digits) {\r\n        alloclhs=decRoundOperand(lhs, set, status);\r\n        if (alloclhs==NULL) {result=BADINT; break;}\r\n        lhs=alloclhs;\r\n        }\r\n      if (rhs->digits>set->digits) {\r\n        allocrhs=decRoundOperand(rhs, set, status);\r\n        if (allocrhs==NULL) {result=BADINT; break;}\r\n        rhs=allocrhs;\r\n        }\r\n      }\r\n    #endif\r\n    // [following code does not require input rounding]\r\n\r\n    // If total ordering then handle differing signs 'up front'\r\n    if (op==COMPTOTAL) {                // total ordering\r\n      if (decNumberIsNegative(lhs) & !decNumberIsNegative(rhs)) {\r\n        result=-1;\r\n        break;\r\n        }\r\n      if (!decNumberIsNegative(lhs) & decNumberIsNegative(rhs)) {\r\n        result=+1;\r\n        break;\r\n        }\r\n      }\r\n\r\n    // handle NaNs specially; let infinities drop through\r\n    // This assumes sNaN (even just one) leads to NaN.\r\n    merged=(lhs->bits | rhs->bits) & (DECSNAN | DECNAN);\r\n    if (merged) {                       // a NaN bit set\r\n      if (op==COMPARE);                 // result will be NaN\r\n       else if (op==COMPSIG)            // treat qNaN as sNaN\r\n        *status|=DEC_Invalid_operation | DEC_sNaN;\r\n       else if (op==COMPTOTAL) {        // total ordering, always finite\r\n        // signs are known to be the same; compute the ordering here\r\n        // as if the signs are both positive, then invert for negatives\r\n        if (!decNumberIsNaN(lhs)) result=-1;\r\n         else if (!decNumberIsNaN(rhs)) result=+1;\r\n         // here if both NaNs\r\n         else if (decNumberIsSNaN(lhs) && decNumberIsQNaN(rhs)) result=-1;\r\n         else if (decNumberIsQNaN(lhs) && decNumberIsSNaN(rhs)) result=+1;\r\n         else { // both NaN or both sNaN\r\n          // now it just depends on the payload\r\n          result=decUnitCompare(lhs->lsu, D2U(lhs->digits),\r\n                                rhs->lsu, D2U(rhs->digits), 0);\r\n          // [Error not possible, as these are 'aligned']\r\n          } // both same NaNs\r\n        if (decNumberIsNegative(lhs)) result=-result;\r\n        break;\r\n        } // total order\r\n\r\n       else if (merged & DECSNAN);           // sNaN -> qNaN\r\n       else { // here if MIN or MAX and one or two quiet NaNs\r\n        // min or max -- 754 rules ignore single NaN\r\n        if (!decNumberIsNaN(lhs) || !decNumberIsNaN(rhs)) {\r\n          // just one NaN; force choice to be the non-NaN operand\r\n          op=COMPMAX;\r\n          if (lhs->bits & DECNAN) result=-1; // pick rhs\r\n                             else result=+1; // pick lhs\r\n          break;\r\n          }\r\n        } // max or min\r\n      op=COMPNAN;                            // use special path\r\n      decNaNs(res, lhs, rhs, set, status);   // propagate NaN\r\n      break;\r\n      }\r\n    // have numbers\r\n    if (op==COMPMAXMAG || op==COMPMINMAG) result=decCompare(lhs, rhs, 1);\r\n     else result=decCompare(lhs, rhs, 0);    // sign matters\r\n    } while(0);                              // end protected\r\n\r\n  if (result==BADINT) *status|=DEC_Insufficient_storage; // rare\r\n   else {\r\n    if (op==COMPARE || op==COMPSIG ||op==COMPTOTAL) { // returning signum\r\n      if (op==COMPTOTAL && result==0) {\r\n        // operands are numerically equal or same NaN (and same sign,\r\n        // tested first); if identical, leave result 0\r\n        if (lhs->exponent!=rhs->exponent) {\r\n          if (lhs->exponent<rhs->exponent) result=-1;\r\n           else result=+1;\r\n          if (decNumberIsNegative(lhs)) result=-result;\r\n          } // lexp!=rexp\r\n        } // total-order by exponent\r\n      decNumberZero(res);               // [always a valid result]\r\n      if (result!=0) {                  // must be -1 or +1\r\n        *res->lsu=1;\r\n        if (result<0) res->bits=DECNEG;\r\n        }\r\n      }\r\n     else if (op==COMPNAN);             // special, drop through\r\n     else {                             // MAX or MIN, non-NaN result\r\n      Int residue=0;                    // rounding accumulator\r\n      // choose the operand for the result\r\n      const decNumber *choice;\r\n      if (result==0) { // operands are numerically equal\r\n        // choose according to sign then exponent (see 754)\r\n        uByte slhs=(lhs->bits & DECNEG);\r\n        uByte srhs=(rhs->bits & DECNEG);\r\n        #if DECSUBSET\r\n        if (!set->extended) {           // subset: force left-hand\r\n          op=COMPMAX;\r\n          result=+1;\r\n          }\r\n        else\r\n        #endif\r\n        if (slhs!=srhs) {          // signs differ\r\n          if (slhs) result=-1;     // rhs is max\r\n               else result=+1;     // lhs is max\r\n          }\r\n         else if (slhs && srhs) {  // both negative\r\n          if (lhs->exponent<rhs->exponent) result=+1;\r\n                                      else result=-1;\r\n          // [if equal, use lhs, technically identical]\r\n          }\r\n         else {                    // both positive\r\n          if (lhs->exponent>rhs->exponent) result=+1;\r\n                                      else result=-1;\r\n          // [ditto]\r\n          }\r\n        } // numerically equal\r\n      // here result will be non-0; reverse if looking for MIN\r\n      if (op==COMPMIN || op==COMPMINMAG) result=-result;\r\n      choice=(result>0 ? lhs : rhs);    // choose\r\n      // copy chosen to result, rounding if need be\r\n      decCopyFit(res, choice, set, &residue, status);\r\n      decFinish(res, set, &residue, status);\r\n      }\r\n    }\r\n  #if DECSUBSET\r\n  if (allocrhs!=NULL) free(allocrhs);   // free any storage used\r\n  if (alloclhs!=NULL) free(alloclhs);   // ..\r\n  #endif\r\n  return res;\r\n  } // decCompareOp\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decCompare -- compare two decNumbers by numerical value            */\r\n/*                                                                    */\r\n/*  This routine compares A ? B without altering them.                */\r\n/*                                                                    */\r\n/*  Arg1 is A, a decNumber which is not a NaN                         */\r\n/*  Arg2 is B, a decNumber which is not a NaN                         */\r\n/*  Arg3 is 1 for a sign-independent compare, 0 otherwise             */\r\n/*                                                                    */\r\n/*  returns -1, 0, or 1 for A<B, A==B, or A>B, or BADINT if failure   */\r\n/*  (the only possible failure is an allocation error)                */\r\n/* ------------------------------------------------------------------ */\r\nstatic Int decCompare(const decNumber *lhs, const decNumber *rhs,\r\n                      Flag abs) {\r\n  Int   result;                    // result value\r\n  Int   sigr;                      // rhs signum\r\n  Int   compare;                   // work\r\n\r\n  result=1;                                  // assume signum(lhs)\r\n  if (ISZERO(lhs)) result=0;\r\n  if (abs) {\r\n    if (ISZERO(rhs)) return result;          // LHS wins or both 0\r\n    // RHS is non-zero\r\n    if (result==0) return -1;                // LHS is 0; RHS wins\r\n    // [here, both non-zero, result=1]\r\n    }\r\n   else {                                    // signs matter\r\n    if (result && decNumberIsNegative(lhs)) result=-1;\r\n    sigr=1;                                  // compute signum(rhs)\r\n    if (ISZERO(rhs)) sigr=0;\r\n     else if (decNumberIsNegative(rhs)) sigr=-1;\r\n    if (result > sigr) return +1;            // L > R, return 1\r\n    if (result < sigr) return -1;            // L < R, return -1\r\n    if (result==0) return 0;                   // both 0\r\n    }\r\n\r\n  // signums are the same; both are non-zero\r\n  if ((lhs->bits | rhs->bits) & DECINF) {    // one or more infinities\r\n    if (decNumberIsInfinite(rhs)) {\r\n      if (decNumberIsInfinite(lhs)) result=0;// both infinite\r\n       else result=-result;                  // only rhs infinite\r\n      }\r\n    return result;\r\n    }\r\n  // must compare the coefficients, allowing for exponents\r\n  if (lhs->exponent>rhs->exponent) {         // LHS exponent larger\r\n    // swap sides, and sign\r\n    const decNumber *temp=lhs;\r\n    lhs=rhs;\r\n    rhs=temp;\r\n    result=-result;\r\n    }\r\n  compare=decUnitCompare(lhs->lsu, D2U(lhs->digits),\r\n                         rhs->lsu, D2U(rhs->digits),\r\n                         rhs->exponent-lhs->exponent);\r\n  if (compare!=BADINT) compare*=result;      // comparison succeeded\r\n  return compare;\r\n  } // decCompare\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decUnitCompare -- compare two >=0 integers in Unit arrays          */\r\n/*                                                                    */\r\n/*  This routine compares A ? B*10**E where A and B are unit arrays   */\r\n/*  A is a plain integer                                              */\r\n/*  B has an exponent of E (which must be non-negative)               */\r\n/*                                                                    */\r\n/*  Arg1 is A first Unit (lsu)                                        */\r\n/*  Arg2 is A length in Units                                         */\r\n/*  Arg3 is B first Unit (lsu)                                        */\r\n/*  Arg4 is B length in Units                                         */\r\n/*  Arg5 is E (0 if the units are aligned)                            */\r\n/*                                                                    */\r\n/*  returns -1, 0, or 1 for A<B, A==B, or A>B, or BADINT if failure   */\r\n/*  (the only possible failure is an allocation error, which can      */\r\n/*  only occur if E!=0)                                               */\r\n/* ------------------------------------------------------------------ */\r\nstatic Int decUnitCompare(const Unit *a, Int alength,\r\n                          const Unit *b, Int blength, Int exp) {\r\n  Unit  *acc;                      // accumulator for result\r\n  Unit  accbuff[SD2U(DECBUFFER*2+1)]; // local buffer\r\n  Unit  *allocacc=NULL;            // -> allocated acc buffer, iff allocated\r\n  Int   accunits, need;            // units in use or needed for acc\r\n  const Unit *l, *r, *u;           // work\r\n  Int   expunits, exprem, result;  // ..\r\n\r\n  if (exp==0) {                    // aligned; fastpath\r\n    if (alength>blength) return 1;\r\n    if (alength<blength) return -1;\r\n    // same number of units in both -- need unit-by-unit compare\r\n    l=a+alength-1;\r\n    r=b+alength-1;\r\n    for (;l>=a; l--, r--) {\r\n      if (*l>*r) return 1;\r\n      if (*l<*r) return -1;\r\n      }\r\n    return 0;                      // all units match\r\n    } // aligned\r\n\r\n  // Unaligned.  If one is >1 unit longer than the other, padded\r\n  // approximately, then can return easily\r\n  if (alength>blength+(Int)D2U(exp)) return 1;\r\n  if (alength+1<blength+(Int)D2U(exp)) return -1;\r\n\r\n  // Need to do a real subtract.  For this, a result buffer is needed\r\n  // even though only the sign is of interest.  Its length needs\r\n  // to be the larger of alength and padded blength, +2\r\n  need=blength+D2U(exp);                // maximum real length of B\r\n  if (need<alength) need=alength;\r\n  need+=2;\r\n  acc=accbuff;                          // assume use local buffer\r\n  if (need*sizeof(Unit)>sizeof(accbuff)) {\r\n    allocacc=(Unit *)malloc(need*sizeof(Unit));\r\n    if (allocacc==NULL) return BADINT;  // hopeless -- abandon\r\n    acc=allocacc;\r\n    }\r\n  // Calculate units and remainder from exponent.\r\n  expunits=exp/DECDPUN;\r\n  exprem=exp%DECDPUN;\r\n  // subtract [A+B*(-m)]\r\n  accunits=decUnitAddSub(a, alength, b, blength, expunits, acc,\r\n                         -(Int)powers[exprem]);\r\n  // [UnitAddSub result may have leading zeros, even on zero]\r\n  if (accunits<0) result=-1;            // negative result\r\n   else {                               // non-negative result\r\n    // check units of the result before freeing any storage\r\n    for (u=acc; u<acc+accunits-1 && *u==0;) u++;\r\n    result=(*u==0 ? 0 : +1);\r\n    }\r\n  // clean up and return the result\r\n  if (allocacc!=NULL) free(allocacc);   // drop any storage used\r\n  return result;\r\n  } // decUnitCompare\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decUnitAddSub -- add or subtract two >=0 integers in Unit arrays   */\r\n/*                                                                    */\r\n/*  This routine performs the calculation:                            */\r\n/*                                                                    */\r\n/*  C=A+(B*M)                                                         */\r\n/*                                                                    */\r\n/*  Where M is in the range -DECDPUNMAX through +DECDPUNMAX.          */\r\n/*                                                                    */\r\n/*  A may be shorter or longer than B.                                */\r\n/*                                                                    */\r\n/*  Leading zeros are not removed after a calculation.  The result is */\r\n/*  either the same length as the longer of A and B (adding any       */\r\n/*  shift), or one Unit longer than that (if a Unit carry occurred).  */\r\n/*                                                                    */\r\n/*  A and B content are not altered unless C is also A or B.          */\r\n/*  C may be the same array as A or B, but only if no zero padding is */\r\n/*  requested (that is, C may be B only if bshift==0).                */\r\n/*  C is filled from the lsu; only those units necessary to complete  */\r\n/*  the calculation are referenced.                                   */\r\n/*                                                                    */\r\n/*  Arg1 is A first Unit (lsu)                                        */\r\n/*  Arg2 is A length in Units                                         */\r\n/*  Arg3 is B first Unit (lsu)                                        */\r\n/*  Arg4 is B length in Units                                         */\r\n/*  Arg5 is B shift in Units  (>=0; pads with 0 units if positive)    */\r\n/*  Arg6 is C first Unit (lsu)                                        */\r\n/*  Arg7 is M, the multiplier                                         */\r\n/*                                                                    */\r\n/*  returns the count of Units written to C, which will be non-zero   */\r\n/*  and negated if the result is negative.  That is, the sign of the  */\r\n/*  returned Int is the sign of the result (positive for zero) and    */\r\n/*  the absolute value of the Int is the count of Units.              */\r\n/*                                                                    */\r\n/*  It is the caller's responsibility to make sure that C size is     */\r\n/*  safe, allowing space if necessary for a one-Unit carry.           */\r\n/*                                                                    */\r\n/*  This routine is severely performance-critical; *any* change here  */\r\n/*  must be measured (timed) to assure no performance degradation.    */\r\n/*  In particular, trickery here tends to be counter-productive, as   */\r\n/*  increased complexity of code hurts register optimizations on      */\r\n/*  register-poor architectures.  Avoiding divisions is nearly        */\r\n/*  always a Good Idea, however.                                      */\r\n/*                                                                    */\r\n/* Special thanks to Rick McGuire (IBM Cambridge, MA) and Dave Clark  */\r\n/* (IBM Warwick, UK) for some of the ideas used in this routine.      */\r\n/* ------------------------------------------------------------------ */\r\nstatic Int decUnitAddSub(const Unit *a, Int alength,\r\n                         const Unit *b, Int blength, Int bshift,\r\n                         Unit *c, Int m) {\r\n  const Unit *alsu=a;              // A lsu [need to remember it]\r\n  Unit *clsu=c;                    // C ditto\r\n  Unit *minC;                      // low water mark for C\r\n  Unit *maxC;                      // high water mark for C\r\n  eInt carry=0;                    // carry integer (could be Long)\r\n  Int  add;                        // work\r\n  #if DECDPUN<=4                   // myriadal, millenary, etc.\r\n  Int  est;                        // estimated quotient\r\n  #endif\r\n\r\n  #if DECTRACE\r\n  if (alength<1 || blength<1)\r\n    printf(\"decUnitAddSub: alen blen m %ld %ld [%ld]\\n\", alength, blength, m);\r\n  #endif\r\n\r\n  maxC=c+alength;                  // A is usually the longer\r\n  minC=c+blength;                  // .. and B the shorter\r\n  if (bshift!=0) {                 // B is shifted; low As copy across\r\n    minC+=bshift;\r\n    // if in place [common], skip copy unless there's a gap [rare]\r\n    if (a==c && bshift<=alength) {\r\n      c+=bshift;\r\n      a+=bshift;\r\n      }\r\n     else for (; c<clsu+bshift; a++, c++) {  // copy needed\r\n      if (a<alsu+alength) *c=*a;\r\n       else *c=0;\r\n      }\r\n    }\r\n  if (minC>maxC) { // swap\r\n    Unit *hold=minC;\r\n    minC=maxC;\r\n    maxC=hold;\r\n    }\r\n\r\n  // For speed, do the addition as two loops; the first where both A\r\n  // and B contribute, and the second (if necessary) where only one or\r\n  // other of the numbers contribute.\r\n  // Carry handling is the same (i.e., duplicated) in each case.\r\n  for (; c<minC; c++) {\r\n    carry+=*a;\r\n    a++;\r\n    carry+=((eInt)*b)*m;                // [special-casing m=1/-1\r\n    b++;                                // here is not a win]\r\n    // here carry is new Unit of digits; it could be +ve or -ve\r\n    if ((ueInt)carry<=DECDPUNMAX) {     // fastpath 0-DECDPUNMAX\r\n      *c=(Unit)carry;\r\n      carry=0;\r\n      continue;\r\n      }\r\n    #if DECDPUN==4                           // use divide-by-multiply\r\n      if (carry>=0) {\r\n        est=(((ueInt)carry>>11)*53687)>>18;\r\n        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder\r\n        carry=est;                           // likely quotient [89%]\r\n        if (*c<DECDPUNMAX+1) continue;       // estimate was correct\r\n        carry++;\r\n        *c-=DECDPUNMAX+1;\r\n        continue;\r\n        }\r\n      // negative case\r\n      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive\r\n      est=(((ueInt)carry>>11)*53687)>>18;\r\n      *c=(Unit)(carry-est*(DECDPUNMAX+1));\r\n      carry=est-(DECDPUNMAX+1);              // correctly negative\r\n      if (*c<DECDPUNMAX+1) continue;         // was OK\r\n      carry++;\r\n      *c-=DECDPUNMAX+1;\r\n    #elif DECDPUN==3\r\n      if (carry>=0) {\r\n        est=(((ueInt)carry>>3)*16777)>>21;\r\n        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder\r\n        carry=est;                           // likely quotient [99%]\r\n        if (*c<DECDPUNMAX+1) continue;       // estimate was correct\r\n        carry++;\r\n        *c-=DECDPUNMAX+1;\r\n        continue;\r\n        }\r\n      // negative case\r\n      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive\r\n      est=(((ueInt)carry>>3)*16777)>>21;\r\n      *c=(Unit)(carry-est*(DECDPUNMAX+1));\r\n      carry=est-(DECDPUNMAX+1);              // correctly negative\r\n      if (*c<DECDPUNMAX+1) continue;         // was OK\r\n      carry++;\r\n      *c-=DECDPUNMAX+1;\r\n    #elif DECDPUN<=2\r\n      // Can use QUOT10 as carry <= 4 digits\r\n      if (carry>=0) {\r\n        est=QUOT10(carry, DECDPUN);\r\n        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder\r\n        carry=est;                           // quotient\r\n        continue;\r\n        }\r\n      // negative case\r\n      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive\r\n      est=QUOT10(carry, DECDPUN);\r\n      *c=(Unit)(carry-est*(DECDPUNMAX+1));\r\n      carry=est-(DECDPUNMAX+1);              // correctly negative\r\n    #else\r\n      // remainder operator is undefined if negative, so must test\r\n      if ((ueInt)carry<(DECDPUNMAX+1)*2) {   // fastpath carry +1\r\n        *c=(Unit)(carry-(DECDPUNMAX+1));     // [helps additions]\r\n        carry=1;\r\n        continue;\r\n        }\r\n      if (carry>=0) {\r\n        *c=(Unit)(carry%(DECDPUNMAX+1));\r\n        carry=carry/(DECDPUNMAX+1);\r\n        continue;\r\n        }\r\n      // negative case\r\n      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive\r\n      *c=(Unit)(carry%(DECDPUNMAX+1));\r\n      carry=carry/(DECDPUNMAX+1)-(DECDPUNMAX+1);\r\n    #endif\r\n    } // c\r\n\r\n  // now may have one or other to complete\r\n  // [pretest to avoid loop setup/shutdown]\r\n  if (c<maxC) for (; c<maxC; c++) {\r\n    if (a<alsu+alength) {               // still in A\r\n      carry+=*a;\r\n      a++;\r\n      }\r\n     else {                             // inside B\r\n      carry+=((eInt)*b)*m;\r\n      b++;\r\n      }\r\n    // here carry is new Unit of digits; it could be +ve or -ve and\r\n    // magnitude up to DECDPUNMAX squared\r\n    if ((ueInt)carry<=DECDPUNMAX) {     // fastpath 0-DECDPUNMAX\r\n      *c=(Unit)carry;\r\n      carry=0;\r\n      continue;\r\n      }\r\n    // result for this unit is negative or >DECDPUNMAX\r\n    #if DECDPUN==4                           // use divide-by-multiply\r\n      if (carry>=0) {\r\n        est=(((ueInt)carry>>11)*53687)>>18;\r\n        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder\r\n        carry=est;                           // likely quotient [79.7%]\r\n        if (*c<DECDPUNMAX+1) continue;       // estimate was correct\r\n        carry++;\r\n        *c-=DECDPUNMAX+1;\r\n        continue;\r\n        }\r\n      // negative case\r\n      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive\r\n      est=(((ueInt)carry>>11)*53687)>>18;\r\n      *c=(Unit)(carry-est*(DECDPUNMAX+1));\r\n      carry=est-(DECDPUNMAX+1);              // correctly negative\r\n      if (*c<DECDPUNMAX+1) continue;         // was OK\r\n      carry++;\r\n      *c-=DECDPUNMAX+1;\r\n    #elif DECDPUN==3\r\n      if (carry>=0) {\r\n        est=(((ueInt)carry>>3)*16777)>>21;\r\n        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder\r\n        carry=est;                           // likely quotient [99%]\r\n        if (*c<DECDPUNMAX+1) continue;       // estimate was correct\r\n        carry++;\r\n        *c-=DECDPUNMAX+1;\r\n        continue;\r\n        }\r\n      // negative case\r\n      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive\r\n      est=(((ueInt)carry>>3)*16777)>>21;\r\n      *c=(Unit)(carry-est*(DECDPUNMAX+1));\r\n      carry=est-(DECDPUNMAX+1);              // correctly negative\r\n      if (*c<DECDPUNMAX+1) continue;         // was OK\r\n      carry++;\r\n      *c-=DECDPUNMAX+1;\r\n    #elif DECDPUN<=2\r\n      if (carry>=0) {\r\n        est=QUOT10(carry, DECDPUN);\r\n        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder\r\n        carry=est;                           // quotient\r\n        continue;\r\n        }\r\n      // negative case\r\n      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive\r\n      est=QUOT10(carry, DECDPUN);\r\n      *c=(Unit)(carry-est*(DECDPUNMAX+1));\r\n      carry=est-(DECDPUNMAX+1);              // correctly negative\r\n    #else\r\n      if ((ueInt)carry<(DECDPUNMAX+1)*2){    // fastpath carry 1\r\n        *c=(Unit)(carry-(DECDPUNMAX+1));\r\n        carry=1;\r\n        continue;\r\n        }\r\n      // remainder operator is undefined if negative, so must test\r\n      if (carry>=0) {\r\n        *c=(Unit)(carry%(DECDPUNMAX+1));\r\n        carry=carry/(DECDPUNMAX+1);\r\n        continue;\r\n        }\r\n      // negative case\r\n      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive\r\n      *c=(Unit)(carry%(DECDPUNMAX+1));\r\n      carry=carry/(DECDPUNMAX+1)-(DECDPUNMAX+1);\r\n    #endif\r\n    } // c\r\n\r\n  // OK, all A and B processed; might still have carry or borrow\r\n  // return number of Units in the result, negated if a borrow\r\n  if (carry==0) return c-clsu;     // no carry, so no more to do\r\n  if (carry>0) {                   // positive carry\r\n    *c=(Unit)carry;                // place as new unit\r\n    c++;                           // ..\r\n    return c-clsu;\r\n    }\r\n  // -ve carry: it's a borrow; complement needed\r\n  add=1;                           // temporary carry...\r\n  for (c=clsu; c<maxC; c++) {\r\n    add=DECDPUNMAX+add-*c;\r\n    if (add<=DECDPUNMAX) {\r\n      *c=(Unit)add;\r\n      add=0;\r\n      }\r\n     else {\r\n      *c=0;\r\n      add=1;\r\n      }\r\n    }\r\n  // add an extra unit iff it would be non-zero\r\n  #if DECTRACE\r\n    printf(\"UAS borrow: add %ld, carry %ld\\n\", add, carry);\r\n  #endif\r\n  if ((add-carry-1)!=0) {\r\n    *c=(Unit)(add-carry-1);\r\n    c++;                      // interesting, include it\r\n    }\r\n  return clsu-c;              // -ve result indicates borrowed\r\n  } // decUnitAddSub\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decTrim -- trim trailing zeros or normalize                        */\r\n/*                                                                    */\r\n/*   dn is the number to trim or normalize                            */\r\n/*   set is the context to use to check for clamp                     */\r\n/*   all is 1 to remove all trailing zeros, 0 for just fraction ones  */\r\n/*   noclamp is 1 to unconditional (unclamped) trim                   */\r\n/*   dropped returns the number of discarded trailing zeros           */\r\n/*   returns dn                                                       */\r\n/*                                                                    */\r\n/* If clamp is set in the context then the number of zeros trimmed    */\r\n/* may be limited if the exponent is high.                            */\r\n/* All fields are updated as required.  This is a utility operation,  */\r\n/* so special values are unchanged and no error is possible.          */\r\n/* ------------------------------------------------------------------ */\r\nstatic decNumber * decTrim(decNumber *dn, decContext *set, Flag all,\r\n                           Flag noclamp, Int *dropped) {\r\n  Int   d, exp;                    // work\r\n  uInt  cut;                       // ..\r\n  Unit  *up;                       // -> current Unit\r\n\r\n  #if DECCHECK\r\n  if (decCheckOperands(dn, DECUNUSED, DECUNUSED, DECUNCONT)) return dn;\r\n  #endif\r\n\r\n  *dropped=0;                           // assume no zeros dropped\r\n  if ((dn->bits & DECSPECIAL)           // fast exit if special ..\r\n    || (*dn->lsu & 0x01)) return dn;    // .. or odd\r\n  if (ISZERO(dn)) {                     // .. or 0\r\n    dn->exponent=0;                     // (sign is preserved)\r\n    return dn;\r\n    }\r\n\r\n  // have a finite number which is even\r\n  exp=dn->exponent;\r\n  cut=1;                           // digit (1-DECDPUN) in Unit\r\n  up=dn->lsu;                      // -> current Unit\r\n  for (d=0; d<dn->digits-1; d++) { // [don't strip the final digit]\r\n    // slice by powers\r\n    #if DECDPUN<=4\r\n      uInt quot=QUOT10(*up, cut);\r\n      if ((*up-quot*powers[cut])!=0) break;  // found non-0 digit\r\n    #else\r\n      if (*up%powers[cut]!=0) break;         // found non-0 digit\r\n    #endif\r\n    // have a trailing 0\r\n    if (!all) {                    // trimming\r\n      // [if exp>0 then all trailing 0s are significant for trim]\r\n      if (exp<=0) {                // if digit might be significant\r\n        if (exp==0) break;         // then quit\r\n        exp++;                     // next digit might be significant\r\n        }\r\n      }\r\n    cut++;                         // next power\r\n    if (cut>DECDPUN) {             // need new Unit\r\n      up++;\r\n      cut=1;\r\n      }\r\n    } // d\r\n  if (d==0) return dn;             // none to drop\r\n\r\n  // may need to limit drop if clamping\r\n  if (set->clamp && !noclamp) {\r\n    Int maxd=set->emax-set->digits+1-dn->exponent;\r\n    if (maxd<=0) return dn;        // nothing possible\r\n    if (d>maxd) d=maxd;\r\n    }\r\n\r\n  // effect the drop\r\n  decShiftToLeast(dn->lsu, D2U(dn->digits), d);\r\n  dn->exponent+=d;                 // maintain numerical value\r\n  dn->digits-=d;                   // new length\r\n  *dropped=d;                      // report the count\r\n  return dn;\r\n  } // decTrim\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decReverse -- reverse a Unit array in place                        */\r\n/*                                                                    */\r\n/*   ulo    is the start of the array                                 */\r\n/*   uhi    is the end of the array (highest Unit to include)         */\r\n/*                                                                    */\r\n/* The units ulo through uhi are reversed in place (if the number     */\r\n/* of units is odd, the middle one is untouched).  Note that the      */\r\n/* digit(s) in each unit are unaffected.                              */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decReverse(Unit *ulo, Unit *uhi) {\r\n  Unit temp;\r\n  for (; ulo<uhi; ulo++, uhi--) {\r\n    temp=*ulo;\r\n    *ulo=*uhi;\r\n    *uhi=temp;\r\n    }\r\n  return;\r\n  } // decReverse\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decShiftToMost -- shift digits in array towards most significant   */\r\n/*                                                                    */\r\n/*   uar    is the array                                              */\r\n/*   digits is the count of digits in use in the array                */\r\n/*   shift  is the number of zeros to pad with (least significant);   */\r\n/*     it must be zero or positive                                    */\r\n/*                                                                    */\r\n/*   returns the new length of the integer in the array, in digits    */\r\n/*                                                                    */\r\n/* No overflow is permitted (that is, the uar array must be known to  */\r\n/* be large enough to hold the result, after shifting).               */\r\n/* ------------------------------------------------------------------ */\r\nstatic Int decShiftToMost(Unit *uar, Int digits, Int shift) {\r\n  Unit  *target, *source, *first;  // work\r\n  Int   cut;                       // odd 0's to add\r\n  uInt  next;                      // work\r\n\r\n  if (shift==0) return digits;     // [fastpath] nothing to do\r\n  if ((digits+shift)<=DECDPUN) {   // [fastpath] single-unit case\r\n    *uar=(Unit)(*uar*powers[shift]);\r\n    return digits+shift;\r\n    }\r\n\r\n  next=0;                          // all paths\r\n  source=uar+D2U(digits)-1;        // where msu comes from\r\n  target=source+D2U(shift);        // where upper part of first cut goes\r\n  cut=DECDPUN-MSUDIGITS(shift);    // where to slice\r\n  if (cut==0) {                    // unit-boundary case\r\n    for (; source>=uar; source--, target--) *target=*source;\r\n    }\r\n   else {\r\n    first=uar+D2U(digits+shift)-1; // where msu of source will end up\r\n    for (; source>=uar; source--, target--) {\r\n      // split the source Unit and accumulate remainder for next\r\n      #if DECDPUN<=4\r\n        uInt quot=QUOT10(*source, cut);\r\n        uInt rem=*source-quot*powers[cut];\r\n        next+=quot;\r\n      #else\r\n        uInt rem=*source%powers[cut];\r\n        next+=*source/powers[cut];\r\n      #endif\r\n      if (target<=first) *target=(Unit)next;   // write to target iff valid\r\n      next=rem*powers[DECDPUN-cut];            // save remainder for next Unit\r\n      }\r\n    } // shift-move\r\n\r\n  // propagate any partial unit to one below and clear the rest\r\n  for (; target>=uar; target--) {\r\n    *target=(Unit)next;\r\n    next=0;\r\n    }\r\n  return digits+shift;\r\n  } // decShiftToMost\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decShiftToLeast -- shift digits in array towards least significant */\r\n/*                                                                    */\r\n/*   uar   is the array                                               */\r\n/*   units is length of the array, in units                           */\r\n/*   shift is the number of digits to remove from the lsu end; it     */\r\n/*     must be zero or positive and <= than units*DECDPUN.            */\r\n/*                                                                    */\r\n/*   returns the new length of the integer in the array, in units     */\r\n/*                                                                    */\r\n/* Removed digits are discarded (lost).  Units not required to hold   */\r\n/* the final result are unchanged.                                    */\r\n/* ------------------------------------------------------------------ */\r\nstatic Int decShiftToLeast(Unit *uar, Int units, Int shift) {\r\n  Unit  *target, *up;              // work\r\n  Int   cut, count;                // work\r\n  Int   quot, rem;                 // for division\r\n\r\n  if (shift==0) return units;      // [fastpath] nothing to do\r\n  if (shift==units*DECDPUN) {      // [fastpath] little to do\r\n    *uar=0;                        // all digits cleared gives zero\r\n    return 1;                      // leaves just the one\r\n    }\r\n\r\n  target=uar;                      // both paths\r\n  cut=MSUDIGITS(shift);\r\n  if (cut==DECDPUN) {              // unit-boundary case; easy\r\n    up=uar+D2U(shift);\r\n    for (; up<uar+units; target++, up++) *target=*up;\r\n    return target-uar;\r\n    }\r\n\r\n  // messier\r\n  up=uar+D2U(shift-cut);           // source; correct to whole Units\r\n  count=units*DECDPUN-shift;       // the maximum new length\r\n  #if DECDPUN<=4\r\n    quot=QUOT10(*up, cut);\r\n  #else\r\n    quot=*up/powers[cut];\r\n  #endif\r\n  for (; ; target++) {\r\n    *target=(Unit)quot;\r\n    count-=(DECDPUN-cut);\r\n    if (count<=0) break;\r\n    up++;\r\n    quot=*up;\r\n    #if DECDPUN<=4\r\n      quot=QUOT10(quot, cut);\r\n      rem=*up-quot*powers[cut];\r\n    #else\r\n      rem=quot%powers[cut];\r\n      quot=quot/powers[cut];\r\n    #endif\r\n    *target=(Unit)(*target+rem*powers[DECDPUN-cut]);\r\n    count-=cut;\r\n    if (count<=0) break;\r\n    }\r\n  return target-uar+1;\r\n  } // decShiftToLeast\r\n\r\n#if DECSUBSET\r\n/* ------------------------------------------------------------------ */\r\n/* decRoundOperand -- round an operand  [used for subset only]        */\r\n/*                                                                    */\r\n/*   dn is the number to round (dn->digits is > set->digits)          */\r\n/*   set is the relevant context                                      */\r\n/*   status is the status accumulator                                 */\r\n/*                                                                    */\r\n/*   returns an allocated decNumber with the rounded result.          */\r\n/*                                                                    */\r\n/* lostDigits and other status may be set by this.                    */\r\n/*                                                                    */\r\n/* Since the input is an operand, it must not be modified.            */\r\n/* Instead, return an allocated decNumber, rounded as required.       */\r\n/* It is the caller's responsibility to free the allocated storage.   */\r\n/*                                                                    */\r\n/* If no storage is available then the result cannot be used, so NULL */\r\n/* is returned.                                                       */\r\n/* ------------------------------------------------------------------ */\r\nstatic decNumber *decRoundOperand(const decNumber *dn, decContext *set,\r\n                                  uInt *status) {\r\n  decNumber *res;                       // result structure\r\n  uInt newstatus=0;                     // status from round\r\n  Int  residue=0;                       // rounding accumulator\r\n\r\n  // Allocate storage for the returned decNumber, big enough for the\r\n  // length specified by the context\r\n  res=(decNumber *)malloc(sizeof(decNumber)\r\n                          +(D2U(set->digits)-1)*sizeof(Unit));\r\n  if (res==NULL) {\r\n    *status|=DEC_Insufficient_storage;\r\n    return NULL;\r\n    }\r\n  decCopyFit(res, dn, set, &residue, &newstatus);\r\n  decApplyRound(res, set, residue, &newstatus);\r\n\r\n  // If that set Inexact then \"lost digits\" is raised...\r\n  if (newstatus & DEC_Inexact) newstatus|=DEC_Lost_digits;\r\n  *status|=newstatus;\r\n  return res;\r\n  } // decRoundOperand\r\n#endif\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decCopyFit -- copy a number, truncating the coefficient if needed  */\r\n/*                                                                    */\r\n/*   dest is the target decNumber                                     */\r\n/*   src  is the source decNumber                                     */\r\n/*   set is the context [used for length (digits) and rounding mode]  */\r\n/*   residue is the residue accumulator                               */\r\n/*   status contains the current status to be updated                 */\r\n/*                                                                    */\r\n/* (dest==src is allowed and will be a no-op if fits)                 */\r\n/* All fields are updated as required.                                */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decCopyFit(decNumber *dest, const decNumber *src,\r\n                       decContext *set, Int *residue, uInt *status) {\r\n  dest->bits=src->bits;\r\n  dest->exponent=src->exponent;\r\n  decSetCoeff(dest, set, src->lsu, src->digits, residue, status);\r\n  } // decCopyFit\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decSetCoeff -- set the coefficient of a number                     */\r\n/*                                                                    */\r\n/*   dn    is the number whose coefficient array is to be set.        */\r\n/*         It must have space for set->digits digits                  */\r\n/*   set   is the context [for size]                                  */\r\n/*   lsu   -> lsu of the source coefficient [may be dn->lsu]          */\r\n/*   len   is digits in the source coefficient [may be dn->digits]    */\r\n/*   residue is the residue accumulator.  This has values as in       */\r\n/*         decApplyRound, and will be unchanged unless the            */\r\n/*         target size is less than len.  In this case, the           */\r\n/*         coefficient is truncated and the residue is updated to     */\r\n/*         reflect the previous residue and the dropped digits.       */\r\n/*   status is the status accumulator, as usual                       */\r\n/*                                                                    */\r\n/* The coefficient may already be in the number, or it can be an      */\r\n/* external intermediate array.  If it is in the number, lsu must ==  */\r\n/* dn->lsu and len must == dn->digits.                                */\r\n/*                                                                    */\r\n/* Note that the coefficient length (len) may be < set->digits, and   */\r\n/* in this case this merely copies the coefficient (or is a no-op     */\r\n/* if dn->lsu==lsu).                                                  */\r\n/*                                                                    */\r\n/* Note also that (only internally, from decQuantizeOp and            */\r\n/* decSetSubnormal) the value of set->digits may be less than one,    */\r\n/* indicating a round to left.  This routine handles that case        */\r\n/* correctly; caller ensures space.                                   */\r\n/*                                                                    */\r\n/* dn->digits, dn->lsu (and as required), and dn->exponent are        */\r\n/* updated as necessary.   dn->bits (sign) is unchanged.              */\r\n/*                                                                    */\r\n/* DEC_Rounded status is set if any digits are discarded.             */\r\n/* DEC_Inexact status is set if any non-zero digits are discarded, or */\r\n/*                       incoming residue was non-0 (implies rounded) */\r\n/* ------------------------------------------------------------------ */\r\n// mapping array: maps 0-9 to canonical residues, so that a residue\r\n// can be adjusted in the range [-1, +1] and achieve correct rounding\r\n//                             0  1  2  3  4  5  6  7  8  9\r\nstatic const uByte resmap[10]={0, 3, 3, 3, 3, 5, 7, 7, 7, 7};\r\nstatic void decSetCoeff(decNumber *dn, decContext *set, const Unit *lsu,\r\n                        Int len, Int *residue, uInt *status) {\r\n  Int   discard;              // number of digits to discard\r\n  uInt  cut;                  // cut point in Unit\r\n  const Unit *up;             // work\r\n  Unit  *target;              // ..\r\n  Int   count;                // ..\r\n  #if DECDPUN<=4\r\n  uInt  temp;                 // ..\r\n  #endif\r\n\r\n  discard=len-set->digits;    // digits to discard\r\n  if (discard<=0) {           // no digits are being discarded\r\n    if (dn->lsu!=lsu) {       // copy needed\r\n      // copy the coefficient array to the result number; no shift needed\r\n      count=len;              // avoids D2U\r\n      up=lsu;\r\n      for (target=dn->lsu; count>0; target++, up++, count-=DECDPUN)\r\n        *target=*up;\r\n      dn->digits=len;         // set the new length\r\n      }\r\n    // dn->exponent and residue are unchanged, record any inexactitude\r\n    if (*residue!=0) *status|=(DEC_Inexact | DEC_Rounded);\r\n    return;\r\n    }\r\n\r\n  // some digits must be discarded ...\r\n  dn->exponent+=discard;      // maintain numerical value\r\n  *status|=DEC_Rounded;       // accumulate Rounded status\r\n  if (*residue>1) *residue=1; // previous residue now to right, so reduce\r\n\r\n  if (discard>len) {          // everything, +1, is being discarded\r\n    // guard digit is 0\r\n    // residue is all the number [NB could be all 0s]\r\n    if (*residue<=0) {        // not already positive\r\n      count=len;              // avoids D2U\r\n      for (up=lsu; count>0; up++, count-=DECDPUN) if (*up!=0) { // found non-0\r\n        *residue=1;\r\n        break;                // no need to check any others\r\n        }\r\n      }\r\n    if (*residue!=0) *status|=DEC_Inexact; // record inexactitude\r\n    *dn->lsu=0;               // coefficient will now be 0\r\n    dn->digits=1;             // ..\r\n    return;\r\n    } // total discard\r\n\r\n  // partial discard [most common case]\r\n  // here, at least the first (most significant) discarded digit exists\r\n\r\n  // spin up the number, noting residue during the spin, until get to\r\n  // the Unit with the first discarded digit.  When reach it, extract\r\n  // it and remember its position\r\n  count=0;\r\n  for (up=lsu;; up++) {\r\n    count+=DECDPUN;\r\n    if (count>=discard) break; // full ones all checked\r\n    if (*up!=0) *residue=1;\r\n    } // up\r\n\r\n  // here up -> Unit with first discarded digit\r\n  cut=discard-(count-DECDPUN)-1;\r\n  if (cut==DECDPUN-1) {       // unit-boundary case (fast)\r\n    Unit half=(Unit)powers[DECDPUN]>>1;\r\n    // set residue directly\r\n    if (*up>=half) {\r\n      if (*up>half) *residue=7;\r\n      else *residue+=5;       // add sticky bit\r\n      }\r\n     else { // <half\r\n      if (*up!=0) *residue=3; // [else is 0, leave as sticky bit]\r\n      }\r\n    if (set->digits<=0) {     // special for Quantize/Subnormal :-(\r\n      *dn->lsu=0;             // .. result is 0\r\n      dn->digits=1;           // ..\r\n      }\r\n     else {                   // shift to least\r\n      count=set->digits;      // now digits to end up with\r\n      dn->digits=count;       // set the new length\r\n      up++;                   // move to next\r\n      // on unit boundary, so shift-down copy loop is simple\r\n      for (target=dn->lsu; count>0; target++, up++, count-=DECDPUN)\r\n        *target=*up;\r\n      }\r\n    } // unit-boundary case\r\n\r\n   else { // discard digit is in low digit(s), and not top digit\r\n    uInt  discard1;                // first discarded digit\r\n    uInt  quot, rem;               // for divisions\r\n    if (cut==0) quot=*up;          // is at bottom of unit\r\n     else /* cut>0 */ {            // it's not at bottom of unit\r\n      #if DECDPUN<=4\r\n        quot=QUOT10(*up, cut);\r\n        rem=*up-quot*powers[cut];\r\n      #else\r\n        rem=*up%powers[cut];\r\n        quot=*up/powers[cut];\r\n      #endif\r\n      if (rem!=0) *residue=1;\r\n      }\r\n    // discard digit is now at bottom of quot\r\n    #if DECDPUN<=4\r\n      temp=(quot*6554)>>16;        // fast /10\r\n      // Vowels algorithm here not a win (9 instructions)\r\n      discard1=quot-X10(temp);\r\n      quot=temp;\r\n    #else\r\n      discard1=quot%10;\r\n      quot=quot/10;\r\n    #endif\r\n    // here, discard1 is the guard digit, and residue is everything\r\n    // else [use mapping array to accumulate residue safely]\r\n    *residue+=resmap[discard1];\r\n    cut++;                         // update cut\r\n    // here: up -> Unit of the array with bottom digit\r\n    //       cut is the division point for each Unit\r\n    //       quot holds the uncut high-order digits for the current unit\r\n    if (set->digits<=0) {          // special for Quantize/Subnormal :-(\r\n      *dn->lsu=0;                  // .. result is 0\r\n      dn->digits=1;                // ..\r\n      }\r\n     else {                        // shift to least needed\r\n      count=set->digits;           // now digits to end up with\r\n      dn->digits=count;            // set the new length\r\n      // shift-copy the coefficient array to the result number\r\n      for (target=dn->lsu; ; target++) {\r\n        *target=(Unit)quot;\r\n        count-=(DECDPUN-cut);\r\n        if (count<=0) break;\r\n        up++;\r\n        quot=*up;\r\n        #if DECDPUN<=4\r\n          quot=QUOT10(quot, cut);\r\n          rem=*up-quot*powers[cut];\r\n        #else\r\n          rem=quot%powers[cut];\r\n          quot=quot/powers[cut];\r\n        #endif\r\n        *target=(Unit)(*target+rem*powers[DECDPUN-cut]);\r\n        count-=cut;\r\n        if (count<=0) break;\r\n        } // shift-copy loop\r\n      } // shift to least\r\n    } // not unit boundary\r\n\r\n  if (*residue!=0) *status|=DEC_Inexact; // record inexactitude\r\n  return;\r\n  } // decSetCoeff\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decApplyRound -- apply pending rounding to a number                */\r\n/*                                                                    */\r\n/*   dn    is the number, with space for set->digits digits           */\r\n/*   set   is the context [for size and rounding mode]                */\r\n/*   residue indicates pending rounding, being any accumulated        */\r\n/*         guard and sticky information.  It may be:                  */\r\n/*         6-9: rounding digit is >5                                  */\r\n/*         5:   rounding digit is exactly half-way                    */\r\n/*         1-4: rounding digit is <5 and >0                           */\r\n/*         0:   the coefficient is exact                              */\r\n/*        -1:   as 1, but the hidden digits are subtractive, that     */\r\n/*              is, of the opposite sign to dn.  In this case the     */\r\n/*              coefficient must be non-0.  This case occurs when     */\r\n/*              subtracting a small number (which can be reduced to   */\r\n/*              a sticky bit); see decAddOp.                          */\r\n/*   status is the status accumulator, as usual                       */\r\n/*                                                                    */\r\n/* This routine applies rounding while keeping the length of the      */\r\n/* coefficient constant.  The exponent and status are unchanged       */\r\n/* except if:                                                         */\r\n/*                                                                    */\r\n/*   -- the coefficient was increased and is all nines (in which      */\r\n/*      case Overflow could occur, and is handled directly here so    */\r\n/*      the caller does not need to re-test for overflow)             */\r\n/*                                                                    */\r\n/*   -- the coefficient was decreased and becomes all nines (in which */\r\n/*      case Underflow could occur, and is also handled directly).    */\r\n/*                                                                    */\r\n/* All fields in dn are updated as required.                          */\r\n/*                                                                    */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decApplyRound(decNumber *dn, decContext *set, Int residue,\r\n                          uInt *status) {\r\n  Int  bump;                  // 1 if coefficient needs to be incremented\r\n                              // -1 if coefficient needs to be decremented\r\n\r\n  if (residue==0) return;     // nothing to apply\r\n\r\n  bump=0;                     // assume a smooth ride\r\n\r\n  // now decide whether, and how, to round, depending on mode\r\n  switch (set->round) {\r\n    case DEC_ROUND_05UP: {    // round zero or five up (for reround)\r\n      // This is the same as DEC_ROUND_DOWN unless there is a\r\n      // positive residue and the lsd of dn is 0 or 5, in which case\r\n      // it is bumped; when residue is <0, the number is therefore\r\n      // bumped down unless the final digit was 1 or 6 (in which\r\n      // case it is bumped down and then up -- a no-op)\r\n      Int lsd5=*dn->lsu%5;     // get lsd and quintate\r\n      if (residue<0 && lsd5!=1) bump=-1;\r\n       else if (residue>0 && lsd5==0) bump=1;\r\n      // [bump==1 could be applied directly; use common path for clarity]\r\n      break;} // r-05\r\n\r\n    case DEC_ROUND_DOWN: {\r\n      // no change, except if negative residue\r\n      if (residue<0) bump=-1;\r\n      break;} // r-d\r\n\r\n    case DEC_ROUND_HALF_DOWN: {\r\n      if (residue>5) bump=1;\r\n      break;} // r-h-d\r\n\r\n    case DEC_ROUND_HALF_EVEN: {\r\n      if (residue>5) bump=1;            // >0.5 goes up\r\n       else if (residue==5) {           // exactly 0.5000...\r\n        // 0.5 goes up iff [new] lsd is odd\r\n        if (*dn->lsu & 0x01) bump=1;\r\n        }\r\n      break;} // r-h-e\r\n\r\n    case DEC_ROUND_HALF_UP: {\r\n      if (residue>=5) bump=1;\r\n      break;} // r-h-u\r\n\r\n    case DEC_ROUND_UP: {\r\n      if (residue>0) bump=1;\r\n      break;} // r-u\r\n\r\n    case DEC_ROUND_CEILING: {\r\n      // same as _UP for positive numbers, and as _DOWN for negatives\r\n      // [negative residue cannot occur on 0]\r\n      if (decNumberIsNegative(dn)) {\r\n        if (residue<0) bump=-1;\r\n        }\r\n       else {\r\n        if (residue>0) bump=1;\r\n        }\r\n      break;} // r-c\r\n\r\n    case DEC_ROUND_FLOOR: {\r\n      // same as _UP for negative numbers, and as _DOWN for positive\r\n      // [negative residue cannot occur on 0]\r\n      if (!decNumberIsNegative(dn)) {\r\n        if (residue<0) bump=-1;\r\n        }\r\n       else {\r\n        if (residue>0) bump=1;\r\n        }\r\n      break;} // r-f\r\n\r\n    default: {      // e.g., DEC_ROUND_MAX\r\n      *status|=DEC_Invalid_context;\r\n      #if DECTRACE || (DECCHECK && DECVERB)\r\n      printf(\"Unknown rounding mode: %d\\n\", set->round);\r\n      #endif\r\n      break;}\r\n    } // switch\r\n\r\n  // now bump the number, up or down, if need be\r\n  if (bump==0) return;                       // no action required\r\n\r\n  // Simply use decUnitAddSub unless bumping up and the number is\r\n  // all nines.  In this special case set to 100... explicitly\r\n  // and adjust the exponent by one (as otherwise could overflow\r\n  // the array)\r\n  // Similarly handle all-nines result if bumping down.\r\n  if (bump>0) {\r\n    Unit *up;                                // work\r\n    uInt count=dn->digits;                   // digits to be checked\r\n    for (up=dn->lsu; ; up++) {\r\n      if (count<=DECDPUN) {\r\n        // this is the last Unit (the msu)\r\n        if (*up!=powers[count]-1) break;     // not still 9s\r\n        // here if it, too, is all nines\r\n        *up=(Unit)powers[count-1];           // here 999 -> 100 etc.\r\n        for (up=up-1; up>=dn->lsu; up--) *up=0; // others all to 0\r\n        dn->exponent++;                      // and bump exponent\r\n        // [which, very rarely, could cause Overflow...]\r\n        if ((dn->exponent+dn->digits)>set->emax+1) {\r\n          decSetOverflow(dn, set, status);\r\n          }\r\n        return;                              // done\r\n        }\r\n      // a full unit to check, with more to come\r\n      if (*up!=DECDPUNMAX) break;            // not still 9s\r\n      count-=DECDPUN;\r\n      } // up\r\n    } // bump>0\r\n   else {                                    // -1\r\n    // here checking for a pre-bump of 1000... (leading 1, all\r\n    // other digits zero)\r\n    Unit *up, *sup;                          // work\r\n    uInt count=dn->digits;                   // digits to be checked\r\n    for (up=dn->lsu; ; up++) {\r\n      if (count<=DECDPUN) {\r\n        // this is the last Unit (the msu)\r\n        if (*up!=powers[count-1]) break;     // not 100..\r\n        // here if have the 1000... case\r\n        sup=up;                              // save msu pointer\r\n        *up=(Unit)powers[count]-1;           // here 100 in msu -> 999\r\n        // others all to all-nines, too\r\n        for (up=up-1; up>=dn->lsu; up--) *up=(Unit)powers[DECDPUN]-1;\r\n        dn->exponent--;                      // and bump exponent\r\n\r\n        // iff the number was at the subnormal boundary (exponent=etiny)\r\n        // then the exponent is now out of range, so it will in fact get\r\n        // clamped to etiny and the final 9 dropped.\r\n        // printf(\">> emin=%d exp=%d sdig=%d\\n\", set->emin,\r\n        //        dn->exponent, set->digits);\r\n        if (dn->exponent+1==set->emin-set->digits+1) {\r\n          if (count==1 && dn->digits==1) *sup=0;  // here 9 -> 0[.9]\r\n           else {\r\n            *sup=(Unit)powers[count-1]-1;    // here 999.. in msu -> 99..\r\n            dn->digits--;\r\n            }\r\n          dn->exponent++;\r\n          *status|=DEC_Underflow | DEC_Subnormal | DEC_Inexact | DEC_Rounded;\r\n          }\r\n        return;                              // done\r\n        }\r\n\r\n      // a full unit to check, with more to come\r\n      if (*up!=0) break;                     // not still 0s\r\n      count-=DECDPUN;\r\n      } // up\r\n\r\n    } // bump<0\r\n\r\n  // Actual bump needed.  Do it.\r\n  decUnitAddSub(dn->lsu, D2U(dn->digits), uarrone, 1, 0, dn->lsu, bump);\r\n  } // decApplyRound\r\n\r\n#if DECSUBSET\r\n/* ------------------------------------------------------------------ */\r\n/* decFinish -- finish processing a number                            */\r\n/*                                                                    */\r\n/*   dn is the number                                                 */\r\n/*   set is the context                                               */\r\n/*   residue is the rounding accumulator (as in decApplyRound)        */\r\n/*   status is the accumulator                                        */\r\n/*                                                                    */\r\n/* This finishes off the current number by:                           */\r\n/*    1. If not extended:                                             */\r\n/*       a. Converting a zero result to clean '0'                     */\r\n/*       b. Reducing positive exponents to 0, if would fit in digits  */\r\n/*    2. Checking for overflow and subnormals (always)                */\r\n/* Note this is just Finalize when no subset arithmetic.              */\r\n/* All fields are updated as required.                                */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decFinish(decNumber *dn, decContext *set, Int *residue,\r\n                      uInt *status) {\r\n  if (!set->extended) {\r\n    if ISZERO(dn) {                // value is zero\r\n      dn->exponent=0;              // clean exponent ..\r\n      dn->bits=0;                  // .. and sign\r\n      return;                      // no error possible\r\n      }\r\n    if (dn->exponent>=0) {         // non-negative exponent\r\n      // >0; reduce to integer if possible\r\n      if (set->digits >= (dn->exponent+dn->digits)) {\r\n        dn->digits=decShiftToMost(dn->lsu, dn->digits, dn->exponent);\r\n        dn->exponent=0;\r\n        }\r\n      }\r\n    } // !extended\r\n\r\n  decFinalize(dn, set, residue, status);\r\n  } // decFinish\r\n#endif\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFinalize -- final check, clamp, and round of a number           */\r\n/*                                                                    */\r\n/*   dn is the number                                                 */\r\n/*   set is the context                                               */\r\n/*   residue is the rounding accumulator (as in decApplyRound)        */\r\n/*   status is the status accumulator                                 */\r\n/*                                                                    */\r\n/* This finishes off the current number by checking for subnormal     */\r\n/* results, applying any pending rounding, checking for overflow,     */\r\n/* and applying any clamping.                                         */\r\n/* Underflow and overflow conditions are raised as appropriate.       */\r\n/* All fields are updated as required.                                */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decFinalize(decNumber *dn, decContext *set, Int *residue,\r\n                        uInt *status) {\r\n  Int shift;                            // shift needed if clamping\r\n  Int tinyexp=set->emin-dn->digits+1;   // precalculate subnormal boundary\r\n\r\n  // Must be careful, here, when checking the exponent as the\r\n  // adjusted exponent could overflow 31 bits [because it may already\r\n  // be up to twice the expected].\r\n\r\n  // First test for subnormal.  This must be done before any final\r\n  // round as the result could be rounded to Nmin or 0.\r\n  if (dn->exponent<=tinyexp) {          // prefilter\r\n    Int comp;\r\n    decNumber nmin;\r\n    // A very nasty case here is dn == Nmin and residue<0\r\n    if (dn->exponent<tinyexp) {\r\n      // Go handle subnormals; this will apply round if needed.\r\n      decSetSubnormal(dn, set, residue, status);\r\n      return;\r\n      }\r\n    // Equals case: only subnormal if dn=Nmin and negative residue\r\n    decNumberZero(&nmin);\r\n    nmin.lsu[0]=1;\r\n    nmin.exponent=set->emin;\r\n    comp=decCompare(dn, &nmin, 1);                // (signless compare)\r\n    if (comp==BADINT) {                           // oops\r\n      *status|=DEC_Insufficient_storage;          // abandon...\r\n      return;\r\n      }\r\n    if (*residue<0 && comp==0) {                  // neg residue and dn==Nmin\r\n      decApplyRound(dn, set, *residue, status);   // might force down\r\n      decSetSubnormal(dn, set, residue, status);\r\n      return;\r\n      }\r\n    }\r\n\r\n  // now apply any pending round (this could raise overflow).\r\n  if (*residue!=0) decApplyRound(dn, set, *residue, status);\r\n\r\n  // Check for overflow [redundant in the 'rare' case] or clamp\r\n  if (dn->exponent<=set->emax-set->digits+1) return;   // neither needed\r\n\r\n\r\n  // here when might have an overflow or clamp to do\r\n  if (dn->exponent>set->emax-dn->digits+1) {           // too big\r\n    decSetOverflow(dn, set, status);\r\n    return;\r\n    }\r\n  // here when the result is normal but in clamp range\r\n  if (!set->clamp) return;\r\n\r\n  // here when need to apply the IEEE exponent clamp (fold-down)\r\n  shift=dn->exponent-(set->emax-set->digits+1);\r\n\r\n  // shift coefficient (if non-zero)\r\n  if (!ISZERO(dn)) {\r\n    dn->digits=decShiftToMost(dn->lsu, dn->digits, shift);\r\n    }\r\n  dn->exponent-=shift;   // adjust the exponent to match\r\n  *status|=DEC_Clamped;  // and record the dirty deed\r\n  return;\r\n  } // decFinalize\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decSetOverflow -- set number to proper overflow value              */\r\n/*                                                                    */\r\n/*   dn is the number (used for sign [only] and result)               */\r\n/*   set is the context [used for the rounding mode, etc.]            */\r\n/*   status contains the current status to be updated                 */\r\n/*                                                                    */\r\n/* This sets the sign of a number and sets its value to either        */\r\n/* Infinity or the maximum finite value, depending on the sign of     */\r\n/* dn and the rounding mode, following IEEE 754 rules.                */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decSetOverflow(decNumber *dn, decContext *set, uInt *status) {\r\n  Flag needmax=0;                  // result is maximum finite value\r\n  uByte sign=dn->bits&DECNEG;      // clean and save sign bit\r\n\r\n  if (ISZERO(dn)) {                // zero does not overflow magnitude\r\n    Int emax=set->emax;                      // limit value\r\n    if (set->clamp) emax-=set->digits-1;     // lower if clamping\r\n    if (dn->exponent>emax) {                 // clamp required\r\n      dn->exponent=emax;\r\n      *status|=DEC_Clamped;\r\n      }\r\n    return;\r\n    }\r\n\r\n  decNumberZero(dn);\r\n  switch (set->round) {\r\n    case DEC_ROUND_DOWN: {\r\n      needmax=1;                   // never Infinity\r\n      break;} // r-d\r\n    case DEC_ROUND_05UP: {\r\n      needmax=1;                   // never Infinity\r\n      break;} // r-05\r\n    case DEC_ROUND_CEILING: {\r\n      if (sign) needmax=1;         // Infinity if non-negative\r\n      break;} // r-c\r\n    case DEC_ROUND_FLOOR: {\r\n      if (!sign) needmax=1;        // Infinity if negative\r\n      break;} // r-f\r\n    default: break;                // Infinity in all other cases\r\n    }\r\n  if (needmax) {\r\n    decSetMaxValue(dn, set);\r\n    dn->bits=sign;                 // set sign\r\n    }\r\n   else dn->bits=sign|DECINF;      // Value is +/-Infinity\r\n  *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;\r\n  } // decSetOverflow\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decSetMaxValue -- set number to +Nmax (maximum normal value)       */\r\n/*                                                                    */\r\n/*   dn is the number to set                                          */\r\n/*   set is the context [used for digits and emax]                    */\r\n/*                                                                    */\r\n/* This sets the number to the maximum positive value.                */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decSetMaxValue(decNumber *dn, decContext *set) {\r\n  Unit *up;                        // work\r\n  Int count=set->digits;           // nines to add\r\n  dn->digits=count;\r\n  // fill in all nines to set maximum value\r\n  for (up=dn->lsu; ; up++) {\r\n    if (count>DECDPUN) *up=DECDPUNMAX;  // unit full o'nines\r\n     else {                             // this is the msu\r\n      *up=(Unit)(powers[count]-1);\r\n      break;\r\n      }\r\n    count-=DECDPUN;                // filled those digits\r\n    } // up\r\n  dn->bits=0;                      // + sign\r\n  dn->exponent=set->emax-set->digits+1;\r\n  } // decSetMaxValue\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decSetSubnormal -- process value whose exponent is <Emin           */\r\n/*                                                                    */\r\n/*   dn is the number (used as input as well as output; it may have   */\r\n/*         an allowed subnormal value, which may need to be rounded)  */\r\n/*   set is the context [used for the rounding mode]                  */\r\n/*   residue is any pending residue                                   */\r\n/*   status contains the current status to be updated                 */\r\n/*                                                                    */\r\n/* If subset mode, set result to zero and set Underflow flags.        */\r\n/*                                                                    */\r\n/* Value may be zero with a low exponent; this does not set Subnormal */\r\n/* but the exponent will be clamped to Etiny.                         */\r\n/*                                                                    */\r\n/* Otherwise ensure exponent is not out of range, and round as        */\r\n/* necessary.  Underflow is set if the result is Inexact.             */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decSetSubnormal(decNumber *dn, decContext *set, Int *residue,\r\n                            uInt *status) {\r\n  decContext workset;         // work\r\n  Int        etiny, adjust;   // ..\r\n\r\n  #if DECSUBSET\r\n  // simple set to zero and 'hard underflow' for subset\r\n  if (!set->extended) {\r\n    decNumberZero(dn);\r\n    // always full overflow\r\n    *status|=DEC_Underflow | DEC_Subnormal | DEC_Inexact | DEC_Rounded;\r\n    return;\r\n    }\r\n  #endif\r\n\r\n  // Full arithmetic -- allow subnormals, rounded to minimum exponent\r\n  // (Etiny) if needed\r\n  etiny=set->emin-(set->digits-1);      // smallest allowed exponent\r\n\r\n  if ISZERO(dn) {                       // value is zero\r\n    // residue can never be non-zero here\r\n    #if DECCHECK\r\n      if (*residue!=0) {\r\n        printf(\"++ Subnormal 0 residue %ld\\n\", (LI)*residue);\r\n        *status|=DEC_Invalid_operation;\r\n        }\r\n    #endif\r\n    if (dn->exponent<etiny) {           // clamp required\r\n      dn->exponent=etiny;\r\n      *status|=DEC_Clamped;\r\n      }\r\n    return;\r\n    }\r\n\r\n  *status|=DEC_Subnormal;               // have a non-zero subnormal\r\n  adjust=etiny-dn->exponent;            // calculate digits to remove\r\n  if (adjust<=0) {                      // not out of range; unrounded\r\n    // residue can never be non-zero here, except in the Nmin-residue\r\n    // case (which is a subnormal result), so can take fast-path here\r\n    // it may already be inexact (from setting the coefficient)\r\n    if (*status&DEC_Inexact) *status|=DEC_Underflow;\r\n    return;\r\n    }\r\n\r\n  // adjust>0, so need to rescale the result so exponent becomes Etiny\r\n  // [this code is similar to that in rescale]\r\n  workset=*set;                         // clone rounding, etc.\r\n  workset.digits=dn->digits-adjust;     // set requested length\r\n  workset.emin-=adjust;                 // and adjust emin to match\r\n  // [note that the latter can be <1, here, similar to Rescale case]\r\n  decSetCoeff(dn, &workset, dn->lsu, dn->digits, residue, status);\r\n  decApplyRound(dn, &workset, *residue, status);\r\n\r\n  // Use 754 default rule: Underflow is set iff Inexact\r\n  // [independent of whether trapped]\r\n  if (*status&DEC_Inexact) *status|=DEC_Underflow;\r\n\r\n  // if rounded up a 999s case, exponent will be off by one; adjust\r\n  // back if so [it will fit, because it was shortened earlier]\r\n  if (dn->exponent>etiny) {\r\n    dn->digits=decShiftToMost(dn->lsu, dn->digits, 1);\r\n    dn->exponent--;                     // (re)adjust the exponent.\r\n    }\r\n\r\n  // if rounded to zero, it is by definition clamped...\r\n  if (ISZERO(dn)) *status|=DEC_Clamped;\r\n  } // decSetSubnormal\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decCheckMath - check entry conditions for a math function          */\r\n/*                                                                    */\r\n/*   This checks the context and the operand                          */\r\n/*                                                                    */\r\n/*   rhs is the operand to check                                      */\r\n/*   set is the context to check                                      */\r\n/*   status is unchanged if both are good                             */\r\n/*                                                                    */\r\n/* returns non-zero if status is changed, 0 otherwise                 */\r\n/*                                                                    */\r\n/* Restrictions enforced:                                             */\r\n/*                                                                    */\r\n/*   digits, emax, and -emin in the context must be less than         */\r\n/*   DEC_MAX_MATH (999999), and A must be within these bounds if      */\r\n/*   non-zero.  Invalid_operation is set in the status if a           */\r\n/*   restriction is violated.                                         */\r\n/* ------------------------------------------------------------------ */\r\nstatic uInt decCheckMath(const decNumber *rhs, decContext *set,\r\n                         uInt *status) {\r\n  uInt save=*status;                         // record\r\n  if (set->digits>DEC_MAX_MATH\r\n   || set->emax>DEC_MAX_MATH\r\n   || -set->emin>DEC_MAX_MATH) *status|=DEC_Invalid_context;\r\n   else if ((rhs->digits>DEC_MAX_MATH\r\n     || rhs->exponent+rhs->digits>DEC_MAX_MATH+1\r\n     || rhs->exponent+rhs->digits<2*(1-DEC_MAX_MATH))\r\n     && !ISZERO(rhs)) *status|=DEC_Invalid_operation;\r\n  return (*status!=save);\r\n  } // decCheckMath\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decGetInt -- get integer from a number                             */\r\n/*                                                                    */\r\n/*   dn is the number [which will not be altered]                     */\r\n/*                                                                    */\r\n/*   returns one of:                                                  */\r\n/*     BADINT if there is a non-zero fraction                         */\r\n/*     the converted integer                                          */\r\n/*     BIGEVEN if the integer is even and magnitude > 2*10**9         */\r\n/*     BIGODD  if the integer is odd  and magnitude > 2*10**9         */\r\n/*                                                                    */\r\n/* This checks and gets a whole number from the input decNumber.      */\r\n/* The sign can be determined from dn by the caller when BIGEVEN or   */\r\n/* BIGODD is returned.                                                */\r\n/* ------------------------------------------------------------------ */\r\nstatic Int decGetInt(const decNumber *dn) {\r\n  Int  theInt;                          // result accumulator\r\n  const Unit *up;                       // work\r\n  Int  got;                             // digits (real or not) processed\r\n  Int  ilength=dn->digits+dn->exponent; // integral length\r\n  Flag neg=decNumberIsNegative(dn);     // 1 if -ve\r\n\r\n  // The number must be an integer that fits in 10 digits\r\n  // Assert, here, that 10 is enough for any rescale Etiny\r\n  #if DEC_MAX_EMAX > 999999999\r\n    #error GetInt may need updating [for Emax]\r\n  #endif\r\n  #if DEC_MIN_EMIN < -999999999\r\n    #error GetInt may need updating [for Emin]\r\n  #endif\r\n  if (ISZERO(dn)) return 0;             // zeros are OK, with any exponent\r\n\r\n  up=dn->lsu;                           // ready for lsu\r\n  theInt=0;                             // ready to accumulate\r\n  if (dn->exponent>=0) {                // relatively easy\r\n    // no fractional part [usual]; allow for positive exponent\r\n    got=dn->exponent;\r\n    }\r\n   else { // -ve exponent; some fractional part to check and discard\r\n    Int count=-dn->exponent;            // digits to discard\r\n    // spin up whole units until reach the Unit with the unit digit\r\n    for (; count>=DECDPUN; up++) {\r\n      if (*up!=0) return BADINT;        // non-zero Unit to discard\r\n      count-=DECDPUN;\r\n      }\r\n    if (count==0) got=0;                // [a multiple of DECDPUN]\r\n     else {                             // [not multiple of DECDPUN]\r\n      Int rem;                          // work\r\n      // slice off fraction digits and check for non-zero\r\n      #if DECDPUN<=4\r\n        theInt=QUOT10(*up, count);\r\n        rem=*up-theInt*powers[count];\r\n      #else\r\n        rem=*up%powers[count];          // slice off discards\r\n        theInt=*up/powers[count];\r\n      #endif\r\n      if (rem!=0) return BADINT;        // non-zero fraction\r\n      // it looks good\r\n      got=DECDPUN-count;                // number of digits so far\r\n      up++;                             // ready for next\r\n      }\r\n    }\r\n  // now it's known there's no fractional part\r\n\r\n  // tricky code now, to accumulate up to 9.3 digits\r\n  if (got==0) {theInt=*up; got+=DECDPUN; up++;} // ensure lsu is there\r\n\r\n  if (ilength<11) {\r\n    Int save=theInt;\r\n    // collect any remaining unit(s)\r\n    for (; got<ilength; up++) {\r\n      theInt+=*up*powers[got];\r\n      got+=DECDPUN;\r\n      }\r\n    if (ilength==10) {                  // need to check for wrap\r\n      if (theInt/(Int)powers[got-DECDPUN]!=(Int)*(up-1)) ilength=11;\r\n         // [that test also disallows the BADINT result case]\r\n       else if (neg && theInt>1999999997) ilength=11;\r\n       else if (!neg && theInt>999999999) ilength=11;\r\n      if (ilength==11) theInt=save;     // restore correct low bit\r\n      }\r\n    }\r\n\r\n  if (ilength>10) {                     // too big\r\n    if (theInt&1) return BIGODD;        // bottom bit 1\r\n    return BIGEVEN;                     // bottom bit 0\r\n    }\r\n\r\n  if (neg) theInt=-theInt;              // apply sign\r\n  return theInt;\r\n  } // decGetInt\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decDecap -- decapitate the coefficient of a number                 */\r\n/*                                                                    */\r\n/*   dn   is the number to be decapitated                             */\r\n/*   drop is the number of digits to be removed from the left of dn;  */\r\n/*     this must be <= dn->digits (if equal, the coefficient is       */\r\n/*     set to 0)                                                      */\r\n/*                                                                    */\r\n/* Returns dn; dn->digits will be <= the initial digits less drop     */\r\n/* (after removing drop digits there may be leading zero digits       */\r\n/* which will also be removed).  Only dn->lsu and dn->digits change.  */\r\n/* ------------------------------------------------------------------ */\r\nstatic decNumber *decDecap(decNumber *dn, Int drop) {\r\n  Unit *msu;                            // -> target cut point\r\n  Int cut;                              // work\r\n  if (drop>=dn->digits) {               // losing the whole thing\r\n    #if DECCHECK\r\n    if (drop>dn->digits)\r\n      printf(\"decDecap called with drop>digits [%ld>%ld]\\n\",\r\n             (LI)drop, (LI)dn->digits);\r\n    #endif\r\n    dn->lsu[0]=0;\r\n    dn->digits=1;\r\n    return dn;\r\n    }\r\n  msu=dn->lsu+D2U(dn->digits-drop)-1;   // -> likely msu\r\n  cut=MSUDIGITS(dn->digits-drop);       // digits to be in use in msu\r\n  if (cut!=DECDPUN) *msu%=powers[cut];  // clear left digits\r\n  // that may have left leading zero digits, so do a proper count...\r\n  dn->digits=decGetDigits(dn->lsu, msu-dn->lsu+1);\r\n  return dn;\r\n  } // decDecap\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decBiStr -- compare string with pairwise options                   */\r\n/*                                                                    */\r\n/*   targ is the string to compare                                    */\r\n/*   str1 is one of the strings to compare against (length may be 0)  */\r\n/*   str2 is the other; it must be the same length as str1            */\r\n/*                                                                    */\r\n/*   returns 1 if strings compare equal, (that is, it is the same     */\r\n/*   length as str1 and str2, and each character of targ is in either */\r\n/*   str1 or str2 in the corresponding position), or 0 otherwise      */\r\n/*                                                                    */\r\n/* This is used for generic caseless compare, including the awkward   */\r\n/* case of the Turkish dotted and dotless Is.  Use as (for example):  */\r\n/*   if (decBiStr(test, \"mike\", \"MIKE\")) ...                          */\r\n/* ------------------------------------------------------------------ */\r\nstatic Flag decBiStr(const char *targ, const char *str1, const char *str2) {\r\n  for (;;targ++, str1++, str2++) {\r\n    if (*targ!=*str1 && *targ!=*str2) return 0;\r\n    // *targ has a match in one (or both, if terminator)\r\n    if (*targ=='\\0') break;\r\n    } // forever\r\n  return 1;\r\n  } // decBiStr\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decNaNs -- handle NaN operand or operands                          */\r\n/*                                                                    */\r\n/*   res     is the result number                                     */\r\n/*   lhs     is the first operand                                     */\r\n/*   rhs     is the second operand, or NULL if none                   */\r\n/*   context is used to limit payload length                          */\r\n/*   status  contains the current status                              */\r\n/*   returns res in case convenient                                   */\r\n/*                                                                    */\r\n/* Called when one or both operands is a NaN, and propagates the      */\r\n/* appropriate result to res.  When an sNaN is found, it is changed   */\r\n/* to a qNaN and Invalid operation is set.                            */\r\n/* ------------------------------------------------------------------ */\r\nstatic decNumber * decNaNs(decNumber *res, const decNumber *lhs,\r\n                           const decNumber *rhs, decContext *set,\r\n                           uInt *status) {\r\n  // This decision tree ends up with LHS being the source pointer,\r\n  // and status updated if need be\r\n  if (lhs->bits & DECSNAN)\r\n    *status|=DEC_Invalid_operation | DEC_sNaN;\r\n   else if (rhs==NULL);\r\n   else if (rhs->bits & DECSNAN) {\r\n    lhs=rhs;\r\n    *status|=DEC_Invalid_operation | DEC_sNaN;\r\n    }\r\n   else if (lhs->bits & DECNAN);\r\n   else lhs=rhs;\r\n\r\n  // propagate the payload\r\n  if (lhs->digits<=set->digits) decNumberCopy(res, lhs); // easy\r\n   else { // too long\r\n    const Unit *ul;\r\n    Unit *ur, *uresp1;\r\n    // copy safe number of units, then decapitate\r\n    res->bits=lhs->bits;                // need sign etc.\r\n    uresp1=res->lsu+D2U(set->digits);\r\n    for (ur=res->lsu, ul=lhs->lsu; ur<uresp1; ur++, ul++) *ur=*ul;\r\n    res->digits=D2U(set->digits)*DECDPUN;\r\n    // maybe still too long\r\n    if (res->digits>set->digits) decDecap(res, res->digits-set->digits);\r\n    }\r\n\r\n  res->bits&=~DECSNAN;        // convert any sNaN to NaN, while\r\n  res->bits|=DECNAN;          // .. preserving sign\r\n  res->exponent=0;            // clean exponent\r\n                              // [coefficient was copied/decapitated]\r\n  return res;\r\n  } // decNaNs\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decStatus -- apply non-zero status                                 */\r\n/*                                                                    */\r\n/*   dn     is the number to set if error                             */\r\n/*   status contains the current status (not yet in context)          */\r\n/*   set    is the context                                            */\r\n/*                                                                    */\r\n/* If the status is an error status, the number is set to a NaN,      */\r\n/* unless the error was an overflow, divide-by-zero, or underflow,    */\r\n/* in which case the number will have already been set.               */\r\n/*                                                                    */\r\n/* The context status is then updated with the new status.  Note that */\r\n/* this may raise a signal, so control may never return from this     */\r\n/* routine (hence resources must be recovered before it is called).   */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decStatus(decNumber *dn, uInt status, decContext *set) {\r\n  if (status & DEC_NaNs) {              // error status -> NaN\r\n    // if cause was an sNaN, clear and propagate [NaN is already set up]\r\n    if (status & DEC_sNaN) status&=~DEC_sNaN;\r\n     else {\r\n      decNumberZero(dn);                // other error: clean throughout\r\n      dn->bits=DECNAN;                  // and make a quiet NaN\r\n      }\r\n    }\r\n  decContextSetStatus(set, status);     // [may not return]\r\n  return;\r\n  } // decStatus\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decGetDigits -- count digits in a Units array                      */\r\n/*                                                                    */\r\n/*   uar is the Unit array holding the number (this is often an       */\r\n/*          accumulator of some sort)                                 */\r\n/*   len is the length of the array in units [>=1]                    */\r\n/*                                                                    */\r\n/*   returns the number of (significant) digits in the array          */\r\n/*                                                                    */\r\n/* All leading zeros are excluded, except the last if the array has   */\r\n/* only zero Units.                                                   */\r\n/* ------------------------------------------------------------------ */\r\n// This may be called twice during some operations.\r\nstatic Int decGetDigits(Unit *uar, Int len) {\r\n  Unit *up=uar+(len-1);            // -> msu\r\n  Int  digits=(len-1)*DECDPUN+1;   // possible digits excluding msu\r\n  #if DECDPUN>4\r\n  uInt const *pow;                 // work\r\n  #endif\r\n                                   // (at least 1 in final msu)\r\n  #if DECCHECK\r\n  if (len<1) printf(\"decGetDigits called with len<1 [%ld]\\n\", (LI)len);\r\n  #endif\r\n\r\n  for (; up>=uar; up--) {\r\n    if (*up==0) {                  // unit is all 0s\r\n      if (digits==1) break;        // a zero has one digit\r\n      digits-=DECDPUN;             // adjust for 0 unit\r\n      continue;}\r\n    // found the first (most significant) non-zero Unit\r\n    #if DECDPUN>1                  // not done yet\r\n    if (*up<10) break;             // is 1-9\r\n    digits++;\r\n    #if DECDPUN>2                  // not done yet\r\n    if (*up<100) break;            // is 10-99\r\n    digits++;\r\n    #if DECDPUN>3                  // not done yet\r\n    if (*up<1000) break;           // is 100-999\r\n    digits++;\r\n    #if DECDPUN>4                  // count the rest ...\r\n    for (pow=&powers[4]; *up>=*pow; pow++) digits++;\r\n    #endif\r\n    #endif\r\n    #endif\r\n    #endif\r\n    break;\r\n    } // up\r\n  return digits;\r\n  } // decGetDigits\r\n\r\n#if DECTRACE | DECCHECK\r\n/* ------------------------------------------------------------------ */\r\n/* decNumberShow -- display a number [debug aid]                      */\r\n/*   dn is the number to show                                         */\r\n/*                                                                    */\r\n/* Shows: sign, exponent, coefficient (msu first), digits             */\r\n/*    or: sign, special-value                                         */\r\n/* ------------------------------------------------------------------ */\r\n// this is public so other modules can use it\r\nvoid decNumberShow(const decNumber *dn) {\r\n  const Unit *up;                  // work\r\n  uInt u, d;                       // ..\r\n  Int cut;                         // ..\r\n  char isign='+';                  // main sign\r\n  if (dn==NULL) {\r\n    printf(\"NULL\\n\");\r\n    return;}\r\n  if (decNumberIsNegative(dn)) isign='-';\r\n  printf(\" >> %c \", isign);\r\n  if (dn->bits&DECSPECIAL) {       // Is a special value\r\n    if (decNumberIsInfinite(dn)) printf(\"Infinity\");\r\n     else {                                  // a NaN\r\n      if (dn->bits&DECSNAN) printf(\"sNaN\");  // signalling NaN\r\n       else printf(\"NaN\");\r\n      }\r\n    // if coefficient and exponent are 0, no more to do\r\n    if (dn->exponent==0 && dn->digits==1 && *dn->lsu==0) {\r\n      printf(\"\\n\");\r\n      return;}\r\n    // drop through to report other information\r\n    printf(\" \");\r\n    }\r\n\r\n  // now carefully display the coefficient\r\n  up=dn->lsu+D2U(dn->digits)-1;         // msu\r\n  printf(\"%ld\", (LI)*up);\r\n  for (up=up-1; up>=dn->lsu; up--) {\r\n    u=*up;\r\n    printf(\":\");\r\n    for (cut=DECDPUN-1; cut>=0; cut--) {\r\n      d=u/powers[cut];\r\n      u-=d*powers[cut];\r\n      printf(\"%ld\", (LI)d);\r\n      } // cut\r\n    } // up\r\n  if (dn->exponent!=0) {\r\n    char esign='+';\r\n    if (dn->exponent<0) esign='-';\r\n    printf(\" E%c%ld\", esign, (LI)abs(dn->exponent));\r\n    }\r\n  printf(\" [%ld]\\n\", (LI)dn->digits);\r\n  } // decNumberShow\r\n#endif\r\n\r\n#if DECTRACE || DECCHECK\r\n/* ------------------------------------------------------------------ */\r\n/* decDumpAr -- display a unit array [debug/check aid]                */\r\n/*   name is a single-character tag name                              */\r\n/*   ar   is the array to display                                     */\r\n/*   len  is the length of the array in Units                         */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decDumpAr(char name, const Unit *ar, Int len) {\r\n  Int i;\r\n  const char *spec;\r\n  #if DECDPUN==9\r\n    spec=\"%09d \";\r\n  #elif DECDPUN==8\r\n    spec=\"%08d \";\r\n  #elif DECDPUN==7\r\n    spec=\"%07d \";\r\n  #elif DECDPUN==6\r\n    spec=\"%06d \";\r\n  #elif DECDPUN==5\r\n    spec=\"%05d \";\r\n  #elif DECDPUN==4\r\n    spec=\"%04d \";\r\n  #elif DECDPUN==3\r\n    spec=\"%03d \";\r\n  #elif DECDPUN==2\r\n    spec=\"%02d \";\r\n  #else\r\n    spec=\"%d \";\r\n  #endif\r\n  printf(\"  :%c: \", name);\r\n  for (i=len-1; i>=0; i--) {\r\n    if (i==len-1) printf(\"%ld \", (LI)ar[i]);\r\n     else printf(spec, ar[i]);\r\n    }\r\n  printf(\"\\n\");\r\n  return;}\r\n#endif\r\n\r\n#if DECCHECK\r\n/* ------------------------------------------------------------------ */\r\n/* decCheckOperands -- check operand(s) to a routine                  */\r\n/*   res is the result structure (not checked; it will be set to      */\r\n/*          quiet NaN if error found (and it is not NULL))            */\r\n/*   lhs is the first operand (may be DECUNRESU)                      */\r\n/*   rhs is the second (may be DECUNUSED)                             */\r\n/*   set is the context (may be DECUNCONT)                            */\r\n/*   returns 0 if both operands, and the context are clean, or 1      */\r\n/*     otherwise (in which case the context will show an error,       */\r\n/*     unless NULL).  Note that res is not cleaned; caller should     */\r\n/*     handle this so res=NULL case is safe.                          */\r\n/* The caller is expected to abandon immediately if 1 is returned.    */\r\n/* ------------------------------------------------------------------ */\r\nstatic Flag decCheckOperands(decNumber *res, const decNumber *lhs,\r\n                             const decNumber *rhs, decContext *set) {\r\n  Flag bad=0;\r\n  if (set==NULL) {                 // oops; hopeless\r\n    #if DECTRACE || DECVERB\r\n    printf(\"Reference to context is NULL.\\n\");\r\n    #endif\r\n    bad=1;\r\n    return 1;}\r\n   else if (set!=DECUNCONT\r\n     && (set->digits<1 || set->round>=DEC_ROUND_MAX)) {\r\n    bad=1;\r\n    #if DECTRACE || DECVERB\r\n    printf(\"Bad context [digits=%ld round=%ld].\\n\",\r\n           (LI)set->digits, (LI)set->round);\r\n    #endif\r\n    }\r\n   else {\r\n    if (res==NULL) {\r\n      bad=1;\r\n      #if DECTRACE\r\n      // this one not DECVERB as standard tests include NULL\r\n      printf(\"Reference to result is NULL.\\n\");\r\n      #endif\r\n      }\r\n    if (!bad && lhs!=DECUNUSED) bad=(decCheckNumber(lhs));\r\n    if (!bad && rhs!=DECUNUSED) bad=(decCheckNumber(rhs));\r\n    }\r\n  if (bad) {\r\n    if (set!=DECUNCONT) decContextSetStatus(set, DEC_Invalid_operation);\r\n    if (res!=DECUNRESU && res!=NULL) {\r\n      decNumberZero(res);\r\n      res->bits=DECNAN;       // qNaN\r\n      }\r\n    }\r\n  return bad;\r\n  } // decCheckOperands\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decCheckNumber -- check a number                                   */\r\n/*   dn is the number to check                                        */\r\n/*   returns 0 if the number is clean, or 1 otherwise                 */\r\n/*                                                                    */\r\n/* The number is considered valid if it could be a result from some   */\r\n/* operation in some valid context.                                   */\r\n/* ------------------------------------------------------------------ */\r\nstatic Flag decCheckNumber(const decNumber *dn) {\r\n  const Unit *up;             // work\r\n  uInt maxuint;               // ..\r\n  Int ae, d, digits;          // ..\r\n  Int emin, emax;             // ..\r\n\r\n  if (dn==NULL) {             // hopeless\r\n    #if DECTRACE\r\n    // this one not DECVERB as standard tests include NULL\r\n    printf(\"Reference to decNumber is NULL.\\n\");\r\n    #endif\r\n    return 1;}\r\n\r\n  // check special values\r\n  if (dn->bits & DECSPECIAL) {\r\n    if (dn->exponent!=0) {\r\n      #if DECTRACE || DECVERB\r\n      printf(\"Exponent %ld (not 0) for a special value [%02x].\\n\",\r\n             (LI)dn->exponent, dn->bits);\r\n      #endif\r\n      return 1;}\r\n\r\n    // 2003.09.08: NaNs may now have coefficients, so next tests Inf only\r\n    if (decNumberIsInfinite(dn)) {\r\n      if (dn->digits!=1) {\r\n        #if DECTRACE || DECVERB\r\n        printf(\"Digits %ld (not 1) for an infinity.\\n\", (LI)dn->digits);\r\n        #endif\r\n        return 1;}\r\n      if (*dn->lsu!=0) {\r\n        #if DECTRACE || DECVERB\r\n        printf(\"LSU %ld (not 0) for an infinity.\\n\", (LI)*dn->lsu);\r\n        #endif\r\n        decDumpAr('I', dn->lsu, D2U(dn->digits));\r\n        return 1;}\r\n      } // Inf\r\n    // 2002.12.26: negative NaNs can now appear through proposed IEEE\r\n    //             concrete formats (decimal64, etc.).\r\n    return 0;\r\n    }\r\n\r\n  // check the coefficient\r\n  if (dn->digits<1 || dn->digits>DECNUMMAXP) {\r\n    #if DECTRACE || DECVERB\r\n    printf(\"Digits %ld in number.\\n\", (LI)dn->digits);\r\n    #endif\r\n    return 1;}\r\n\r\n  d=dn->digits;\r\n\r\n  for (up=dn->lsu; d>0; up++) {\r\n    if (d>DECDPUN) maxuint=DECDPUNMAX;\r\n     else {                   // reached the msu\r\n      maxuint=powers[d]-1;\r\n      if (dn->digits>1 && *up<powers[d-1]) {\r\n        #if DECTRACE || DECVERB\r\n        printf(\"Leading 0 in number.\\n\");\r\n        decNumberShow(dn);\r\n        #endif\r\n        return 1;}\r\n      }\r\n    if (*up>maxuint) {\r\n      #if DECTRACE || DECVERB\r\n      printf(\"Bad Unit [%08lx] in %ld-digit number at offset %ld [maxuint %ld].\\n\",\r\n              (LI)*up, (LI)dn->digits, (LI)(up-dn->lsu), (LI)maxuint);\r\n      #endif\r\n      return 1;}\r\n    d-=DECDPUN;\r\n    }\r\n\r\n  // check the exponent.  Note that input operands can have exponents\r\n  // which are out of the set->emin/set->emax and set->digits range\r\n  // (just as they can have more digits than set->digits).\r\n  ae=dn->exponent+dn->digits-1;    // adjusted exponent\r\n  emax=DECNUMMAXE;\r\n  emin=DECNUMMINE;\r\n  digits=DECNUMMAXP;\r\n  if (ae<emin-(digits-1)) {\r\n    #if DECTRACE || DECVERB\r\n    printf(\"Adjusted exponent underflow [%ld].\\n\", (LI)ae);\r\n    decNumberShow(dn);\r\n    #endif\r\n    return 1;}\r\n  if (ae>+emax) {\r\n    #if DECTRACE || DECVERB\r\n    printf(\"Adjusted exponent overflow [%ld].\\n\", (LI)ae);\r\n    decNumberShow(dn);\r\n    #endif\r\n    return 1;}\r\n\r\n  return 0;              // it's OK\r\n  } // decCheckNumber\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decCheckInexact -- check a normal finite inexact result has digits */\r\n/*   dn is the number to check                                        */\r\n/*   set is the context (for status and precision)                    */\r\n/*   sets Invalid operation, etc., if some digits are missing         */\r\n/* [this check is not made for DECSUBSET compilation or when          */\r\n/* subnormal is not set]                                              */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decCheckInexact(const decNumber *dn, decContext *set) {\r\n  #if !DECSUBSET && DECEXTFLAG\r\n    if ((set->status & (DEC_Inexact|DEC_Subnormal))==DEC_Inexact\r\n     && (set->digits!=dn->digits) && !(dn->bits & DECSPECIAL)) {\r\n      #if DECTRACE || DECVERB\r\n      printf(\"Insufficient digits [%ld] on normal Inexact result.\\n\",\r\n             (LI)dn->digits);\r\n      decNumberShow(dn);\r\n      #endif\r\n      decContextSetStatus(set, DEC_Invalid_operation);\r\n      }\r\n  #else\r\n    // next is a noop for quiet compiler\r\n    if (dn!=NULL && dn->digits==0) set->status|=DEC_Invalid_operation;\r\n  #endif\r\n  return;\r\n  } // decCheckInexact\r\n#endif\r\n\r\n#if DECALLOC\r\n#undef malloc\r\n#undef free\r\n/* ------------------------------------------------------------------ */\r\n/* decMalloc -- accountable allocation routine                        */\r\n/*   n is the number of bytes to allocate                             */\r\n/*                                                                    */\r\n/* Semantics is the same as the stdlib malloc routine, but bytes      */\r\n/* allocated are accounted for globally, and corruption fences are    */\r\n/* added before and after the 'actual' storage.                       */\r\n/* ------------------------------------------------------------------ */\r\n/* This routine allocates storage with an extra twelve bytes; 8 are   */\r\n/* at the start and hold:                                             */\r\n/*   0-3 the original length requested                                */\r\n/*   4-7 buffer corruption detection fence (DECFENCE, x4)             */\r\n/* The 4 bytes at the end also hold a corruption fence (DECFENCE, x4) */\r\n/* ------------------------------------------------------------------ */\r\nstatic void *decMalloc(size_t n) {\r\n  uInt  size=n+12;                 // true size\r\n  void  *alloc;                    // -> allocated storage\r\n  uByte *b, *b0;                   // work\r\n  uInt  uiwork;                    // for macros\r\n\r\n  alloc=malloc(size);              // -> allocated storage\r\n  if (alloc==NULL) return NULL;    // out of strorage\r\n  b0=(uByte *)alloc;               // as bytes\r\n  decAllocBytes+=n;                // account for storage\r\n  UBFROMUI(alloc, n);              // save n\r\n  // printf(\" alloc ++ dAB: %ld (%ld)\\n\", (LI)decAllocBytes, (LI)n);\r\n  for (b=b0+4; b<b0+8; b++) *b=DECFENCE;\r\n  for (b=b0+n+8; b<b0+n+12; b++) *b=DECFENCE;\r\n  return b0+8;                     // -> play area\r\n  } // decMalloc\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decFree -- accountable free routine                                */\r\n/*   alloc is the storage to free                                     */\r\n/*                                                                    */\r\n/* Semantics is the same as the stdlib malloc routine, except that    */\r\n/* the global storage accounting is updated and the fences are        */\r\n/* checked to ensure that no routine has written 'out of bounds'.     */\r\n/* ------------------------------------------------------------------ */\r\n/* This routine first checks that the fences have not been corrupted. */\r\n/* It then frees the storage using the 'truw' storage address (that   */\r\n/* is, offset by 8).                                                  */\r\n/* ------------------------------------------------------------------ */\r\nstatic void decFree(void *alloc) {\r\n  uInt  n;                         // original length\r\n  uByte *b, *b0;                   // work\r\n  uInt  uiwork;                    // for macros\r\n\r\n  if (alloc==NULL) return;         // allowed; it's a nop\r\n  b0=(uByte *)alloc;               // as bytes\r\n  b0-=8;                           // -> true start of storage\r\n  n=UBTOUI(b0);                    // lift length\r\n  for (b=b0+4; b<b0+8; b++) if (*b!=DECFENCE)\r\n    printf(\"=== Corrupt byte [%02x] at offset %d from %ld ===\\n\", *b,\r\n           b-b0-8, (LI)b0);\r\n  for (b=b0+n+8; b<b0+n+12; b++) if (*b!=DECFENCE)\r\n    printf(\"=== Corrupt byte [%02x] at offset +%d from %ld, n=%ld ===\\n\", *b,\r\n           b-b0-8, (LI)b0, (LI)n);\r\n  free(b0);                        // drop the storage\r\n  decAllocBytes-=n;                // account for storage\r\n  // printf(\" free -- dAB: %d (%d)\\n\", decAllocBytes, -n);\r\n  } // decFree\r\n#define malloc(a) decMalloc(a)\r\n#define free(a) decFree(a)\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decNumber.h",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Number arithmetic module header                            */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2010.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#if !defined(DECNUMBER)\r\n  #define DECNUMBER\r\n  #define DECNAME     \"decNumber\"                       /* Short name */\r\n  #define DECFULLNAME \"Decimal Number Module\"         /* Verbose name */\r\n  #define DECAUTHOR   \"Mike Cowlishaw\"                /* Who to blame */\r\n\r\n  #if !defined(DECCONTEXT)\r\n    #include \"decContext.h\"\r\n  #endif\r\n\r\n  /* Bit settings for decNumber.bits                                  */\r\n  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */\r\n  #define DECINF    0x40      /* 1=Infinity                           */\r\n  #define DECNAN    0x20      /* 1=NaN                                */\r\n  #define DECSNAN   0x10      /* 1=sNaN                               */\r\n  /* The remaining bits are reserved; they must be 0                  */\r\n  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */\r\n\r\n  /* Define the decNumber data structure.  The size and shape of the  */\r\n  /* units array in the structure is determined by the following      */\r\n  /* constant.  This must not be changed without recompiling the      */\r\n  /* decNumber library modules. */\r\n\r\n  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */\r\n                              /* and <10; 3 or powers of 2 are best]. */\r\n\r\n  /* DECNUMDIGITS is the default number of digits that can be held in */\r\n  /* the structure.  If undefined, 1 is assumed and it is assumed     */\r\n  /* that the structure will be immediately followed by extra space,  */\r\n  /* as required.  DECNUMDIGITS is always >0.                         */\r\n  #if !defined(DECNUMDIGITS)\r\n    #define DECNUMDIGITS 1\r\n  #endif\r\n\r\n  /* The size (integer data type) of each unit is determined by the   */\r\n  /* number of digits it will hold.                                   */\r\n  #if   DECDPUN<=2\r\n    #define decNumberUnit uint8_t\r\n  #elif DECDPUN<=4\r\n    #define decNumberUnit uint16_t\r\n  #else\r\n    #define decNumberUnit uint32_t\r\n  #endif\r\n  /* The number of units needed is ceil(DECNUMDIGITS/DECDPUN)         */\r\n  #define DECNUMUNITS ((DECNUMDIGITS+DECDPUN-1)/DECDPUN)\r\n\r\n  /* The data structure... */\r\n  typedef struct {\r\n    int32_t digits;      /* Count of digits in the coefficient; >0    */\r\n    int32_t exponent;    /* Unadjusted exponent, unbiased, in         */\r\n                         /* range: -1999999997 through 999999999      */\r\n    uint8_t bits;        /* Indicator bits (see above)                */\r\n                         /* Coefficient, from least significant unit  */\r\n    decNumberUnit lsu[DECNUMUNITS];\r\n    } decNumber;\r\n\r\n  /* Notes:                                                           */\r\n  /* 1. If digits is > DECDPUN then there will one or more            */\r\n  /*    decNumberUnits immediately following the first element of lsu.*/\r\n  /*    These contain the remaining (more significant) digits of the  */\r\n  /*    number, and may be in the lsu array, or may be guaranteed by  */\r\n  /*    some other mechanism (such as being contained in another      */\r\n  /*    structure, or being overlaid on dynamically allocated         */\r\n  /*    storage).                                                     */\r\n  /*                                                                  */\r\n  /*    Each integer of the coefficient (except potentially the last) */\r\n  /*    contains DECDPUN digits (e.g., a value in the range 0 through */\r\n  /*    99999999 if DECDPUN is 8, or 0 through 999 if DECDPUN is 3).  */\r\n  /*                                                                  */\r\n  /* 2. A decNumber converted to a string may need up to digits+14    */\r\n  /*    characters.  The worst cases (non-exponential and exponential */\r\n  /*    formats) are -0.00000{9...}# and -9.{9...}E+999999999#        */\r\n  /*    (where # is '\\0')                                             */\r\n\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* decNumber public functions and macros                            */\r\n  /* ---------------------------------------------------------------- */\r\n  /* Conversions                                                      */\r\n  decNumber * decNumberFromInt32(decNumber *, int32_t);\r\n  decNumber * decNumberFromUInt32(decNumber *, uint32_t);\r\n  decNumber * decNumberFromString(decNumber *, const char *, decContext *);\r\n  char      * decNumberToString(const decNumber *, char *);\r\n  char      * decNumberToEngString(const decNumber *, char *);\r\n  uint32_t    decNumberToUInt32(const decNumber *, decContext *);\r\n  int32_t     decNumberToInt32(const decNumber *, decContext *);\r\n  uint8_t   * decNumberGetBCD(const decNumber *, uint8_t *);\r\n  decNumber * decNumberSetBCD(decNumber *, const uint8_t *, uint32_t);\r\n\r\n  /* Operators and elementary functions                               */\r\n  decNumber * decNumberAbs(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberAdd(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberAnd(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberCompare(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberCompareSignal(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberCompareTotal(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberCompareTotalMag(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberDivide(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberDivideInteger(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberExp(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberFMA(decNumber *, const decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberInvert(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberLn(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberLogB(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberLog10(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberMax(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberMaxMag(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberMin(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberMinMag(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberMinus(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberMultiply(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberNormalize(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberOr(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberPlus(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberPower(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberQuantize(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberReduce(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberRemainder(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberRemainderNear(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberRescale(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberRotate(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberSameQuantum(decNumber *, const decNumber *, const decNumber *);\r\n  decNumber * decNumberScaleB(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberShift(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberSquareRoot(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberSubtract(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberToIntegralExact(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberToIntegralValue(decNumber *, const decNumber *, decContext *);\r\n  decNumber * decNumberXor(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n\r\n  /* Utilities                                                        */\r\n  enum decClass decNumberClass(const decNumber *, decContext *);\r\n  const char * decNumberClassToString(enum decClass);\r\n  decNumber  * decNumberCopy(decNumber *, const decNumber *);\r\n  decNumber  * decNumberCopyAbs(decNumber *, const decNumber *);\r\n  decNumber  * decNumberCopyNegate(decNumber *, const decNumber *);\r\n  decNumber  * decNumberCopySign(decNumber *, const decNumber *, const decNumber *);\r\n  decNumber  * decNumberNextMinus(decNumber *, const decNumber *, decContext *);\r\n  decNumber  * decNumberNextPlus(decNumber *, const decNumber *, decContext *);\r\n  decNumber  * decNumberNextToward(decNumber *, const decNumber *, const decNumber *, decContext *);\r\n  decNumber  * decNumberTrim(decNumber *);\r\n  const char * decNumberVersion(void);\r\n  decNumber  * decNumberZero(decNumber *);\r\n\r\n  /* Functions for testing decNumbers (normality depends on context)  */\r\n  int32_t decNumberIsNormal(const decNumber *, decContext *);\r\n  int32_t decNumberIsSubnormal(const decNumber *, decContext *);\r\n\r\n  /* Macros for testing decNumber *dn                                 */\r\n  #define decNumberIsCanonical(dn) (1)  /* All decNumbers are saintly */\r\n  #define decNumberIsFinite(dn)    (((dn)->bits&DECSPECIAL)==0)\r\n  #define decNumberIsInfinite(dn)  (((dn)->bits&DECINF)!=0)\r\n  #define decNumberIsNaN(dn)       (((dn)->bits&(DECNAN|DECSNAN))!=0)\r\n  #define decNumberIsNegative(dn)  (((dn)->bits&DECNEG)!=0)\r\n  #define decNumberIsQNaN(dn)      (((dn)->bits&(DECNAN))!=0)\r\n  #define decNumberIsSNaN(dn)      (((dn)->bits&(DECSNAN))!=0)\r\n  #define decNumberIsSpecial(dn)   (((dn)->bits&DECSPECIAL)!=0)\r\n  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \\\r\n                                    && (dn)->digits==1 \\\r\n                                    && (((dn)->bits&DECSPECIAL)==0))\r\n  #define decNumberRadix(dn)       (10)\r\n\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decNumberLocal.h",
    "content": "/* ------------------------------------------------------------------ */\r\n/* decNumber package local type, tuning, and macro definitions        */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2010.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This header file is included by all modules in the decNumber       */\r\n/* library, and contains local type definitions, tuning parameters,   */\r\n/* etc.  It should not need to be used by application programs.       */\r\n/* decNumber.h or one of decDouble (etc.) must be included first.     */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#if !defined(DECNUMBERLOC)\r\n  #define DECNUMBERLOC\r\n  #define DECVERSION    \"decNumber 3.68\" /* Package Version [16 max.] */\r\n  #define DECNLAUTHOR   \"Mike Cowlishaw\"              /* Who to blame */\r\n\r\n  #include <stdlib.h>         /* for abs                              */\r\n  #include <string.h>         /* for memset, strcpy                   */\r\n\r\n  /* Conditional code flag -- set this to match hardware platform     */\r\n  #if !defined(DECLITEND)\r\n  #define DECLITEND 1         /* 1=little-endian, 0=big-endian        */\r\n  #endif\r\n\r\n  /* Conditional code flag -- set this to 1 for best performance      */\r\n  #if !defined(DECUSE64)\r\n  #define DECUSE64  1         /* 1=use int64s, 0=int32 & smaller only */\r\n  #endif\r\n\r\n  /* Conditional code flag -- set this to 0 to exclude printf calls   */\r\n  #if !defined(DECPRINT)\r\n  #define DECPRINT  1         /* 1=allow printf calls; 0=no printf    */\r\n  #endif\r\n\r\n  /* Conditional check flags -- set these to 0 for best performance   */\r\n  #if !defined(DECCHECK)\r\n  #define DECCHECK  0         /* 1 to enable robust checking          */\r\n  #endif\r\n  #if !defined(DECALLOC)\r\n  #define DECALLOC  0         /* 1 to enable memory accounting        */\r\n  #endif\r\n  #if !defined(DECTRACE)\r\n  #define DECTRACE  0         /* 1 to trace certain internals, etc.   */\r\n  #endif\r\n\r\n  /* Tuning parameter for decNumber (arbitrary precision) module      */\r\n  #if !defined(DECBUFFER)\r\n  #define DECBUFFER 36        /* Size basis for local buffers.  This  */\r\n                              /* should be a common maximum precision */\r\n                              /* rounded up to a multiple of 4; must  */\r\n                              /* be zero or positive.                 */\r\n  #endif\r\n\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* Check parameter dependencies                                     */\r\n  /* ---------------------------------------------------------------- */\r\n  #if DECCHECK & !DECPRINT\r\n    #error DECCHECK needs DECPRINT to be useful\r\n  #endif\r\n  #if DECALLOC & !DECPRINT\r\n    #error DECALLOC needs DECPRINT to be useful\r\n  #endif\r\n  #if DECTRACE & !DECPRINT\r\n    #error DECTRACE needs DECPRINT to be useful\r\n  #endif\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* Definitions for all modules (general-purpose)                    */\r\n  /* ---------------------------------------------------------------- */\r\n\r\n  /* Local names for common types -- for safety, decNumber modules do */\r\n  /* not use int or long directly.                                    */\r\n  #define Flag   uint8_t\r\n  #define Byte   int8_t\r\n  #define uByte  uint8_t\r\n  #define Short  int16_t\r\n  #define uShort uint16_t\r\n  #define Int    int32_t\r\n  #define uInt   uint32_t\r\n  #define Unit   decNumberUnit\r\n  #if DECUSE64\r\n  #define Long   int64_t\r\n  #define uLong  uint64_t\r\n  #endif\r\n\r\n  /* Development-use definitions                                      */\r\n  typedef long int LI;        /* for printf arguments only            */\r\n  #define DECNOINT  0         /* 1 to check no internal use of 'int'  */\r\n                              /*   or stdint types                    */\r\n  #if DECNOINT\r\n    /* if these interfere with your C includes, do not set DECNOINT   */\r\n    #define int     ?         /* enable to ensure that plain C 'int'  */\r\n    #define long    ??        /* .. or 'long' types are not used      */\r\n  #endif\r\n\r\n  /* Shared lookup tables                                             */\r\n  extern const uByte  DECSTICKYTAB[10]; /* re-round digits if sticky  */\r\n  extern const uInt   DECPOWERS[10];    /* powers of ten table        */\r\n  /* The following are included from decDPD.h                         */\r\n  extern const uShort DPD2BIN[1024];    /* DPD -> 0-999               */\r\n  extern const uShort BIN2DPD[1000];    /* 0-999 -> DPD               */\r\n  extern const uInt   DPD2BINK[1024];   /* DPD -> 0-999000            */\r\n  extern const uInt   DPD2BINM[1024];   /* DPD -> 0-999000000         */\r\n  extern const uByte  DPD2BCD8[4096];   /* DPD -> ddd + len           */\r\n  extern const uByte  BIN2BCD8[4000];   /* 0-999 -> ddd + len         */\r\n  extern const uShort BCD2DPD[2458];    /* 0-0x999 -> DPD (0x999=2457)*/\r\n\r\n  /* LONGMUL32HI -- set w=(u*v)>>32, where w, u, and v are uInts      */\r\n  /* (that is, sets w to be the high-order word of the 64-bit result; */\r\n  /* the low-order word is simply u*v.)                               */\r\n  /* This version is derived from Knuth via Hacker's Delight;         */\r\n  /* it seems to optimize better than some others tried               */\r\n  #define LONGMUL32HI(w, u, v) {             \\\r\n    uInt u0, u1, v0, v1, w0, w1, w2, t;      \\\r\n    u0=u & 0xffff; u1=u>>16;                 \\\r\n    v0=v & 0xffff; v1=v>>16;                 \\\r\n    w0=u0*v0;                                \\\r\n    t=u1*v0 + (w0>>16);                      \\\r\n    w1=t & 0xffff; w2=t>>16;                 \\\r\n    w1=u0*v1 + w1;                           \\\r\n    (w)=u1*v1 + w2 + (w1>>16);}\r\n\r\n  /* ROUNDUP -- round an integer up to a multiple of n                */\r\n  #define ROUNDUP(i, n) ((((i)+(n)-1)/n)*n)\r\n  #define ROUNDUP4(i)   (((i)+3)&~3)    /* special for n=4            */\r\n\r\n  /* ROUNDDOWN -- round an integer down to a multiple of n            */\r\n  #define ROUNDDOWN(i, n) (((i)/n)*n)\r\n  #define ROUNDDOWN4(i)   ((i)&~3)      /* special for n=4            */\r\n\r\n  /* References to multi-byte sequences under different sizes; these  */\r\n  /* require locally declared variables, but do not violate strict    */\r\n  /* aliasing or alignment (as did the UINTAT simple cast to uInt).   */\r\n  /* Variables needed are uswork, uiwork, etc. [so do not use at same */\r\n  /* level in an expression, e.g., UBTOUI(x)==UBTOUI(y) may fail].    */\r\n\r\n  /* Return a uInt, etc., from bytes starting at a char* or uByte*    */\r\n  #define UBTOUS(b)  (memcpy((void *)&uswork, b, 2), uswork)\r\n  #define UBTOUI(b)  (memcpy((void *)&uiwork, b, 4), uiwork)\r\n\r\n  /* Store a uInt, etc., into bytes starting at a char* or uByte*.    */\r\n  /* Returns i, evaluated, for convenience; has to use uiwork because */\r\n  /* i may be an expression.                                          */\r\n  #define UBFROMUS(b, i)  (uswork=(i), memcpy(b, (void *)&uswork, 2), uswork)\r\n  #define UBFROMUI(b, i)  (uiwork=(i), memcpy(b, (void *)&uiwork, 4), uiwork)\r\n\r\n  /* X10 and X100 -- multiply integer i by 10 or 100                  */\r\n  /* [shifts are usually faster than multiply; could be conditional]  */\r\n  #define X10(i)  (((i)<<1)+((i)<<3))\r\n  #define X100(i) (((i)<<2)+((i)<<5)+((i)<<6))\r\n\r\n  /* MAXI and MINI -- general max & min (not in ANSI) for integers    */\r\n  #define MAXI(x,y) ((x)<(y)?(y):(x))\r\n  #define MINI(x,y) ((x)>(y)?(y):(x))\r\n\r\n  /* Useful constants                                                 */\r\n  #define BILLION      1000000000            /* 10**9                 */\r\n  /* CHARMASK: 0x30303030 for ASCII/UTF8; 0xF0F0F0F0 for EBCDIC       */\r\n  #define CHARMASK ((((((((uInt)'0')<<8)+'0')<<8)+'0')<<8)+'0')\r\n\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* Definitions for arbitary-precision modules (only valid after     */\r\n  /* decNumber.h has been included)                                   */\r\n  /* ---------------------------------------------------------------- */\r\n\r\n  /* Limits and constants                                             */\r\n  #define DECNUMMAXP 999999999  /* maximum precision code can handle  */\r\n  #define DECNUMMAXE 999999999  /* maximum adjusted exponent ditto    */\r\n  #define DECNUMMINE -999999999 /* minimum adjusted exponent ditto    */\r\n  #if (DECNUMMAXP != DEC_MAX_DIGITS)\r\n    #error Maximum digits mismatch\r\n  #endif\r\n  #if (DECNUMMAXE != DEC_MAX_EMAX)\r\n    #error Maximum exponent mismatch\r\n  #endif\r\n  #if (DECNUMMINE != DEC_MIN_EMIN)\r\n    #error Minimum exponent mismatch\r\n  #endif\r\n\r\n  /* Set DECDPUNMAX -- the maximum integer that fits in DECDPUN       */\r\n  /* digits, and D2UTABLE -- the initializer for the D2U table        */\r\n  #if   DECDPUN==1\r\n    #define DECDPUNMAX 9\r\n    #define D2UTABLE {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,  \\\r\n                      18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, \\\r\n                      33,34,35,36,37,38,39,40,41,42,43,44,45,46,47, \\\r\n                      48,49}\r\n  #elif DECDPUN==2\r\n    #define DECDPUNMAX 99\r\n    #define D2UTABLE {0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,  \\\r\n                      11,11,12,12,13,13,14,14,15,15,16,16,17,17,18, \\\r\n                      18,19,19,20,20,21,21,22,22,23,23,24,24,25}\r\n  #elif DECDPUN==3\r\n    #define DECDPUNMAX 999\r\n    #define D2UTABLE {0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,  \\\r\n                      8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13, \\\r\n                      13,14,14,14,15,15,15,16,16,16,17}\r\n  #elif DECDPUN==4\r\n    #define DECDPUNMAX 9999\r\n    #define D2UTABLE {0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,  \\\r\n                      6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11, \\\r\n                      11,11,11,12,12,12,12,13}\r\n  #elif DECDPUN==5\r\n    #define DECDPUNMAX 99999\r\n    #define D2UTABLE {0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,  \\\r\n                      5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,  \\\r\n                      9,9,10,10,10,10}\r\n  #elif DECDPUN==6\r\n    #define DECDPUNMAX 999999\r\n    #define D2UTABLE {0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,  \\\r\n                      4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8,  \\\r\n                      8,8,8,8,8,9}\r\n  #elif DECDPUN==7\r\n    #define DECDPUNMAX 9999999\r\n    #define D2UTABLE {0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,  \\\r\n                      4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7,  \\\r\n                      7,7,7,7,7,7}\r\n  #elif DECDPUN==8\r\n    #define DECDPUNMAX 99999999\r\n    #define D2UTABLE {0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,  \\\r\n                      3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,  \\\r\n                      6,6,6,6,6,7}\r\n  #elif DECDPUN==9\r\n    #define DECDPUNMAX 999999999\r\n    #define D2UTABLE {0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3,  \\\r\n                      3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,  \\\r\n                      5,5,6,6,6,6}\r\n  #elif defined(DECDPUN)\r\n    #error DECDPUN must be in the range 1-9\r\n  #endif\r\n\r\n  /* ----- Shared data (in decNumber.c) ----- */\r\n  /* Public lookup table used by the D2U macro (see below)            */\r\n  #define DECMAXD2U 49\r\n  extern const uByte d2utable[DECMAXD2U+1];\r\n\r\n  /* ----- Macros ----- */\r\n  /* ISZERO -- return true if decNumber dn is a zero                  */\r\n  /* [performance-critical in some situations]                        */\r\n  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */\r\n\r\n  /* D2U -- return the number of Units needed to hold d digits        */\r\n  /* (runtime version, with table lookaside for small d)              */\r\n  #if DECDPUN==8\r\n    #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+7)>>3))\r\n  #elif DECDPUN==4\r\n    #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+3)>>2))\r\n  #else\r\n    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)\r\n  #endif\r\n  /* SD2U -- static D2U macro (for compile-time calculation)          */\r\n  #define SD2U(d) (((d)+DECDPUN-1)/DECDPUN)\r\n\r\n  /* MSUDIGITS -- returns digits in msu, from digits, calculated      */\r\n  /* using D2U                                                        */\r\n  #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)\r\n\r\n  /* D2N -- return the number of decNumber structs that would be      */\r\n  /* needed to contain that number of digits (and the initial         */\r\n  /* decNumber struct) safely.  Note that one Unit is included in the */\r\n  /* initial structure.  Used for allocating space that is aligned on */\r\n  /* a decNumber struct boundary. */\r\n  #define D2N(d) \\\r\n    ((((SD2U(d)-1)*sizeof(Unit))+sizeof(decNumber)*2-1)/sizeof(decNumber))\r\n\r\n  /* TODIGIT -- macro to remove the leading digit from the unsigned   */\r\n  /* integer u at column cut (counting from the right, LSD=0) and     */\r\n  /* place it as an ASCII character into the character pointed to by  */\r\n  /* c.  Note that cut must be <= 9, and the maximum value for u is   */\r\n  /* 2,000,000,000 (as is needed for negative exponents of            */\r\n  /* subnormals).  The unsigned integer pow is used as a temporary    */\r\n  /* variable. */\r\n  #define TODIGIT(u, cut, c, pow) {       \\\r\n    *(c)='0';                             \\\r\n    pow=DECPOWERS[cut]*2;                 \\\r\n    if ((u)>pow) {                        \\\r\n      pow*=4;                             \\\r\n      if ((u)>=pow) {(u)-=pow; *(c)+=8;}  \\\r\n      pow/=2;                             \\\r\n      if ((u)>=pow) {(u)-=pow; *(c)+=4;}  \\\r\n      pow/=2;                             \\\r\n      }                                   \\\r\n    if ((u)>=pow) {(u)-=pow; *(c)+=2;}    \\\r\n    pow/=2;                               \\\r\n    if ((u)>=pow) {(u)-=pow; *(c)+=1;}    \\\r\n    }\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* Definitions for fixed-precision modules (only valid after        */\r\n  /* decSingle.h, decDouble.h, or decQuad.h has been included)        */\r\n  /* ---------------------------------------------------------------- */\r\n\r\n  /* bcdnum -- a structure describing a format-independent finite     */\r\n  /* number, whose coefficient is a string of bcd8 uBytes             */\r\n  typedef struct {\r\n    uByte   *msd;             /* -> most significant digit            */\r\n    uByte   *lsd;             /* -> least ditto                       */\r\n    uInt     sign;            /* 0=positive, DECFLOAT_Sign=negative   */\r\n    Int      exponent;        /* Unadjusted signed exponent (q), or   */\r\n                              /* DECFLOAT_NaN etc. for a special      */\r\n    } bcdnum;\r\n\r\n  /* Test if exponent or bcdnum exponent must be a special, etc.      */\r\n  #define EXPISSPECIAL(exp) ((exp)>=DECFLOAT_MinSp)\r\n  #define EXPISINF(exp) (exp==DECFLOAT_Inf)\r\n  #define EXPISNAN(exp) (exp==DECFLOAT_qNaN || exp==DECFLOAT_sNaN)\r\n  #define NUMISSPECIAL(num) (EXPISSPECIAL((num)->exponent))\r\n\r\n  /* Refer to a 32-bit word or byte in a decFloat (df) by big-endian  */\r\n  /* (array) notation (the 0 word or byte contains the sign bit),     */\r\n  /* automatically adjusting for endianness; similarly address a word */\r\n  /* in the next-wider format (decFloatWider, or dfw)                 */\r\n  #define DECWORDS  (DECBYTES/4)\r\n  #define DECWWORDS (DECWBYTES/4)\r\n  #if DECLITEND\r\n    #define DFBYTE(df, off)   ((df)->bytes[DECBYTES-1-(off)])\r\n    #define DFWORD(df, off)   ((df)->words[DECWORDS-1-(off)])\r\n    #define DFWWORD(dfw, off) ((dfw)->words[DECWWORDS-1-(off)])\r\n  #else\r\n    #define DFBYTE(df, off)   ((df)->bytes[off])\r\n    #define DFWORD(df, off)   ((df)->words[off])\r\n    #define DFWWORD(dfw, off) ((dfw)->words[off])\r\n  #endif\r\n\r\n  /* Tests for sign or specials, directly on DECFLOATs                */\r\n  #define DFISSIGNED(df)  ((DFWORD(df, 0)&0x80000000)!=0)\r\n  #define DFISSPECIAL(df) ((DFWORD(df, 0)&0x78000000)==0x78000000)\r\n  #define DFISINF(df)     ((DFWORD(df, 0)&0x7c000000)==0x78000000)\r\n  #define DFISNAN(df)     ((DFWORD(df, 0)&0x7c000000)==0x7c000000)\r\n  #define DFISQNAN(df)    ((DFWORD(df, 0)&0x7e000000)==0x7c000000)\r\n  #define DFISSNAN(df)    ((DFWORD(df, 0)&0x7e000000)==0x7e000000)\r\n\r\n  /* Shared lookup tables                                             */\r\n  extern const uInt   DECCOMBMSD[64];   /* Combination field -> MSD   */\r\n  extern const uInt   DECCOMBFROM[48];  /* exp+msd -> Combination     */\r\n\r\n  /* Private generic (utility) routine                                */\r\n  #if DECCHECK || DECTRACE\r\n    extern void decShowNum(const bcdnum *, const char *);\r\n  #endif\r\n\r\n  /* Format-dependent macros and constants                            */\r\n  #if defined(DECPMAX)\r\n\r\n    /* Useful constants                                               */\r\n    #define DECPMAX9  (ROUNDUP(DECPMAX, 9)/9)  /* 'Pmax' in 10**9s    */\r\n    /* Top words for a zero                                           */\r\n    #define SINGLEZERO   0x22500000\r\n    #define DOUBLEZERO   0x22380000\r\n    #define QUADZERO     0x22080000\r\n    /* [ZEROWORD is defined to be one of these in the DFISZERO macro] */\r\n\r\n    /* Format-dependent common tests:                                 */\r\n    /*   DFISZERO   -- test for (any) zero                            */\r\n    /*   DFISCCZERO -- test for coefficient continuation being zero   */\r\n    /*   DFISCC01   -- test for coefficient contains only 0s and 1s   */\r\n    /*   DFISINT    -- test for finite and exponent q=0               */\r\n    /*   DFISUINT01 -- test for sign=0, finite, exponent q=0, and     */\r\n    /*                 MSD=0 or 1                                     */\r\n    /*   ZEROWORD is also defined here.                               */\r\n    /*                                                                */\r\n    /* In DFISZERO the first test checks the least-significant word   */\r\n    /* (most likely to be non-zero); the penultimate tests MSD and    */\r\n    /* DPDs in the signword, and the final test excludes specials and */\r\n    /* MSD>7.  DFISINT similarly has to allow for the two forms of    */\r\n    /* MSD codes.  DFISUINT01 only has to allow for one form of MSD   */\r\n    /* code.                                                          */\r\n    #if DECPMAX==7\r\n      #define ZEROWORD SINGLEZERO\r\n      /* [test macros not needed except for Zero]                     */\r\n      #define DFISZERO(df)  ((DFWORD(df, 0)&0x1c0fffff)==0         \\\r\n                          && (DFWORD(df, 0)&0x60000000)!=0x60000000)\r\n    #elif DECPMAX==16\r\n      #define ZEROWORD DOUBLEZERO\r\n      #define DFISZERO(df)  ((DFWORD(df, 1)==0                     \\\r\n                          && (DFWORD(df, 0)&0x1c03ffff)==0         \\\r\n                          && (DFWORD(df, 0)&0x60000000)!=0x60000000))\r\n      #define DFISINT(df) ((DFWORD(df, 0)&0x63fc0000)==0x22380000  \\\r\n                         ||(DFWORD(df, 0)&0x7bfc0000)==0x6a380000)\r\n      #define DFISUINT01(df) ((DFWORD(df, 0)&0xfbfc0000)==0x22380000)\r\n      #define DFISCCZERO(df) (DFWORD(df, 1)==0                     \\\r\n                          && (DFWORD(df, 0)&0x0003ffff)==0)\r\n      #define DFISCC01(df)  ((DFWORD(df, 0)&~0xfffc9124)==0        \\\r\n                          && (DFWORD(df, 1)&~0x49124491)==0)\r\n    #elif DECPMAX==34\r\n      #define ZEROWORD QUADZERO\r\n      #define DFISZERO(df)  ((DFWORD(df, 3)==0                     \\\r\n                          &&  DFWORD(df, 2)==0                     \\\r\n                          &&  DFWORD(df, 1)==0                     \\\r\n                          && (DFWORD(df, 0)&0x1c003fff)==0         \\\r\n                          && (DFWORD(df, 0)&0x60000000)!=0x60000000))\r\n      #define DFISINT(df) ((DFWORD(df, 0)&0x63ffc000)==0x22080000  \\\r\n                         ||(DFWORD(df, 0)&0x7bffc000)==0x6a080000)\r\n      #define DFISUINT01(df) ((DFWORD(df, 0)&0xfbffc000)==0x22080000)\r\n      #define DFISCCZERO(df) (DFWORD(df, 3)==0                     \\\r\n                          &&  DFWORD(df, 2)==0                     \\\r\n                          &&  DFWORD(df, 1)==0                     \\\r\n                          && (DFWORD(df, 0)&0x00003fff)==0)\r\n\r\n      #define DFISCC01(df)   ((DFWORD(df, 0)&~0xffffc912)==0       \\\r\n                          &&  (DFWORD(df, 1)&~0x44912449)==0       \\\r\n                          &&  (DFWORD(df, 2)&~0x12449124)==0       \\\r\n                          &&  (DFWORD(df, 3)&~0x49124491)==0)\r\n    #endif\r\n\r\n    /* Macros to test if a certain 10 bits of a uInt or pair of uInts */\r\n    /* are a canonical declet [higher or lower bits are ignored].     */\r\n    /* declet is at offset 0 (from the right) in a uInt:              */\r\n    #define CANONDPD(dpd) (((dpd)&0x300)==0 || ((dpd)&0x6e)!=0x6e)\r\n    /* declet is at offset k (a multiple of 2) in a uInt:             */\r\n    #define CANONDPDOFF(dpd, k) (((dpd)&(0x300<<(k)))==0            \\\r\n      || ((dpd)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k)))\r\n    /* declet is at offset k (a multiple of 2) in a pair of uInts:    */\r\n    /* [the top 2 bits will always be in the more-significant uInt]   */\r\n    #define CANONDPDTWO(hi, lo, k) (((hi)&(0x300>>(32-(k))))==0     \\\r\n      || ((hi)&(0x6e>>(32-(k))))!=(0x6e>>(32-(k)))                  \\\r\n      || ((lo)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k)))\r\n\r\n    /* Macro to test whether a full-length (length DECPMAX) BCD8      */\r\n    /* coefficient, starting at uByte u, is all zeros                 */\r\n    /* Test just the LSWord first, then the remainder as a sequence   */\r\n    /* of tests in order to avoid same-level use of UBTOUI            */\r\n    #if DECPMAX==7\r\n      #define ISCOEFFZERO(u) (                                      \\\r\n           UBTOUI((u)+DECPMAX-4)==0                                 \\\r\n        && UBTOUS((u)+DECPMAX-6)==0                                 \\\r\n        && *(u)==0)\r\n    #elif DECPMAX==16\r\n      #define ISCOEFFZERO(u) (                                      \\\r\n           UBTOUI((u)+DECPMAX-4)==0                                 \\\r\n        && UBTOUI((u)+DECPMAX-8)==0                                 \\\r\n        && UBTOUI((u)+DECPMAX-12)==0                                \\\r\n        && UBTOUI(u)==0)\r\n    #elif DECPMAX==34\r\n      #define ISCOEFFZERO(u) (                                      \\\r\n           UBTOUI((u)+DECPMAX-4)==0                                 \\\r\n        && UBTOUI((u)+DECPMAX-8)==0                                 \\\r\n        && UBTOUI((u)+DECPMAX-12)==0                                \\\r\n        && UBTOUI((u)+DECPMAX-16)==0                                \\\r\n        && UBTOUI((u)+DECPMAX-20)==0                                \\\r\n        && UBTOUI((u)+DECPMAX-24)==0                                \\\r\n        && UBTOUI((u)+DECPMAX-28)==0                                \\\r\n        && UBTOUI((u)+DECPMAX-32)==0                                \\\r\n        && UBTOUS(u)==0)\r\n    #endif\r\n\r\n    /* Macros and masks for the sign, exponent continuation, and MSD  */\r\n    /* Get the sign as DECFLOAT_Sign or 0                             */\r\n    #define GETSIGN(df) (DFWORD(df, 0)&0x80000000)\r\n    /* Get the exponent continuation from a decFloat *df as an Int    */\r\n    #define GETECON(df) ((Int)((DFWORD((df), 0)&0x03ffffff)>>(32-6-DECECONL)))\r\n    /* Ditto, from the next-wider format                              */\r\n    #define GETWECON(df) ((Int)((DFWWORD((df), 0)&0x03ffffff)>>(32-6-DECWECONL)))\r\n    /* Get the biased exponent similarly                              */\r\n    #define GETEXP(df)  ((Int)(DECCOMBEXP[DFWORD((df), 0)>>26]+GETECON(df)))\r\n    /* Get the unbiased exponent similarly                            */\r\n    #define GETEXPUN(df) ((Int)GETEXP(df)-DECBIAS)\r\n    /* Get the MSD similarly (as uInt)                                */\r\n    #define GETMSD(df)   (DECCOMBMSD[DFWORD((df), 0)>>26])\r\n\r\n    /* Compile-time computes of the exponent continuation field masks */\r\n    /* full exponent continuation field:                              */\r\n    #define ECONMASK ((0x03ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))\r\n    /* same, not including its first digit (the qNaN/sNaN selector):  */\r\n    #define ECONNANMASK ((0x01ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))\r\n\r\n    /* Macros to decode the coefficient in a finite decFloat *df into */\r\n    /* a BCD string (uByte *bcdin) of length DECPMAX uBytes.          */\r\n\r\n    /* In-line sequence to convert least significant 10 bits of uInt  */\r\n    /* dpd to three BCD8 digits starting at uByte u.  Note that an    */\r\n    /* extra byte is written to the right of the three digits because */\r\n    /* four bytes are moved at a time for speed; the alternative      */\r\n    /* macro moves exactly three bytes (usually slower).              */\r\n    #define dpd2bcd8(u, dpd)  memcpy(u, &DPD2BCD8[((dpd)&0x3ff)*4], 4)\r\n    #define dpd2bcd83(u, dpd) memcpy(u, &DPD2BCD8[((dpd)&0x3ff)*4], 3)\r\n\r\n    /* Decode the declets.  After extracting each one, it is decoded  */\r\n    /* to BCD8 using a table lookup (also used for variable-length    */\r\n    /* decode).  Each DPD decode is 3 bytes BCD8 plus a one-byte      */\r\n    /* length which is not used, here).  Fixed-length 4-byte moves    */\r\n    /* are fast, however, almost everywhere, and so are used except   */\r\n    /* for the final three bytes (to avoid overrun).  The code below  */\r\n    /* is 36 instructions for Doubles and about 70 for Quads, even    */\r\n    /* on IA32.                                                       */\r\n\r\n    /* Two macros are defined for each format:                        */\r\n    /*   GETCOEFF extracts the coefficient of the current format      */\r\n    /*   GETWCOEFF extracts the coefficient of the next-wider format. */\r\n    /* The latter is a copy of the next-wider GETCOEFF using DFWWORD. */\r\n\r\n    #if DECPMAX==7\r\n    #define GETCOEFF(df, bcd) {                          \\\r\n      uInt sourhi=DFWORD(df, 0);                         \\\r\n      *(bcd)=(uByte)DECCOMBMSD[sourhi>>26];              \\\r\n      dpd2bcd8(bcd+1, sourhi>>10);                       \\\r\n      dpd2bcd83(bcd+4, sourhi);}\r\n    #define GETWCOEFF(df, bcd) {                         \\\r\n      uInt sourhi=DFWWORD(df, 0);                        \\\r\n      uInt sourlo=DFWWORD(df, 1);                        \\\r\n      *(bcd)=(uByte)DECCOMBMSD[sourhi>>26];              \\\r\n      dpd2bcd8(bcd+1, sourhi>>8);                        \\\r\n      dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30));       \\\r\n      dpd2bcd8(bcd+7, sourlo>>20);                       \\\r\n      dpd2bcd8(bcd+10, sourlo>>10);                      \\\r\n      dpd2bcd83(bcd+13, sourlo);}\r\n\r\n    #elif DECPMAX==16\r\n    #define GETCOEFF(df, bcd) {                          \\\r\n      uInt sourhi=DFWORD(df, 0);                         \\\r\n      uInt sourlo=DFWORD(df, 1);                         \\\r\n      *(bcd)=(uByte)DECCOMBMSD[sourhi>>26];              \\\r\n      dpd2bcd8(bcd+1, sourhi>>8);                        \\\r\n      dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30));       \\\r\n      dpd2bcd8(bcd+7, sourlo>>20);                       \\\r\n      dpd2bcd8(bcd+10, sourlo>>10);                      \\\r\n      dpd2bcd83(bcd+13, sourlo);}\r\n    #define GETWCOEFF(df, bcd) {                         \\\r\n      uInt sourhi=DFWWORD(df, 0);                        \\\r\n      uInt sourmh=DFWWORD(df, 1);                        \\\r\n      uInt sourml=DFWWORD(df, 2);                        \\\r\n      uInt sourlo=DFWWORD(df, 3);                        \\\r\n      *(bcd)=(uByte)DECCOMBMSD[sourhi>>26];              \\\r\n      dpd2bcd8(bcd+1, sourhi>>4);                        \\\r\n      dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26));     \\\r\n      dpd2bcd8(bcd+7, sourmh>>16);                       \\\r\n      dpd2bcd8(bcd+10, sourmh>>6);                       \\\r\n      dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28));    \\\r\n      dpd2bcd8(bcd+16, sourml>>18);                      \\\r\n      dpd2bcd8(bcd+19, sourml>>8);                       \\\r\n      dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30));    \\\r\n      dpd2bcd8(bcd+25, sourlo>>20);                      \\\r\n      dpd2bcd8(bcd+28, sourlo>>10);                      \\\r\n      dpd2bcd83(bcd+31, sourlo);}\r\n\r\n    #elif DECPMAX==34\r\n    #define GETCOEFF(df, bcd) {                          \\\r\n      uInt sourhi=DFWORD(df, 0);                         \\\r\n      uInt sourmh=DFWORD(df, 1);                         \\\r\n      uInt sourml=DFWORD(df, 2);                         \\\r\n      uInt sourlo=DFWORD(df, 3);                         \\\r\n      *(bcd)=(uByte)DECCOMBMSD[sourhi>>26];              \\\r\n      dpd2bcd8(bcd+1, sourhi>>4);                        \\\r\n      dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26));     \\\r\n      dpd2bcd8(bcd+7, sourmh>>16);                       \\\r\n      dpd2bcd8(bcd+10, sourmh>>6);                       \\\r\n      dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28));    \\\r\n      dpd2bcd8(bcd+16, sourml>>18);                      \\\r\n      dpd2bcd8(bcd+19, sourml>>8);                       \\\r\n      dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30));    \\\r\n      dpd2bcd8(bcd+25, sourlo>>20);                      \\\r\n      dpd2bcd8(bcd+28, sourlo>>10);                      \\\r\n      dpd2bcd83(bcd+31, sourlo);}\r\n\r\n      #define GETWCOEFF(df, bcd) {??} /* [should never be used]       */\r\n    #endif\r\n\r\n    /* Macros to decode the coefficient in a finite decFloat *df into */\r\n    /* a base-billion uInt array, with the least-significant          */\r\n    /* 0-999999999 'digit' at offset 0.                               */\r\n\r\n    /* Decode the declets.  After extracting each one, it is decoded  */\r\n    /* to binary using a table lookup.  Three tables are used; one    */\r\n    /* the usual DPD to binary, the other two pre-multiplied by 1000  */\r\n    /* and 1000000 to avoid multiplication during decode.  These      */\r\n    /* tables can also be used for multiplying up the MSD as the DPD  */\r\n    /* code for 0 through 9 is the identity.                          */\r\n    #define DPD2BIN0 DPD2BIN         /* for prettier code             */\r\n\r\n    #if DECPMAX==7\r\n    #define GETCOEFFBILL(df, buf) {                           \\\r\n      uInt sourhi=DFWORD(df, 0);                              \\\r\n      (buf)[0]=DPD2BIN0[sourhi&0x3ff]                         \\\r\n              +DPD2BINK[(sourhi>>10)&0x3ff]                   \\\r\n              +DPD2BINM[DECCOMBMSD[sourhi>>26]];}\r\n\r\n    #elif DECPMAX==16\r\n    #define GETCOEFFBILL(df, buf) {                           \\\r\n      uInt sourhi, sourlo;                                    \\\r\n      sourlo=DFWORD(df, 1);                                   \\\r\n      (buf)[0]=DPD2BIN0[sourlo&0x3ff]                         \\\r\n              +DPD2BINK[(sourlo>>10)&0x3ff]                   \\\r\n              +DPD2BINM[(sourlo>>20)&0x3ff];                  \\\r\n      sourhi=DFWORD(df, 0);                                   \\\r\n      (buf)[1]=DPD2BIN0[((sourhi<<2) | (sourlo>>30))&0x3ff]   \\\r\n              +DPD2BINK[(sourhi>>8)&0x3ff]                    \\\r\n              +DPD2BINM[DECCOMBMSD[sourhi>>26]];}\r\n\r\n    #elif DECPMAX==34\r\n    #define GETCOEFFBILL(df, buf) {                           \\\r\n      uInt sourhi, sourmh, sourml, sourlo;                    \\\r\n      sourlo=DFWORD(df, 3);                                   \\\r\n      (buf)[0]=DPD2BIN0[sourlo&0x3ff]                         \\\r\n              +DPD2BINK[(sourlo>>10)&0x3ff]                   \\\r\n              +DPD2BINM[(sourlo>>20)&0x3ff];                  \\\r\n      sourml=DFWORD(df, 2);                                   \\\r\n      (buf)[1]=DPD2BIN0[((sourml<<2) | (sourlo>>30))&0x3ff]   \\\r\n              +DPD2BINK[(sourml>>8)&0x3ff]                    \\\r\n              +DPD2BINM[(sourml>>18)&0x3ff];                  \\\r\n      sourmh=DFWORD(df, 1);                                   \\\r\n      (buf)[2]=DPD2BIN0[((sourmh<<4) | (sourml>>28))&0x3ff]   \\\r\n              +DPD2BINK[(sourmh>>6)&0x3ff]                    \\\r\n              +DPD2BINM[(sourmh>>16)&0x3ff];                  \\\r\n      sourhi=DFWORD(df, 0);                                   \\\r\n      (buf)[3]=DPD2BIN0[((sourhi<<6) | (sourmh>>26))&0x3ff]   \\\r\n              +DPD2BINK[(sourhi>>4)&0x3ff]                    \\\r\n              +DPD2BINM[DECCOMBMSD[sourhi>>26]];}\r\n\r\n    #endif\r\n\r\n    /* Macros to decode the coefficient in a finite decFloat *df into */\r\n    /* a base-thousand uInt array (of size DECLETS+1, to allow for    */\r\n    /* the MSD), with the least-significant 0-999 'digit' at offset 0.*/\r\n\r\n    /* Decode the declets.  After extracting each one, it is decoded  */\r\n    /* to binary using a table lookup.                                */\r\n    #if DECPMAX==7\r\n    #define GETCOEFFTHOU(df, buf) {                           \\\r\n      uInt sourhi=DFWORD(df, 0);                              \\\r\n      (buf)[0]=DPD2BIN[sourhi&0x3ff];                         \\\r\n      (buf)[1]=DPD2BIN[(sourhi>>10)&0x3ff];                   \\\r\n      (buf)[2]=DECCOMBMSD[sourhi>>26];}\r\n\r\n    #elif DECPMAX==16\r\n    #define GETCOEFFTHOU(df, buf) {                           \\\r\n      uInt sourhi, sourlo;                                    \\\r\n      sourlo=DFWORD(df, 1);                                   \\\r\n      (buf)[0]=DPD2BIN[sourlo&0x3ff];                         \\\r\n      (buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff];                   \\\r\n      (buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff];                   \\\r\n      sourhi=DFWORD(df, 0);                                   \\\r\n      (buf)[3]=DPD2BIN[((sourhi<<2) | (sourlo>>30))&0x3ff];   \\\r\n      (buf)[4]=DPD2BIN[(sourhi>>8)&0x3ff];                    \\\r\n      (buf)[5]=DECCOMBMSD[sourhi>>26];}\r\n\r\n    #elif DECPMAX==34\r\n    #define GETCOEFFTHOU(df, buf) {                           \\\r\n      uInt sourhi, sourmh, sourml, sourlo;                    \\\r\n      sourlo=DFWORD(df, 3);                                   \\\r\n      (buf)[0]=DPD2BIN[sourlo&0x3ff];                         \\\r\n      (buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff];                   \\\r\n      (buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff];                   \\\r\n      sourml=DFWORD(df, 2);                                   \\\r\n      (buf)[3]=DPD2BIN[((sourml<<2) | (sourlo>>30))&0x3ff];   \\\r\n      (buf)[4]=DPD2BIN[(sourml>>8)&0x3ff];                    \\\r\n      (buf)[5]=DPD2BIN[(sourml>>18)&0x3ff];                   \\\r\n      sourmh=DFWORD(df, 1);                                   \\\r\n      (buf)[6]=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff];   \\\r\n      (buf)[7]=DPD2BIN[(sourmh>>6)&0x3ff];                    \\\r\n      (buf)[8]=DPD2BIN[(sourmh>>16)&0x3ff];                   \\\r\n      sourhi=DFWORD(df, 0);                                   \\\r\n      (buf)[9]=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff];   \\\r\n      (buf)[10]=DPD2BIN[(sourhi>>4)&0x3ff];                   \\\r\n      (buf)[11]=DECCOMBMSD[sourhi>>26];}\r\n    #endif\r\n\r\n\r\n    /* Macros to decode the coefficient in a finite decFloat *df and  */\r\n    /* add to a base-thousand uInt array (as for GETCOEFFTHOU).       */\r\n    /* After the addition then most significant 'digit' in the array  */\r\n    /* might have a value larger then 10 (with a maximum of 19).      */\r\n    #if DECPMAX==7\r\n    #define ADDCOEFFTHOU(df, buf) {                           \\\r\n      uInt sourhi=DFWORD(df, 0);                              \\\r\n      (buf)[0]+=DPD2BIN[sourhi&0x3ff];                        \\\r\n      if (buf[0]>999) {buf[0]-=1000; buf[1]++;}               \\\r\n      (buf)[1]+=DPD2BIN[(sourhi>>10)&0x3ff];                  \\\r\n      if (buf[1]>999) {buf[1]-=1000; buf[2]++;}               \\\r\n      (buf)[2]+=DECCOMBMSD[sourhi>>26];}\r\n\r\n    #elif DECPMAX==16\r\n    #define ADDCOEFFTHOU(df, buf) {                           \\\r\n      uInt sourhi, sourlo;                                    \\\r\n      sourlo=DFWORD(df, 1);                                   \\\r\n      (buf)[0]+=DPD2BIN[sourlo&0x3ff];                        \\\r\n      if (buf[0]>999) {buf[0]-=1000; buf[1]++;}               \\\r\n      (buf)[1]+=DPD2BIN[(sourlo>>10)&0x3ff];                  \\\r\n      if (buf[1]>999) {buf[1]-=1000; buf[2]++;}               \\\r\n      (buf)[2]+=DPD2BIN[(sourlo>>20)&0x3ff];                  \\\r\n      if (buf[2]>999) {buf[2]-=1000; buf[3]++;}               \\\r\n      sourhi=DFWORD(df, 0);                                   \\\r\n      (buf)[3]+=DPD2BIN[((sourhi<<2) | (sourlo>>30))&0x3ff];  \\\r\n      if (buf[3]>999) {buf[3]-=1000; buf[4]++;}               \\\r\n      (buf)[4]+=DPD2BIN[(sourhi>>8)&0x3ff];                   \\\r\n      if (buf[4]>999) {buf[4]-=1000; buf[5]++;}               \\\r\n      (buf)[5]+=DECCOMBMSD[sourhi>>26];}\r\n\r\n    #elif DECPMAX==34\r\n    #define ADDCOEFFTHOU(df, buf) {                           \\\r\n      uInt sourhi, sourmh, sourml, sourlo;                    \\\r\n      sourlo=DFWORD(df, 3);                                   \\\r\n      (buf)[0]+=DPD2BIN[sourlo&0x3ff];                        \\\r\n      if (buf[0]>999) {buf[0]-=1000; buf[1]++;}               \\\r\n      (buf)[1]+=DPD2BIN[(sourlo>>10)&0x3ff];                  \\\r\n      if (buf[1]>999) {buf[1]-=1000; buf[2]++;}               \\\r\n      (buf)[2]+=DPD2BIN[(sourlo>>20)&0x3ff];                  \\\r\n      if (buf[2]>999) {buf[2]-=1000; buf[3]++;}               \\\r\n      sourml=DFWORD(df, 2);                                   \\\r\n      (buf)[3]+=DPD2BIN[((sourml<<2) | (sourlo>>30))&0x3ff];  \\\r\n      if (buf[3]>999) {buf[3]-=1000; buf[4]++;}               \\\r\n      (buf)[4]+=DPD2BIN[(sourml>>8)&0x3ff];                   \\\r\n      if (buf[4]>999) {buf[4]-=1000; buf[5]++;}               \\\r\n      (buf)[5]+=DPD2BIN[(sourml>>18)&0x3ff];                  \\\r\n      if (buf[5]>999) {buf[5]-=1000; buf[6]++;}               \\\r\n      sourmh=DFWORD(df, 1);                                   \\\r\n      (buf)[6]+=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff];  \\\r\n      if (buf[6]>999) {buf[6]-=1000; buf[7]++;}               \\\r\n      (buf)[7]+=DPD2BIN[(sourmh>>6)&0x3ff];                   \\\r\n      if (buf[7]>999) {buf[7]-=1000; buf[8]++;}               \\\r\n      (buf)[8]+=DPD2BIN[(sourmh>>16)&0x3ff];                  \\\r\n      if (buf[8]>999) {buf[8]-=1000; buf[9]++;}               \\\r\n      sourhi=DFWORD(df, 0);                                   \\\r\n      (buf)[9]+=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff];  \\\r\n      if (buf[9]>999) {buf[9]-=1000; buf[10]++;}              \\\r\n      (buf)[10]+=DPD2BIN[(sourhi>>4)&0x3ff];                  \\\r\n      if (buf[10]>999) {buf[10]-=1000; buf[11]++;}            \\\r\n      (buf)[11]+=DECCOMBMSD[sourhi>>26];}\r\n    #endif\r\n\r\n\r\n    /* Set a decFloat to the maximum positive finite number (Nmax)    */\r\n    #if DECPMAX==7\r\n    #define DFSETNMAX(df)            \\\r\n      {DFWORD(df, 0)=0x77f3fcff;}\r\n    #elif DECPMAX==16\r\n    #define DFSETNMAX(df)            \\\r\n      {DFWORD(df, 0)=0x77fcff3f;     \\\r\n       DFWORD(df, 1)=0xcff3fcff;}\r\n    #elif DECPMAX==34\r\n    #define DFSETNMAX(df)            \\\r\n      {DFWORD(df, 0)=0x77ffcff3;     \\\r\n       DFWORD(df, 1)=0xfcff3fcf;     \\\r\n       DFWORD(df, 2)=0xf3fcff3f;     \\\r\n       DFWORD(df, 3)=0xcff3fcff;}\r\n    #endif\r\n\r\n  /* [end of format-dependent macros and constants]                   */\r\n  #endif\r\n\r\n#else\r\n  #error decNumberLocal included more than once\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decPacked.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Packed Decimal conversion module                                   */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2002.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This module comprises the routines for Packed Decimal format       */\r\n/* numbers.  Conversions are supplied to and from decNumber, which in */\r\n/* turn supports:                                                     */\r\n/*   conversions to and from string                                   */\r\n/*   arithmetic routines                                              */\r\n/*   utilities.                                                       */\r\n/* Conversions from decNumber to and from densely packed decimal      */\r\n/* formats are provided by the decimal32 through decimal128 modules.  */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#include <string.h>           // for NULL\r\n#include \"decNumber.h\"        // base number library\r\n#include \"decPacked.h\"        // packed decimal\r\n#include \"decNumberLocal.h\"   // decNumber local types, etc.\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decPackedFromNumber -- convert decNumber to BCD Packed Decimal     */\r\n/*                                                                    */\r\n/*   bcd    is the BCD bytes                                          */\r\n/*   length is the length of the BCD array                            */\r\n/*   scale  is the scale result                                       */\r\n/*   dn     is the decNumber                                          */\r\n/*   returns bcd, or NULL if error                                    */\r\n/*                                                                    */\r\n/* The number is converted to a BCD packed decimal byte array,        */\r\n/* right aligned in the bcd array, whose length is indicated by the   */\r\n/* second parameter.  The final 4-bit nibble in the array will be a   */\r\n/* sign nibble, C (1100) for + and D (1101) for -.  Unused bytes and  */\r\n/* nibbles to the left of the number are set to 0.                    */\r\n/*                                                                    */\r\n/* scale is set to the scale of the number (this is the exponent,     */\r\n/* negated).  To force the number to a specified scale, first use the */\r\n/* decNumberRescale routine, which will round and change the exponent */\r\n/* as necessary.                                                      */\r\n/*                                                                    */\r\n/* If there is an error (that is, the decNumber has too many digits   */\r\n/* to fit in length bytes, or it is a NaN or Infinity), NULL is       */\r\n/* returned and the bcd and scale results are unchanged.  Otherwise   */\r\n/* bcd is returned.                                                   */\r\n/* ------------------------------------------------------------------ */\r\nuByte * decPackedFromNumber(uByte *bcd, Int length, Int *scale,\r\n                            const decNumber *dn) {\r\n  const Unit *up=dn->lsu;     // Unit array pointer\r\n  uByte obyte, *out;          // current output byte, and where it goes\r\n  Int indigs=dn->digits;      // digits processed\r\n  uInt cut=DECDPUN;           // downcounter per Unit\r\n  uInt u=*up;                 // work\r\n  uInt nib;                   // ..\r\n  #if DECDPUN<=4\r\n  uInt temp;                  // ..\r\n  #endif\r\n\r\n  if (dn->digits>length*2-1                  // too long ..\r\n   ||(dn->bits & DECSPECIAL)) return NULL;   // .. or special -- hopeless\r\n\r\n  if (dn->bits&DECNEG) obyte=DECPMINUS;      // set the sign ..\r\n   else                obyte=DECPPLUS;\r\n  *scale=-dn->exponent;                      // .. and scale\r\n\r\n  // loop from lowest (rightmost) byte\r\n  out=bcd+length-1;                          // -> final byte\r\n  for (; out>=bcd; out--) {\r\n    if (indigs>0) {\r\n      if (cut==0) {\r\n        up++;\r\n        u=*up;\r\n        cut=DECDPUN;\r\n        }\r\n      #if DECDPUN<=4\r\n        temp=(u*6554)>>16;         // fast /10\r\n        nib=u-X10(temp);\r\n        u=temp;\r\n      #else\r\n        nib=u%10;                  // cannot use *6554 trick :-(\r\n        u=u/10;\r\n      #endif\r\n      obyte|=(nib<<4);\r\n      indigs--;\r\n      cut--;\r\n      }\r\n    *out=obyte;\r\n    obyte=0;                       // assume 0\r\n    if (indigs>0) {\r\n      if (cut==0) {\r\n        up++;\r\n        u=*up;\r\n        cut=DECDPUN;\r\n        }\r\n      #if DECDPUN<=4\r\n        temp=(u*6554)>>16;         // as above\r\n        obyte=(uByte)(u-X10(temp));\r\n        u=temp;\r\n      #else\r\n        obyte=(uByte)(u%10);\r\n        u=u/10;\r\n      #endif\r\n      indigs--;\r\n      cut--;\r\n      }\r\n    } // loop\r\n\r\n  return bcd;\r\n  } // decPackedFromNumber\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decPackedToNumber -- convert BCD Packed Decimal to a decNumber     */\r\n/*                                                                    */\r\n/*   bcd    is the BCD bytes                                          */\r\n/*   length is the length of the BCD array                            */\r\n/*   scale  is the scale associated with the BCD integer              */\r\n/*   dn     is the decNumber [with space for length*2 digits]         */\r\n/*   returns dn, or NULL if error                                     */\r\n/*                                                                    */\r\n/* The BCD packed decimal byte array, together with an associated     */\r\n/* scale, is converted to a decNumber.  The BCD array is assumed full */\r\n/* of digits, and must be ended by a 4-bit sign nibble in the least   */\r\n/* significant four bits of the final byte.                           */\r\n/*                                                                    */\r\n/* The scale is used (negated) as the exponent of the decNumber.      */\r\n/* Note that zeros may have a sign and/or a scale.                    */\r\n/*                                                                    */\r\n/* The decNumber structure is assumed to have sufficient space to     */\r\n/* hold the converted number (that is, up to length*2-1 digits), so   */\r\n/* no error is possible unless the adjusted exponent is out of range, */\r\n/* no sign nibble was found, or a sign nibble was found before the    */\r\n/* final nibble.  In these error cases, NULL is returned and the      */\r\n/* decNumber will be 0.                                               */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decPackedToNumber(const uByte *bcd, Int length,\r\n                              const Int *scale, decNumber *dn) {\r\n  const uByte *last=bcd+length-1;  // -> last byte\r\n  const uByte *first;              // -> first non-zero byte\r\n  uInt  nib;                       // work nibble\r\n  Unit  *up=dn->lsu;               // output pointer\r\n  Int   digits;                    // digits count\r\n  Int   cut=0;                     // phase of output\r\n\r\n  decNumberZero(dn);               // default result\r\n  last=&bcd[length-1];\r\n  nib=*last & 0x0f;                // get the sign\r\n  if (nib==DECPMINUS || nib==DECPMINUSALT) dn->bits=DECNEG;\r\n   else if (nib<=9) return NULL;   // not a sign nibble\r\n\r\n  // skip leading zero bytes [final byte is always non-zero, due to sign]\r\n  for (first=bcd; *first==0;) first++;\r\n  digits=(last-first)*2+1;              // calculate digits ..\r\n  if ((*first & 0xf0)==0) digits--;     // adjust for leading zero nibble\r\n  if (digits!=0) dn->digits=digits;     // count of actual digits [if 0,\r\n                                        // leave as 1]\r\n\r\n  // check the adjusted exponent; note that scale could be unbounded\r\n  dn->exponent=-*scale;                 // set the exponent\r\n  if (*scale>=0) {                      // usual case\r\n    if ((dn->digits-*scale-1)<-DECNUMMAXE) {      // underflow\r\n      decNumberZero(dn);\r\n      return NULL;}\r\n    }\r\n   else { // -ve scale; +ve exponent\r\n    // need to be careful to avoid wrap, here, also BADINT case\r\n    if ((*scale<-DECNUMMAXE)            // overflow even without digits\r\n         || ((dn->digits-*scale-1)>DECNUMMAXE)) { // overflow\r\n      decNumberZero(dn);\r\n      return NULL;}\r\n    }\r\n  if (digits==0) return dn;             // result was zero\r\n\r\n  // copy the digits to the number's units, starting at the lsu\r\n  // [unrolled]\r\n  for (;;) {                            // forever\r\n    // left nibble first\r\n    nib=(unsigned)(*last & 0xf0)>>4;\r\n    // got a digit, in nib\r\n    if (nib>9) {decNumberZero(dn); return NULL;}\r\n\r\n    if (cut==0) *up=(Unit)nib;\r\n     else *up=(Unit)(*up+nib*DECPOWERS[cut]);\r\n    digits--;\r\n    if (digits==0) break;               // got them all\r\n    cut++;\r\n    if (cut==DECDPUN) {\r\n      up++;\r\n      cut=0;\r\n      }\r\n    last--;                             // ready for next\r\n    nib=*last & 0x0f;                   // get right nibble\r\n    if (nib>9) {decNumberZero(dn); return NULL;}\r\n\r\n    // got a digit, in nib\r\n    if (cut==0) *up=(Unit)nib;\r\n     else *up=(Unit)(*up+nib*DECPOWERS[cut]);\r\n    digits--;\r\n    if (digits==0) break;               // got them all\r\n    cut++;\r\n    if (cut==DECDPUN) {\r\n      up++;\r\n      cut=0;\r\n      }\r\n    } // forever\r\n\r\n  return dn;\r\n  } // decPackedToNumber\r\n\r\n"
  },
  {
    "path": "vendor/decNumber/decPacked.h",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Packed Decimal conversion module header                            */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2005.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#if !defined(DECPACKED)\r\n  #define DECPACKED\r\n  #define DECPNAME     \"decPacked\"                      /* Short name */\r\n  #define DECPFULLNAME \"Packed Decimal conversions\"   /* Verbose name */\r\n  #define DECPAUTHOR   \"Mike Cowlishaw\"               /* Who to blame */\r\n\r\n  #define DECPACKED_DefP 32             /* default precision          */\r\n\r\n  #ifndef  DECNUMDIGITS\r\n    #define DECNUMDIGITS DECPACKED_DefP /* size if not already defined*/\r\n  #endif\r\n  #include \"decNumber.h\"                /* context and number library */\r\n\r\n  /* Sign nibble constants                                            */\r\n  #if !defined(DECPPLUSALT)\r\n    #define DECPPLUSALT  0x0A /* alternate plus  nibble               */\r\n    #define DECPMINUSALT 0x0B /* alternate minus nibble               */\r\n    #define DECPPLUS     0x0C /* preferred plus  nibble               */\r\n    #define DECPMINUS    0x0D /* preferred minus nibble               */\r\n    #define DECPPLUSALT2 0x0E /* alternate plus  nibble               */\r\n    #define DECPUNSIGNED 0x0F /* alternate plus  nibble (unsigned)    */\r\n  #endif\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* decPacked public routines                                        */\r\n  /* ---------------------------------------------------------------- */\r\n  /* Conversions                                                      */\r\n  uint8_t * decPackedFromNumber(uint8_t *, int32_t, int32_t *,\r\n                                const decNumber *);\r\n  decNumber * decPackedToNumber(const uint8_t *, int32_t, const int32_t *,\r\n                                decNumber *);\r\n\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decQuad.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* decQuad.c -- decQuad operations module                             */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2010.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is included in the package as decNumber.pdf.  This   */\r\n/* document is also available in HTML, together with specifications,  */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This module comprises decQuad operations (including conversions)   */\r\n/* ------------------------------------------------------------------ */\r\n\r\n\r\n/* Constant mappings for shared code */\r\n#define DECPMAX     DECQUAD_Pmax\r\n#define DECEMIN     DECQUAD_Emin\r\n#define DECEMAX     DECQUAD_Emax\r\n#define DECEMAXD    DECQUAD_EmaxD\r\n#define DECBYTES    DECQUAD_Bytes\r\n#define DECSTRING   DECQUAD_String\r\n#define DECECONL    DECQUAD_EconL\r\n#define DECBIAS     DECQUAD_Bias\r\n#define DECLETS     DECQUAD_Declets\r\n#define DECQTINY   (-DECQUAD_Bias)\r\n\r\n/* Type and function mappings for shared code */\r\n#define decFloat                   decQuad        // Type name\r\n\r\n// Utilities and conversions (binary results, extractors, etc.)\r\n#define decFloatFromBCD            decQuadFromBCD\r\n#define decFloatFromInt32          decQuadFromInt32\r\n#define decFloatFromPacked         decQuadFromPacked\r\n#define decFloatFromPackedChecked  decQuadFromPackedChecked\r\n#define decFloatFromString         decQuadFromString\r\n#define decFloatFromUInt32         decQuadFromUInt32\r\n#define decFloatFromWider          decQuadFromWider\r\n#define decFloatGetCoefficient     decQuadGetCoefficient\r\n#define decFloatGetExponent        decQuadGetExponent\r\n#define decFloatSetCoefficient     decQuadSetCoefficient\r\n#define decFloatSetExponent        decQuadSetExponent\r\n#define decFloatShow               decQuadShow\r\n#define decFloatToBCD              decQuadToBCD\r\n#define decFloatToEngString        decQuadToEngString\r\n#define decFloatToInt32            decQuadToInt32\r\n#define decFloatToInt32Exact       decQuadToInt32Exact\r\n#define decFloatToPacked           decQuadToPacked\r\n#define decFloatToString           decQuadToString\r\n#define decFloatToUInt32           decQuadToUInt32\r\n#define decFloatToUInt32Exact      decQuadToUInt32Exact\r\n#define decFloatToWider            decQuadToWider\r\n#define decFloatZero               decQuadZero\r\n\r\n// Computational (result is a decFloat)\r\n#define decFloatAbs                decQuadAbs\r\n#define decFloatAdd                decQuadAdd\r\n#define decFloatAnd                decQuadAnd\r\n#define decFloatDivide             decQuadDivide\r\n#define decFloatDivideInteger      decQuadDivideInteger\r\n#define decFloatFMA                decQuadFMA\r\n#define decFloatInvert             decQuadInvert\r\n#define decFloatLogB               decQuadLogB\r\n#define decFloatMax                decQuadMax\r\n#define decFloatMaxMag             decQuadMaxMag\r\n#define decFloatMin                decQuadMin\r\n#define decFloatMinMag             decQuadMinMag\r\n#define decFloatMinus              decQuadMinus\r\n#define decFloatMultiply           decQuadMultiply\r\n#define decFloatNextMinus          decQuadNextMinus\r\n#define decFloatNextPlus           decQuadNextPlus\r\n#define decFloatNextToward         decQuadNextToward\r\n#define decFloatOr                 decQuadOr\r\n#define decFloatPlus               decQuadPlus\r\n#define decFloatQuantize           decQuadQuantize\r\n#define decFloatReduce             decQuadReduce\r\n#define decFloatRemainder          decQuadRemainder\r\n#define decFloatRemainderNear      decQuadRemainderNear\r\n#define decFloatRotate             decQuadRotate\r\n#define decFloatScaleB             decQuadScaleB\r\n#define decFloatShift              decQuadShift\r\n#define decFloatSubtract           decQuadSubtract\r\n#define decFloatToIntegralValue    decQuadToIntegralValue\r\n#define decFloatToIntegralExact    decQuadToIntegralExact\r\n#define decFloatXor                decQuadXor\r\n\r\n// Comparisons\r\n#define decFloatCompare            decQuadCompare\r\n#define decFloatCompareSignal      decQuadCompareSignal\r\n#define decFloatCompareTotal       decQuadCompareTotal\r\n#define decFloatCompareTotalMag    decQuadCompareTotalMag\r\n\r\n// Copies\r\n#define decFloatCanonical          decQuadCanonical\r\n#define decFloatCopy               decQuadCopy\r\n#define decFloatCopyAbs            decQuadCopyAbs\r\n#define decFloatCopyNegate         decQuadCopyNegate\r\n#define decFloatCopySign           decQuadCopySign\r\n\r\n// Non-computational\r\n#define decFloatClass              decQuadClass\r\n#define decFloatClassString        decQuadClassString\r\n#define decFloatDigits             decQuadDigits\r\n#define decFloatIsCanonical        decQuadIsCanonical\r\n#define decFloatIsFinite           decQuadIsFinite\r\n#define decFloatIsInfinite         decQuadIsInfinite\r\n#define decFloatIsInteger          decQuadIsInteger\r\n#define decFloatIsLogical          decQuadIsLogical\r\n#define decFloatIsNaN              decQuadIsNaN\r\n#define decFloatIsNegative         decQuadIsNegative\r\n#define decFloatIsNormal           decQuadIsNormal\r\n#define decFloatIsPositive         decQuadIsPositive\r\n#define decFloatIsSignaling        decQuadIsSignaling\r\n#define decFloatIsSignalling       decQuadIsSignalling\r\n#define decFloatIsSigned           decQuadIsSigned\r\n#define decFloatIsSubnormal        decQuadIsSubnormal\r\n#define decFloatIsZero             decQuadIsZero\r\n#define decFloatRadix              decQuadRadix\r\n#define decFloatSameQuantum        decQuadSameQuantum\r\n#define decFloatVersion            decQuadVersion\r\n\r\n/* And now the code itself */\r\n#include \"decContext.h\"       // public includes\r\n#include \"decQuad.h\"          // ..\r\n#include \"decNumberLocal.h\"   // local includes (need DECPMAX)\r\n#include \"decCommon.c\"        // non-arithmetic decFloat routines\r\n#include \"decBasic.c\"         // basic formats routines\r\n\r\n"
  },
  {
    "path": "vendor/decNumber/decQuad.h",
    "content": "/* ------------------------------------------------------------------ */\r\n/* decQuad.h -- Decimal 128-bit format module header                  */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2010.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is included in the package as decNumber.pdf.  This   */\r\n/* document is also available in HTML, together with specifications,  */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This include file is always included by decSingle and decDouble,   */\r\n/* and therefore also holds useful constants used by all three.       */\r\n\r\n#if !defined(DECQUAD)\r\n  #define DECQUAD\r\n\r\n  #define DECQUADNAME         \"decimalQuad\"           /* Short name   */\r\n  #define DECQUADTITLE        \"Decimal 128-bit datum\" /* Verbose name */\r\n  #define DECQUADAUTHOR       \"Mike Cowlishaw\"        /* Who to blame */\r\n\r\n  /* parameters for decQuads */\r\n  #define DECQUAD_Bytes    16      /* length                          */\r\n  #define DECQUAD_Pmax     34      /* maximum precision (digits)      */\r\n  #define DECQUAD_Emin  -6143      /* minimum adjusted exponent       */\r\n  #define DECQUAD_Emax   6144      /* maximum adjusted exponent       */\r\n  #define DECQUAD_EmaxD     4      /* maximum exponent digits         */\r\n  #define DECQUAD_Bias   6176      /* bias for the exponent           */\r\n  #define DECQUAD_String   43      /* maximum string length, +1       */\r\n  #define DECQUAD_EconL    12      /* exponent continuation length    */\r\n  #define DECQUAD_Declets  11      /* count of declets                */\r\n  /* highest biased exponent (Elimit-1) */\r\n  #define DECQUAD_Ehigh (DECQUAD_Emax + DECQUAD_Bias - (DECQUAD_Pmax-1))\r\n\r\n  /* Required include                                                 */\r\n  #include \"decContext.h\"\r\n\r\n  /* The decQuad decimal 128-bit type, accessible by all sizes */\r\n  typedef union {\r\n    uint8_t   bytes[DECQUAD_Bytes];     /* fields: 1, 5, 12, 110 bits */\r\n    uint16_t shorts[DECQUAD_Bytes/2];\r\n    uint32_t  words[DECQUAD_Bytes/4];\r\n    #if DECUSE64\r\n    uint64_t  longs[DECQUAD_Bytes/8];\r\n    #endif\r\n    } decQuad;\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* Shared constants                                                 */\r\n  /* ---------------------------------------------------------------- */\r\n\r\n  /* sign and special values [top 32-bits; last two bits are don't-care\r\n     for Infinity on input, last bit don't-care for NaNs] */\r\n  #define DECFLOAT_Sign  0x80000000     /* 1 00000 00 Sign */\r\n  #define DECFLOAT_NaN   0x7c000000     /* 0 11111 00 NaN generic */\r\n  #define DECFLOAT_qNaN  0x7c000000     /* 0 11111 00 qNaN */\r\n  #define DECFLOAT_sNaN  0x7e000000     /* 0 11111 10 sNaN */\r\n  #define DECFLOAT_Inf   0x78000000     /* 0 11110 00 Infinity */\r\n  #define DECFLOAT_MinSp 0x78000000     /* minimum special value */\r\n                                        /* [specials are all >=MinSp] */\r\n  /* Sign nibble constants                                            */\r\n  #if !defined(DECPPLUSALT)\r\n    #define DECPPLUSALT  0x0A /* alternate plus  nibble               */\r\n    #define DECPMINUSALT 0x0B /* alternate minus nibble               */\r\n    #define DECPPLUS     0x0C /* preferred plus  nibble               */\r\n    #define DECPMINUS    0x0D /* preferred minus nibble               */\r\n    #define DECPPLUSALT2 0x0E /* alternate plus  nibble               */\r\n    #define DECPUNSIGNED 0x0F /* alternate plus  nibble (unsigned)    */\r\n  #endif\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* Routines -- implemented as decFloat routines in common files     */\r\n  /* ---------------------------------------------------------------- */\r\n\r\n  /* Utilities and conversions, extractors, etc.) */\r\n  extern decQuad * decQuadFromBCD(decQuad *, int32_t, const uint8_t *, int32_t);\r\n  extern decQuad * decQuadFromInt32(decQuad *, int32_t);\r\n  extern decQuad * decQuadFromPacked(decQuad *, int32_t, const uint8_t *);\r\n  extern decQuad * decQuadFromPackedChecked(decQuad *, int32_t, const uint8_t *);\r\n  extern decQuad * decQuadFromString(decQuad *, const char *, decContext *);\r\n  extern decQuad * decQuadFromUInt32(decQuad *, uint32_t);\r\n  extern int32_t   decQuadGetCoefficient(const decQuad *, uint8_t *);\r\n  extern int32_t   decQuadGetExponent(const decQuad *);\r\n  extern decQuad * decQuadSetCoefficient(decQuad *, const uint8_t *, int32_t);\r\n  extern decQuad * decQuadSetExponent(decQuad *, decContext *, int32_t);\r\n  extern void      decQuadShow(const decQuad *, const char *);\r\n  extern int32_t   decQuadToBCD(const decQuad *, int32_t *, uint8_t *);\r\n  extern char    * decQuadToEngString(const decQuad *, char *);\r\n  extern int32_t   decQuadToInt32(const decQuad *, decContext *, enum rounding);\r\n  extern int32_t   decQuadToInt32Exact(const decQuad *, decContext *, enum rounding);\r\n  extern int32_t   decQuadToPacked(const decQuad *, int32_t *, uint8_t *);\r\n  extern char    * decQuadToString(const decQuad *, char *);\r\n  extern uint32_t  decQuadToUInt32(const decQuad *, decContext *, enum rounding);\r\n  extern uint32_t  decQuadToUInt32Exact(const decQuad *, decContext *, enum rounding);\r\n  extern decQuad * decQuadZero(decQuad *);\r\n\r\n  /* Computational (result is a decQuad) */\r\n  extern decQuad * decQuadAbs(decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadAdd(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadAnd(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadDivide(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadDivideInteger(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadFMA(decQuad *, const decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadInvert(decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadLogB(decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadMax(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadMaxMag(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadMin(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadMinMag(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadMinus(decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadMultiply(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadNextMinus(decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadNextPlus(decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadNextToward(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadOr(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadPlus(decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadQuantize(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadReduce(decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadRemainder(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadRemainderNear(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadRotate(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadScaleB(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadShift(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadSubtract(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadToIntegralValue(decQuad *, const decQuad *, decContext *, enum rounding);\r\n  extern decQuad * decQuadToIntegralExact(decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadXor(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n\r\n  /* Comparisons */\r\n  extern decQuad * decQuadCompare(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadCompareSignal(decQuad *, const decQuad *, const decQuad *, decContext *);\r\n  extern decQuad * decQuadCompareTotal(decQuad *, const decQuad *, const decQuad *);\r\n  extern decQuad * decQuadCompareTotalMag(decQuad *, const decQuad *, const decQuad *);\r\n\r\n  /* Copies */\r\n  extern decQuad * decQuadCanonical(decQuad *, const decQuad *);\r\n  extern decQuad * decQuadCopy(decQuad *, const decQuad *);\r\n  extern decQuad * decQuadCopyAbs(decQuad *, const decQuad *);\r\n  extern decQuad * decQuadCopyNegate(decQuad *, const decQuad *);\r\n  extern decQuad * decQuadCopySign(decQuad *, const decQuad *, const decQuad *);\r\n\r\n  /* Non-computational */\r\n  extern enum decClass decQuadClass(const decQuad *);\r\n  extern const char *  decQuadClassString(const decQuad *);\r\n  extern uint32_t      decQuadDigits(const decQuad *);\r\n  extern uint32_t      decQuadIsCanonical(const decQuad *);\r\n  extern uint32_t      decQuadIsFinite(const decQuad *);\r\n  extern uint32_t      decQuadIsInteger(const decQuad *);\r\n  extern uint32_t      decQuadIsLogical(const decQuad *);\r\n  extern uint32_t      decQuadIsInfinite(const decQuad *);\r\n  extern uint32_t      decQuadIsNaN(const decQuad *);\r\n  extern uint32_t      decQuadIsNegative(const decQuad *);\r\n  extern uint32_t      decQuadIsNormal(const decQuad *);\r\n  extern uint32_t      decQuadIsPositive(const decQuad *);\r\n  extern uint32_t      decQuadIsSignaling(const decQuad *);\r\n  extern uint32_t      decQuadIsSignalling(const decQuad *);\r\n  extern uint32_t      decQuadIsSigned(const decQuad *);\r\n  extern uint32_t      decQuadIsSubnormal(const decQuad *);\r\n  extern uint32_t      decQuadIsZero(const decQuad *);\r\n  extern uint32_t      decQuadRadix(const decQuad *);\r\n  extern uint32_t      decQuadSameQuantum(const decQuad *, const decQuad *);\r\n  extern const char *  decQuadVersion(void);\r\n\r\n  /* decNumber conversions; these are implemented as macros so as not  */\r\n  /* to force a dependency on decimal128 and decNumber in decQuad.     */\r\n  /* decQuadFromNumber returns a decimal128 * to avoid warnings.       */\r\n  #define decQuadToNumber(dq, dn) decimal128ToNumber((decimal128 *)(dq), dn)\r\n  #define decQuadFromNumber(dq, dn, set) decimal128FromNumber((decimal128 *)(dq), dn, set)\r\n\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decSingle.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* decSingle.c -- decSingle operations module                         */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2008.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is included in the package as decNumber.pdf.  This   */\r\n/* document is also available in HTML, together with specifications,  */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This module comprises decSingle operations (including conversions) */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#include \"decContext.h\"       // public includes\r\n#include \"decSingle.h\"        // public includes\r\n\r\n/* Constant mappings for shared code */\r\n#define DECPMAX     DECSINGLE_Pmax\r\n#define DECEMIN     DECSINGLE_Emin\r\n#define DECEMAX     DECSINGLE_Emax\r\n#define DECEMAXD    DECSINGLE_EmaxD\r\n#define DECBYTES    DECSINGLE_Bytes\r\n#define DECSTRING   DECSINGLE_String\r\n#define DECECONL    DECSINGLE_EconL\r\n#define DECBIAS     DECSINGLE_Bias\r\n#define DECLETS     DECSINGLE_Declets\r\n#define DECQTINY    (-DECSINGLE_Bias)\r\n// parameters of next-wider format\r\n#define DECWBYTES   DECDOUBLE_Bytes\r\n#define DECWPMAX    DECDOUBLE_Pmax\r\n#define DECWECONL   DECDOUBLE_EconL\r\n#define DECWBIAS    DECDOUBLE_Bias\r\n\r\n/* Type and function mappings for shared code */\r\n#define decFloat                   decSingle      // Type name\r\n#define decFloatWider              decDouble      // Type name\r\n\r\n// Utility (binary results, extractors, etc.)\r\n#define decFloatFromBCD            decSingleFromBCD\r\n#define decFloatFromPacked         decSingleFromPacked\r\n#define decFloatFromPackedChecked  decSingleFromPackedChecked\r\n#define decFloatFromString         decSingleFromString\r\n#define decFloatFromWider          decSingleFromWider\r\n#define decFloatGetCoefficient     decSingleGetCoefficient\r\n#define decFloatGetExponent        decSingleGetExponent\r\n#define decFloatSetCoefficient     decSingleSetCoefficient\r\n#define decFloatSetExponent        decSingleSetExponent\r\n#define decFloatShow               decSingleShow\r\n#define decFloatToBCD              decSingleToBCD\r\n#define decFloatToEngString        decSingleToEngString\r\n#define decFloatToPacked           decSingleToPacked\r\n#define decFloatToString           decSingleToString\r\n#define decFloatToWider            decSingleToWider\r\n#define decFloatZero               decSingleZero\r\n\r\n// Non-computational\r\n#define decFloatRadix              decSingleRadix\r\n#define decFloatVersion            decSingleVersion\r\n\r\n#include \"decNumberLocal.h\"   // local includes (need DECPMAX)\r\n#include \"decCommon.c\"        // non-basic decFloat routines\r\n// [Do not include decBasic.c for decimal32]\r\n\r\n"
  },
  {
    "path": "vendor/decNumber/decSingle.h",
    "content": "/* ------------------------------------------------------------------ */\r\n/* decSingle.h -- Decimal 32-bit format module header                 */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2008.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is included in the package as decNumber.pdf.  This   */\r\n/* document is also available in HTML, together with specifications,  */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#if !defined(DECSINGLE)\r\n  #define DECSINGLE\r\n\r\n  #define DECSINGLENAME       \"decSingle\"             /* Short name   */\r\n  #define DECSINGLETITLE      \"Decimal 32-bit datum\"  /* Verbose name */\r\n  #define DECSINGLEAUTHOR     \"Mike Cowlishaw\"        /* Who to blame */\r\n\r\n  /* parameters for decSingles */\r\n  #define DECSINGLE_Bytes    4     /* length                          */\r\n  #define DECSINGLE_Pmax     7     /* maximum precision (digits)      */\r\n  #define DECSINGLE_Emin   -95     /* minimum adjusted exponent       */\r\n  #define DECSINGLE_Emax    96     /* maximum adjusted exponent       */\r\n  #define DECSINGLE_EmaxD    3     /* maximum exponent digits         */\r\n  #define DECSINGLE_Bias   101     /* bias for the exponent           */\r\n  #define DECSINGLE_String  16     /* maximum string length, +1       */\r\n  #define DECSINGLE_EconL    6     /* exponent continuation length    */\r\n  #define DECSINGLE_Declets  2     /* count of declets                */\r\n  /* highest biased exponent (Elimit-1) */\r\n  #define DECSINGLE_Ehigh (DECSINGLE_Emax + DECSINGLE_Bias - (DECSINGLE_Pmax-1))\r\n\r\n  /* Required includes                                                */\r\n  #include \"decContext.h\"\r\n  #include \"decQuad.h\"\r\n  #include \"decDouble.h\"\r\n\r\n  /* The decSingle decimal 32-bit type, accessible by all sizes */\r\n  typedef union {\r\n    uint8_t   bytes[DECSINGLE_Bytes];   /* fields: 1, 5, 6, 20 bits */\r\n    uint16_t shorts[DECSINGLE_Bytes/2];\r\n    uint32_t  words[DECSINGLE_Bytes/4];\r\n    } decSingle;\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* Routines -- implemented as decFloat routines in common files     */\r\n  /* ---------------------------------------------------------------- */\r\n\r\n  /* Utilities (binary argument(s) or result, extractors, etc.) */\r\n  extern decSingle * decSingleFromBCD(decSingle *, int32_t, const uint8_t *, int32_t);\r\n  extern decSingle * decSingleFromPacked(decSingle *, int32_t, const uint8_t *);\r\n  extern decSingle * decSingleFromPackedChecked(decSingle *, int32_t, const uint8_t *);\r\n  extern decSingle * decSingleFromString(decSingle *, const char *, decContext *);\r\n  extern decSingle * decSingleFromWider(decSingle *, const decDouble *, decContext *);\r\n  extern int32_t     decSingleGetCoefficient(const decSingle *, uint8_t *);\r\n  extern int32_t     decSingleGetExponent(const decSingle *);\r\n  extern decSingle * decSingleSetCoefficient(decSingle *, const uint8_t *, int32_t);\r\n  extern decSingle * decSingleSetExponent(decSingle *, decContext *, int32_t);\r\n  extern void        decSingleShow(const decSingle *, const char *);\r\n  extern int32_t     decSingleToBCD(const decSingle *, int32_t *, uint8_t *);\r\n  extern char      * decSingleToEngString(const decSingle *, char *);\r\n  extern int32_t     decSingleToPacked(const decSingle *, int32_t *, uint8_t *);\r\n  extern char      * decSingleToString(const decSingle *, char *);\r\n  extern decDouble * decSingleToWider(const decSingle *, decDouble *);\r\n  extern decSingle * decSingleZero(decSingle *);\r\n\r\n  /* (No Arithmetic routines for decSingle) */\r\n\r\n  /* Non-computational */\r\n  extern uint32_t     decSingleRadix(const decSingle *);\r\n  extern const char * decSingleVersion(void);\r\n\r\n  /* decNumber conversions; these are implemented as macros so as not  */\r\n  /* to force a dependency on decimal32 and decNumber in decSingle.    */\r\n  /* decSingleFromNumber returns a decimal32 * to avoid warnings.      */\r\n  #define decSingleToNumber(dq, dn) decimal32ToNumber((decimal32 *)(dq), dn)\r\n  #define decSingleFromNumber(dq, dn, set) decimal32FromNumber((decimal32 *)(dq), dn, set)\r\n\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decimal128.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal 128-bit format module                                      */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2008.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This module comprises the routines for decimal128 format numbers.  */\r\n/* Conversions are supplied to and from decNumber and String.         */\r\n/*                                                                    */\r\n/* This is used when decNumber provides operations, either for all    */\r\n/* operations or as a proxy between decNumber and decSingle.          */\r\n/*                                                                    */\r\n/* Error handling is the same as decNumber (qv.).                     */\r\n/* ------------------------------------------------------------------ */\r\n#include <string.h>           // [for memset/memcpy]\r\n#include <stdio.h>            // [for printf]\r\n\r\n#define  DECNUMDIGITS 34      // make decNumbers with space for 34\r\n#include \"decNumber.h\"        // base number library\r\n#include \"decNumberLocal.h\"   // decNumber local types, etc.\r\n#include \"decimal128.h\"       // our primary include\r\n\r\n/* Utility routines and tables [in decimal64.c] */\r\n// DPD2BIN and the reverse are renamed to prevent link-time conflict\r\n// if decQuad is also built in the same executable\r\n#define DPD2BIN DPD2BINx\r\n#define BIN2DPD BIN2DPDx\r\nextern const uInt   COMBEXP[32], COMBMSD[32];\r\nextern const uShort DPD2BIN[1024];\r\nextern const uShort BIN2DPD[1000];      // [not used]\r\nextern const uByte  BIN2CHAR[4001];\r\n\r\nextern void decDigitsFromDPD(decNumber *, const uInt *, Int);\r\nextern void decDigitsToDPD(const decNumber *, uInt *, Int);\r\n\r\n#if DECTRACE || DECCHECK\r\nvoid decimal128Show(const decimal128 *);          // for debug\r\nextern void decNumberShow(const decNumber *);     // ..\r\n#endif\r\n\r\n/* Useful macro */\r\n// Clear a structure (e.g., a decNumber)\r\n#define DEC_clear(d) memset(d, 0, sizeof(*d))\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal128FromNumber -- convert decNumber to decimal128            */\r\n/*                                                                    */\r\n/*   ds is the target decimal128                                      */\r\n/*   dn is the source number (assumed valid)                          */\r\n/*   set is the context, used only for reporting errors               */\r\n/*                                                                    */\r\n/* The set argument is used only for status reporting and for the     */\r\n/* rounding mode (used if the coefficient is more than DECIMAL128_Pmax*/\r\n/* digits or an overflow is detected).  If the exponent is out of the */\r\n/* valid range then Overflow or Underflow will be raised.             */\r\n/* After Underflow a subnormal result is possible.                    */\r\n/*                                                                    */\r\n/* DEC_Clamped is set if the number has to be 'folded down' to fit,   */\r\n/* by reducing its exponent and multiplying the coefficient by a      */\r\n/* power of ten, or if the exponent on a zero had to be clamped.      */\r\n/* ------------------------------------------------------------------ */\r\ndecimal128 * decimal128FromNumber(decimal128 *d128, const decNumber *dn,\r\n                                  decContext *set) {\r\n  uInt status=0;                   // status accumulator\r\n  Int ae;                          // adjusted exponent\r\n  decNumber  dw;                   // work\r\n  decContext dc;                   // ..\r\n  uInt comb, exp;                  // ..\r\n  uInt uiwork;                     // for macros\r\n  uInt targar[4]={0,0,0,0};        // target 128-bit\r\n  #define targhi targar[3]         // name the word with the sign\r\n  #define targmh targar[2]         // name the words\r\n  #define targml targar[1]         // ..\r\n  #define targlo targar[0]         // ..\r\n\r\n  // If the number has too many digits, or the exponent could be\r\n  // out of range then reduce the number under the appropriate\r\n  // constraints.  This could push the number to Infinity or zero,\r\n  // so this check and rounding must be done before generating the\r\n  // decimal128]\r\n  ae=dn->exponent+dn->digits-1;              // [0 if special]\r\n  if (dn->digits>DECIMAL128_Pmax             // too many digits\r\n   || ae>DECIMAL128_Emax                     // likely overflow\r\n   || ae<DECIMAL128_Emin) {                  // likely underflow\r\n    decContextDefault(&dc, DEC_INIT_DECIMAL128); // [no traps]\r\n    dc.round=set->round;                     // use supplied rounding\r\n    decNumberPlus(&dw, dn, &dc);             // (round and check)\r\n    // [this changes -0 to 0, so enforce the sign...]\r\n    dw.bits|=dn->bits&DECNEG;\r\n    status=dc.status;                        // save status\r\n    dn=&dw;                                  // use the work number\r\n    } // maybe out of range\r\n\r\n  if (dn->bits&DECSPECIAL) {                      // a special value\r\n    if (dn->bits&DECINF) targhi=DECIMAL_Inf<<24;\r\n     else {                                       // sNaN or qNaN\r\n      if ((*dn->lsu!=0 || dn->digits>1)           // non-zero coefficient\r\n       && (dn->digits<DECIMAL128_Pmax)) {         // coefficient fits\r\n        decDigitsToDPD(dn, targar, 0);\r\n        }\r\n      if (dn->bits&DECNAN) targhi|=DECIMAL_NaN<<24;\r\n       else targhi|=DECIMAL_sNaN<<24;\r\n      } // a NaN\r\n    } // special\r\n\r\n   else { // is finite\r\n    if (decNumberIsZero(dn)) {               // is a zero\r\n      // set and clamp exponent\r\n      if (dn->exponent<-DECIMAL128_Bias) {\r\n        exp=0;                               // low clamp\r\n        status|=DEC_Clamped;\r\n        }\r\n       else {\r\n        exp=dn->exponent+DECIMAL128_Bias;    // bias exponent\r\n        if (exp>DECIMAL128_Ehigh) {          // top clamp\r\n          exp=DECIMAL128_Ehigh;\r\n          status|=DEC_Clamped;\r\n          }\r\n        }\r\n      comb=(exp>>9) & 0x18;             // msd=0, exp top 2 bits ..\r\n      }\r\n     else {                             // non-zero finite number\r\n      uInt msd;                         // work\r\n      Int pad=0;                        // coefficient pad digits\r\n\r\n      // the dn is known to fit, but it may need to be padded\r\n      exp=(uInt)(dn->exponent+DECIMAL128_Bias);    // bias exponent\r\n      if (exp>DECIMAL128_Ehigh) {                  // fold-down case\r\n        pad=exp-DECIMAL128_Ehigh;\r\n        exp=DECIMAL128_Ehigh;                      // [to maximum]\r\n        status|=DEC_Clamped;\r\n        }\r\n\r\n      // [fastpath for common case is not a win, here]\r\n      decDigitsToDPD(dn, targar, pad);\r\n      // save and clear the top digit\r\n      msd=targhi>>14;\r\n      targhi&=0x00003fff;\r\n\r\n      // create the combination field\r\n      if (msd>=8) comb=0x18 | ((exp>>11) & 0x06) | (msd & 0x01);\r\n             else comb=((exp>>9) & 0x18) | msd;\r\n      }\r\n    targhi|=comb<<26;              // add combination field ..\r\n    targhi|=(exp&0xfff)<<14;       // .. and exponent continuation\r\n    } // finite\r\n\r\n  if (dn->bits&DECNEG) targhi|=0x80000000; // add sign bit\r\n\r\n  // now write to storage; this is endian\r\n  if (DECLITEND) {\r\n    // lo -> hi\r\n    UBFROMUI(d128->bytes,    targlo);\r\n    UBFROMUI(d128->bytes+4,  targml);\r\n    UBFROMUI(d128->bytes+8,  targmh);\r\n    UBFROMUI(d128->bytes+12, targhi);\r\n    }\r\n   else {\r\n    // hi -> lo\r\n    UBFROMUI(d128->bytes,    targhi);\r\n    UBFROMUI(d128->bytes+4,  targmh);\r\n    UBFROMUI(d128->bytes+8,  targml);\r\n    UBFROMUI(d128->bytes+12, targlo);\r\n    }\r\n\r\n  if (status!=0) decContextSetStatus(set, status); // pass on status\r\n  // decimal128Show(d128);\r\n  return d128;\r\n  } // decimal128FromNumber\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal128ToNumber -- convert decimal128 to decNumber              */\r\n/*   d128 is the source decimal128                                    */\r\n/*   dn is the target number, with appropriate space                  */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decimal128ToNumber(const decimal128 *d128, decNumber *dn) {\r\n  uInt msd;                        // coefficient MSD\r\n  uInt exp;                        // exponent top two bits\r\n  uInt comb;                       // combination field\r\n  Int  need;                       // work\r\n  uInt uiwork;                     // for macros\r\n  uInt sourar[4];                  // source 128-bit\r\n  #define sourhi sourar[3]         // name the word with the sign\r\n  #define sourmh sourar[2]         // and the mid-high word\r\n  #define sourml sourar[1]         // and the mod-low word\r\n  #define sourlo sourar[0]         // and the lowest word\r\n\r\n  // load source from storage; this is endian\r\n  if (DECLITEND) {\r\n    sourlo=UBTOUI(d128->bytes   ); // directly load the low int\r\n    sourml=UBTOUI(d128->bytes+4 ); // then the mid-low\r\n    sourmh=UBTOUI(d128->bytes+8 ); // then the mid-high\r\n    sourhi=UBTOUI(d128->bytes+12); // then the high int\r\n    }\r\n   else {\r\n    sourhi=UBTOUI(d128->bytes   ); // directly load the high int\r\n    sourmh=UBTOUI(d128->bytes+4 ); // then the mid-high\r\n    sourml=UBTOUI(d128->bytes+8 ); // then the mid-low\r\n    sourlo=UBTOUI(d128->bytes+12); // then the low int\r\n    }\r\n\r\n  comb=(sourhi>>26)&0x1f;          // combination field\r\n\r\n  decNumberZero(dn);               // clean number\r\n  if (sourhi&0x80000000) dn->bits=DECNEG; // set sign if negative\r\n\r\n  msd=COMBMSD[comb];               // decode the combination field\r\n  exp=COMBEXP[comb];               // ..\r\n\r\n  if (exp==3) {                    // is a special\r\n    if (msd==0) {\r\n      dn->bits|=DECINF;\r\n      return dn;                   // no coefficient needed\r\n      }\r\n    else if (sourhi&0x02000000) dn->bits|=DECSNAN;\r\n    else dn->bits|=DECNAN;\r\n    msd=0;                         // no top digit\r\n    }\r\n   else {                          // is a finite number\r\n    dn->exponent=(exp<<12)+((sourhi>>14)&0xfff)-DECIMAL128_Bias; // unbiased\r\n    }\r\n\r\n  // get the coefficient\r\n  sourhi&=0x00003fff;              // clean coefficient continuation\r\n  if (msd) {                       // non-zero msd\r\n    sourhi|=msd<<14;               // prefix to coefficient\r\n    need=12;                       // process 12 declets\r\n    }\r\n   else { // msd=0\r\n    if (sourhi) need=11;           // declets to process\r\n     else if (sourmh) need=10;\r\n     else if (sourml) need=7;\r\n     else if (sourlo) need=4;\r\n     else return dn;               // easy: coefficient is 0\r\n    } //msd=0\r\n\r\n  decDigitsFromDPD(dn, sourar, need);   // process declets\r\n  // decNumberShow(dn);\r\n  return dn;\r\n  } // decimal128ToNumber\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* to-scientific-string -- conversion to numeric string               */\r\n/* to-engineering-string -- conversion to numeric string              */\r\n/*                                                                    */\r\n/*   decimal128ToString(d128, string);                                */\r\n/*   decimal128ToEngString(d128, string);                             */\r\n/*                                                                    */\r\n/*  d128 is the decimal128 format number to convert                   */\r\n/*  string is the string where the result will be laid out            */\r\n/*                                                                    */\r\n/*  string must be at least 24 characters                             */\r\n/*                                                                    */\r\n/*  No error is possible, and no status can be set.                   */\r\n/* ------------------------------------------------------------------ */\r\nchar * decimal128ToEngString(const decimal128 *d128, char *string){\r\n  decNumber dn;                         // work\r\n  decimal128ToNumber(d128, &dn);\r\n  decNumberToEngString(&dn, string);\r\n  return string;\r\n  } // decimal128ToEngString\r\n\r\nchar * decimal128ToString(const decimal128 *d128, char *string){\r\n  uInt msd;                        // coefficient MSD\r\n  Int  exp;                        // exponent top two bits or full\r\n  uInt comb;                       // combination field\r\n  char *cstart;                    // coefficient start\r\n  char *c;                         // output pointer in string\r\n  const uByte *u;                  // work\r\n  char *s, *t;                     // .. (source, target)\r\n  Int  dpd;                        // ..\r\n  Int  pre, e;                     // ..\r\n  uInt uiwork;                     // for macros\r\n\r\n  uInt sourar[4];                  // source 128-bit\r\n  #define sourhi sourar[3]         // name the word with the sign\r\n  #define sourmh sourar[2]         // and the mid-high word\r\n  #define sourml sourar[1]         // and the mod-low word\r\n  #define sourlo sourar[0]         // and the lowest word\r\n\r\n  // load source from storage; this is endian\r\n  if (DECLITEND) {\r\n    sourlo=UBTOUI(d128->bytes   ); // directly load the low int\r\n    sourml=UBTOUI(d128->bytes+4 ); // then the mid-low\r\n    sourmh=UBTOUI(d128->bytes+8 ); // then the mid-high\r\n    sourhi=UBTOUI(d128->bytes+12); // then the high int\r\n    }\r\n   else {\r\n    sourhi=UBTOUI(d128->bytes   ); // directly load the high int\r\n    sourmh=UBTOUI(d128->bytes+4 ); // then the mid-high\r\n    sourml=UBTOUI(d128->bytes+8 ); // then the mid-low\r\n    sourlo=UBTOUI(d128->bytes+12); // then the low int\r\n    }\r\n\r\n  c=string;                        // where result will go\r\n  if (((Int)sourhi)<0) *c++='-';   // handle sign\r\n\r\n  comb=(sourhi>>26)&0x1f;          // combination field\r\n  msd=COMBMSD[comb];               // decode the combination field\r\n  exp=COMBEXP[comb];               // ..\r\n\r\n  if (exp==3) {\r\n    if (msd==0) {                  // infinity\r\n      strcpy(c,   \"Inf\");\r\n      strcpy(c+3, \"inity\");\r\n      return string;               // easy\r\n      }\r\n    if (sourhi&0x02000000) *c++='s'; // sNaN\r\n    strcpy(c, \"NaN\");              // complete word\r\n    c+=3;                          // step past\r\n    if (sourlo==0 && sourml==0 && sourmh==0\r\n     && (sourhi&0x0003ffff)==0) return string; // zero payload\r\n    // otherwise drop through to add integer; set correct exp\r\n    exp=0; msd=0;                  // setup for following code\r\n    }\r\n   else exp=(exp<<12)+((sourhi>>14)&0xfff)-DECIMAL128_Bias; // unbiased\r\n\r\n  // convert 34 digits of significand to characters\r\n  cstart=c;                        // save start of coefficient\r\n  if (msd) *c++='0'+(char)msd;     // non-zero most significant digit\r\n\r\n  // Now decode the declets.  After extracting each one, it is\r\n  // decoded to binary and then to a 4-char sequence by table lookup;\r\n  // the 4-chars are a 1-char length (significant digits, except 000\r\n  // has length 0).  This allows us to left-align the first declet\r\n  // with non-zero content, then remaining ones are full 3-char\r\n  // length.  We use fixed-length memcpys because variable-length\r\n  // causes a subroutine call in GCC.  (These are length 4 for speed\r\n  // and are safe because the array has an extra terminator byte.)\r\n  #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4];                   \\\r\n                   if (c!=cstart) {memcpy(c, u+1, 4); c+=3;}      \\\r\n                    else if (*u)  {memcpy(c, u+4-*u, 4); c+=*u;}\r\n  dpd=(sourhi>>4)&0x3ff;                     // declet 1\r\n  dpd2char;\r\n  dpd=((sourhi&0xf)<<6) | (sourmh>>26);      // declet 2\r\n  dpd2char;\r\n  dpd=(sourmh>>16)&0x3ff;                    // declet 3\r\n  dpd2char;\r\n  dpd=(sourmh>>6)&0x3ff;                     // declet 4\r\n  dpd2char;\r\n  dpd=((sourmh&0x3f)<<4) | (sourml>>28);     // declet 5\r\n  dpd2char;\r\n  dpd=(sourml>>18)&0x3ff;                    // declet 6\r\n  dpd2char;\r\n  dpd=(sourml>>8)&0x3ff;                     // declet 7\r\n  dpd2char;\r\n  dpd=((sourml&0xff)<<2) | (sourlo>>30);     // declet 8\r\n  dpd2char;\r\n  dpd=(sourlo>>20)&0x3ff;                    // declet 9\r\n  dpd2char;\r\n  dpd=(sourlo>>10)&0x3ff;                    // declet 10\r\n  dpd2char;\r\n  dpd=(sourlo)&0x3ff;                        // declet 11\r\n  dpd2char;\r\n\r\n  if (c==cstart) *c++='0';         // all zeros -- make 0\r\n\r\n  if (exp==0) {                    // integer or NaN case -- easy\r\n    *c='\\0';                       // terminate\r\n    return string;\r\n    }\r\n\r\n  /* non-0 exponent */\r\n  e=0;                             // assume no E\r\n  pre=c-cstart+exp;\r\n  // [here, pre-exp is the digits count (==1 for zero)]\r\n  if (exp>0 || pre<-5) {           // need exponential form\r\n    e=pre-1;                       // calculate E value\r\n    pre=1;                         // assume one digit before '.'\r\n    } // exponential form\r\n\r\n  /* modify the coefficient, adding 0s, '.', and E+nn as needed */\r\n  s=c-1;                           // source (LSD)\r\n  if (pre>0) {                     // ddd.ddd (plain), perhaps with E\r\n    char *dotat=cstart+pre;\r\n    if (dotat<c) {                 // if embedded dot needed...\r\n      t=c;                              // target\r\n      for (; s>=dotat; s--, t--) *t=*s; // open the gap; leave t at gap\r\n      *t='.';                           // insert the dot\r\n      c++;                              // length increased by one\r\n      }\r\n\r\n    // finally add the E-part, if needed; it will never be 0, and has\r\n    // a maximum length of 4 digits\r\n    if (e!=0) {\r\n      *c++='E';                    // starts with E\r\n      *c++='+';                    // assume positive\r\n      if (e<0) {\r\n        *(c-1)='-';                // oops, need '-'\r\n        e=-e;                      // uInt, please\r\n        }\r\n      if (e<1000) {                // 3 (or fewer) digits case\r\n        u=&BIN2CHAR[e*4];          // -> length byte\r\n        memcpy(c, u+4-*u, 4);      // copy fixed 4 characters [is safe]\r\n        c+=*u;                     // bump pointer appropriately\r\n        }\r\n       else {                      // 4-digits\r\n        Int thou=((e>>3)*1049)>>17; // e/1000\r\n        Int rem=e-(1000*thou);      // e%1000\r\n        *c++='0'+(char)thou;\r\n        u=&BIN2CHAR[rem*4];        // -> length byte\r\n        memcpy(c, u+1, 4);         // copy fixed 3+1 characters [is safe]\r\n        c+=3;                      // bump pointer, always 3 digits\r\n        }\r\n      }\r\n    *c='\\0';                       // add terminator\r\n    //printf(\"res %s\\n\", string);\r\n    return string;\r\n    } // pre>0\r\n\r\n  /* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (can never have E) */\r\n  t=c+1-pre;\r\n  *(t+1)='\\0';                          // can add terminator now\r\n  for (; s>=cstart; s--, t--) *t=*s;    // shift whole coefficient right\r\n  c=cstart;\r\n  *c++='0';                             // always starts with 0.\r\n  *c++='.';\r\n  for (; pre<0; pre++) *c++='0';        // add any 0's after '.'\r\n  //printf(\"res %s\\n\", string);\r\n  return string;\r\n  } // decimal128ToString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* to-number -- conversion from numeric string                        */\r\n/*                                                                    */\r\n/*   decimal128FromString(result, string, set);                       */\r\n/*                                                                    */\r\n/*  result  is the decimal128 format number which gets the result of  */\r\n/*          the conversion                                            */\r\n/*  *string is the character string which should contain a valid      */\r\n/*          number (which may be a special value)                     */\r\n/*  set     is the context                                            */\r\n/*                                                                    */\r\n/* The context is supplied to this routine is used for error handling */\r\n/* (setting of status and traps) and for the rounding mode, only.     */\r\n/* If an error occurs, the result will be a valid decimal128 NaN.     */\r\n/* ------------------------------------------------------------------ */\r\ndecimal128 * decimal128FromString(decimal128 *result, const char *string,\r\n                                  decContext *set) {\r\n  decContext dc;                             // work\r\n  decNumber dn;                              // ..\r\n\r\n  decContextDefault(&dc, DEC_INIT_DECIMAL128); // no traps, please\r\n  dc.round=set->round;                         // use supplied rounding\r\n\r\n  decNumberFromString(&dn, string, &dc);     // will round if needed\r\n  decimal128FromNumber(result, &dn, &dc);\r\n  if (dc.status!=0) {                        // something happened\r\n    decContextSetStatus(set, dc.status);     // .. pass it on\r\n    }\r\n  return result;\r\n  } // decimal128FromString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal128IsCanonical -- test whether encoding is canonical        */\r\n/*   d128 is the source decimal128                                    */\r\n/*   returns 1 if the encoding of d128 is canonical, 0 otherwise      */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\nuInt decimal128IsCanonical(const decimal128 *d128) {\r\n  decNumber dn;                         // work\r\n  decimal128 canon;                      // ..\r\n  decContext dc;                        // ..\r\n  decContextDefault(&dc, DEC_INIT_DECIMAL128);\r\n  decimal128ToNumber(d128, &dn);\r\n  decimal128FromNumber(&canon, &dn, &dc);// canon will now be canonical\r\n  return memcmp(d128, &canon, DECIMAL128_Bytes)==0;\r\n  } // decimal128IsCanonical\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal128Canonical -- copy an encoding, ensuring it is canonical  */\r\n/*   d128 is the source decimal128                                    */\r\n/*   result is the target (may be the same decimal128)                */\r\n/*   returns result                                                   */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecimal128 * decimal128Canonical(decimal128 *result, const decimal128 *d128) {\r\n  decNumber dn;                         // work\r\n  decContext dc;                        // ..\r\n  decContextDefault(&dc, DEC_INIT_DECIMAL128);\r\n  decimal128ToNumber(d128, &dn);\r\n  decimal128FromNumber(result, &dn, &dc);// result will now be canonical\r\n  return result;\r\n  } // decimal128Canonical\r\n\r\n#if DECTRACE || DECCHECK\r\n/* Macros for accessing decimal128 fields.  These assume the argument\r\n   is a reference (pointer) to the decimal128 structure, and the\r\n   decimal128 is in network byte order (big-endian) */\r\n// Get sign\r\n#define decimal128Sign(d)       ((unsigned)(d)->bytes[0]>>7)\r\n\r\n// Get combination field\r\n#define decimal128Comb(d)       (((d)->bytes[0] & 0x7c)>>2)\r\n\r\n// Get exponent continuation [does not remove bias]\r\n#define decimal128ExpCon(d)     ((((d)->bytes[0] & 0x03)<<10)         \\\r\n                              | ((unsigned)(d)->bytes[1]<<2)          \\\r\n                              | ((unsigned)(d)->bytes[2]>>6))\r\n\r\n// Set sign [this assumes sign previously 0]\r\n#define decimal128SetSign(d, b) {                                     \\\r\n  (d)->bytes[0]|=((unsigned)(b)<<7);}\r\n\r\n// Set exponent continuation [does not apply bias]\r\n// This assumes range has been checked and exponent previously 0;\r\n// type of exponent must be unsigned\r\n#define decimal128SetExpCon(d, e) {                                   \\\r\n  (d)->bytes[0]|=(uByte)((e)>>10);                                    \\\r\n  (d)->bytes[1] =(uByte)(((e)&0x3fc)>>2);                             \\\r\n  (d)->bytes[2]|=(uByte)(((e)&0x03)<<6);}\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal128Show -- display a decimal128 in hexadecimal [debug aid]  */\r\n/*   d128 -- the number to show                                       */\r\n/* ------------------------------------------------------------------ */\r\n// Also shows sign/cob/expconfields extracted\r\nvoid decimal128Show(const decimal128 *d128) {\r\n  char buf[DECIMAL128_Bytes*2+1];\r\n  Int i, j=0;\r\n\r\n  if (DECLITEND) {\r\n    for (i=0; i<DECIMAL128_Bytes; i++, j+=2) {\r\n      sprintf(&buf[j], \"%02x\", d128->bytes[15-i]);\r\n      }\r\n    printf(\" D128> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\\n\", buf,\r\n           d128->bytes[15]>>7, (d128->bytes[15]>>2)&0x1f,\r\n           ((d128->bytes[15]&0x3)<<10)|(d128->bytes[14]<<2)|\r\n           (d128->bytes[13]>>6));\r\n    }\r\n   else {\r\n    for (i=0; i<DECIMAL128_Bytes; i++, j+=2) {\r\n      sprintf(&buf[j], \"%02x\", d128->bytes[i]);\r\n      }\r\n    printf(\" D128> %s [S:%d Cb:%02x Ec:%02x] BigEndian\\n\", buf,\r\n           decimal128Sign(d128), decimal128Comb(d128),\r\n           decimal128ExpCon(d128));\r\n    }\r\n  } // decimal128Show\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decimal128.h",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal 128-bit format module header                               */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2005.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#if !defined(DECIMAL128)\r\n  #define DECIMAL128\r\n  #define DEC128NAME     \"decimal128\"                 /* Short name   */\r\n  #define DEC128FULLNAME \"Decimal 128-bit Number\"     /* Verbose name */\r\n  #define DEC128AUTHOR   \"Mike Cowlishaw\"             /* Who to blame */\r\n\r\n  /* parameters for decimal128s */\r\n  #define DECIMAL128_Bytes  16          /* length                     */\r\n  #define DECIMAL128_Pmax   34          /* maximum precision (digits) */\r\n  #define DECIMAL128_Emax   6144        /* maximum adjusted exponent  */\r\n  #define DECIMAL128_Emin  -6143        /* minimum adjusted exponent  */\r\n  #define DECIMAL128_Bias   6176        /* bias for the exponent      */\r\n  #define DECIMAL128_String 43          /* maximum string length, +1  */\r\n  #define DECIMAL128_EconL  12          /* exp. continuation length   */\r\n  /* highest biased exponent (Elimit-1)                               */\r\n  #define DECIMAL128_Ehigh  (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1)\r\n\r\n  /* check enough digits, if pre-defined                              */\r\n  #if defined(DECNUMDIGITS)\r\n    #if (DECNUMDIGITS<DECIMAL128_Pmax)\r\n      #error decimal128.h needs pre-defined DECNUMDIGITS>=34 for safe use\r\n    #endif\r\n  #endif\r\n\r\n  #ifndef DECNUMDIGITS\r\n    #define DECNUMDIGITS DECIMAL128_Pmax /* size if not already defined*/\r\n  #endif\r\n  #ifndef DECNUMBER\r\n    #include \"decNumber.h\"              /* context and number library */\r\n  #endif\r\n\r\n  /* Decimal 128-bit type, accessible by bytes                        */\r\n  typedef struct {\r\n    uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits*/\r\n    } decimal128;\r\n\r\n  /* special values [top byte excluding sign bit; last two bits are   */\r\n  /* don't-care for Infinity on input, last bit don't-care for NaN]   */\r\n  #if !defined(DECIMAL_NaN)\r\n    #define DECIMAL_NaN     0x7c        /* 0 11111 00 NaN             */\r\n    #define DECIMAL_sNaN    0x7e        /* 0 11111 10 sNaN            */\r\n    #define DECIMAL_Inf     0x78        /* 0 11110 00 Infinity        */\r\n  #endif\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* Routines                                                         */\r\n  /* ---------------------------------------------------------------- */\r\n  /* String conversions                                               */\r\n  decimal128 * decimal128FromString(decimal128 *, const char *, decContext *);\r\n  char * decimal128ToString(const decimal128 *, char *);\r\n  char * decimal128ToEngString(const decimal128 *, char *);\r\n\r\n  /* decNumber conversions                                            */\r\n  decimal128 * decimal128FromNumber(decimal128 *, const decNumber *,\r\n                                    decContext *);\r\n  decNumber * decimal128ToNumber(const decimal128 *, decNumber *);\r\n\r\n  /* Format-dependent utilities                                       */\r\n  uint32_t    decimal128IsCanonical(const decimal128 *);\r\n  decimal128 * decimal128Canonical(decimal128 *, const decimal128 *);\r\n\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decimal32.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal 32-bit format module                                       */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2008.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This module comprises the routines for decimal32 format numbers.   */\r\n/* Conversions are supplied to and from decNumber and String.         */\r\n/*                                                                    */\r\n/* This is used when decNumber provides operations, either for all    */\r\n/* operations or as a proxy between decNumber and decSingle.          */\r\n/*                                                                    */\r\n/* Error handling is the same as decNumber (qv.).                     */\r\n/* ------------------------------------------------------------------ */\r\n#include <string.h>           // [for memset/memcpy]\r\n#include <stdio.h>            // [for printf]\r\n\r\n#define  DECNUMDIGITS  7      // make decNumbers with space for 7\r\n#include \"decNumber.h\"        // base number library\r\n#include \"decNumberLocal.h\"   // decNumber local types, etc.\r\n#include \"decimal32.h\"        // our primary include\r\n\r\n/* Utility tables and routines [in decimal64.c] */\r\n// DPD2BIN and the reverse are renamed to prevent link-time conflict\r\n// if decQuad is also built in the same executable\r\n#define DPD2BIN DPD2BINx\r\n#define BIN2DPD BIN2DPDx\r\nextern const uInt   COMBEXP[32], COMBMSD[32];\r\nextern const uShort DPD2BIN[1024];\r\nextern const uShort BIN2DPD[1000];\r\nextern const uByte  BIN2CHAR[4001];\r\n\r\nextern void decDigitsToDPD(const decNumber *, uInt *, Int);\r\nextern void decDigitsFromDPD(decNumber *, const uInt *, Int);\r\n\r\n#if DECTRACE || DECCHECK\r\nvoid decimal32Show(const decimal32 *);            // for debug\r\nextern void decNumberShow(const decNumber *);     // ..\r\n#endif\r\n\r\n/* Useful macro */\r\n// Clear a structure (e.g., a decNumber)\r\n#define DEC_clear(d) memset(d, 0, sizeof(*d))\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal32FromNumber -- convert decNumber to decimal32              */\r\n/*                                                                    */\r\n/*   ds is the target decimal32                                       */\r\n/*   dn is the source number (assumed valid)                          */\r\n/*   set is the context, used only for reporting errors               */\r\n/*                                                                    */\r\n/* The set argument is used only for status reporting and for the     */\r\n/* rounding mode (used if the coefficient is more than DECIMAL32_Pmax */\r\n/* digits or an overflow is detected).  If the exponent is out of the */\r\n/* valid range then Overflow or Underflow will be raised.             */\r\n/* After Underflow a subnormal result is possible.                    */\r\n/*                                                                    */\r\n/* DEC_Clamped is set if the number has to be 'folded down' to fit,   */\r\n/* by reducing its exponent and multiplying the coefficient by a      */\r\n/* power of ten, or if the exponent on a zero had to be clamped.      */\r\n/* ------------------------------------------------------------------ */\r\ndecimal32 * decimal32FromNumber(decimal32 *d32, const decNumber *dn,\r\n                              decContext *set) {\r\n  uInt status=0;                   // status accumulator\r\n  Int ae;                          // adjusted exponent\r\n  decNumber  dw;                   // work\r\n  decContext dc;                   // ..\r\n  uInt comb, exp;                  // ..\r\n  uInt uiwork;                     // for macros\r\n  uInt targ=0;                     // target 32-bit\r\n\r\n  // If the number has too many digits, or the exponent could be\r\n  // out of range then reduce the number under the appropriate\r\n  // constraints.  This could push the number to Infinity or zero,\r\n  // so this check and rounding must be done before generating the\r\n  // decimal32]\r\n  ae=dn->exponent+dn->digits-1;              // [0 if special]\r\n  if (dn->digits>DECIMAL32_Pmax              // too many digits\r\n   || ae>DECIMAL32_Emax                      // likely overflow\r\n   || ae<DECIMAL32_Emin) {                   // likely underflow\r\n    decContextDefault(&dc, DEC_INIT_DECIMAL32); // [no traps]\r\n    dc.round=set->round;                     // use supplied rounding\r\n    decNumberPlus(&dw, dn, &dc);             // (round and check)\r\n    // [this changes -0 to 0, so enforce the sign...]\r\n    dw.bits|=dn->bits&DECNEG;\r\n    status=dc.status;                        // save status\r\n    dn=&dw;                                  // use the work number\r\n    } // maybe out of range\r\n\r\n  if (dn->bits&DECSPECIAL) {                      // a special value\r\n    if (dn->bits&DECINF) targ=DECIMAL_Inf<<24;\r\n     else {                                       // sNaN or qNaN\r\n      if ((*dn->lsu!=0 || dn->digits>1)           // non-zero coefficient\r\n       && (dn->digits<DECIMAL32_Pmax)) {          // coefficient fits\r\n        decDigitsToDPD(dn, &targ, 0);\r\n        }\r\n      if (dn->bits&DECNAN) targ|=DECIMAL_NaN<<24;\r\n       else targ|=DECIMAL_sNaN<<24;\r\n      } // a NaN\r\n    } // special\r\n\r\n   else { // is finite\r\n    if (decNumberIsZero(dn)) {               // is a zero\r\n      // set and clamp exponent\r\n      if (dn->exponent<-DECIMAL32_Bias) {\r\n        exp=0;                               // low clamp\r\n        status|=DEC_Clamped;\r\n        }\r\n       else {\r\n        exp=dn->exponent+DECIMAL32_Bias;     // bias exponent\r\n        if (exp>DECIMAL32_Ehigh) {           // top clamp\r\n          exp=DECIMAL32_Ehigh;\r\n          status|=DEC_Clamped;\r\n          }\r\n        }\r\n      comb=(exp>>3) & 0x18;             // msd=0, exp top 2 bits ..\r\n      }\r\n     else {                             // non-zero finite number\r\n      uInt msd;                         // work\r\n      Int pad=0;                        // coefficient pad digits\r\n\r\n      // the dn is known to fit, but it may need to be padded\r\n      exp=(uInt)(dn->exponent+DECIMAL32_Bias);    // bias exponent\r\n      if (exp>DECIMAL32_Ehigh) {                  // fold-down case\r\n        pad=exp-DECIMAL32_Ehigh;\r\n        exp=DECIMAL32_Ehigh;                      // [to maximum]\r\n        status|=DEC_Clamped;\r\n        }\r\n\r\n      // fastpath common case\r\n      if (DECDPUN==3 && pad==0) {\r\n        targ=BIN2DPD[dn->lsu[0]];\r\n        if (dn->digits>3) targ|=(uInt)(BIN2DPD[dn->lsu[1]])<<10;\r\n        msd=(dn->digits==7 ? dn->lsu[2] : 0);\r\n        }\r\n       else { // general case\r\n        decDigitsToDPD(dn, &targ, pad);\r\n        // save and clear the top digit\r\n        msd=targ>>20;\r\n        targ&=0x000fffff;\r\n        }\r\n\r\n      // create the combination field\r\n      if (msd>=8) comb=0x18 | ((exp>>5) & 0x06) | (msd & 0x01);\r\n             else comb=((exp>>3) & 0x18) | msd;\r\n      }\r\n    targ|=comb<<26;                // add combination field ..\r\n    targ|=(exp&0x3f)<<20;          // .. and exponent continuation\r\n    } // finite\r\n\r\n  if (dn->bits&DECNEG) targ|=0x80000000;  // add sign bit\r\n\r\n  // now write to storage; this is endian\r\n  UBFROMUI(d32->bytes, targ);      // directly store the int\r\n\r\n  if (status!=0) decContextSetStatus(set, status); // pass on status\r\n  // decimal32Show(d32);\r\n  return d32;\r\n  } // decimal32FromNumber\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal32ToNumber -- convert decimal32 to decNumber                */\r\n/*   d32 is the source decimal32                                      */\r\n/*   dn is the target number, with appropriate space                  */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decimal32ToNumber(const decimal32 *d32, decNumber *dn) {\r\n  uInt msd;                        // coefficient MSD\r\n  uInt exp;                        // exponent top two bits\r\n  uInt comb;                       // combination field\r\n  uInt sour;                       // source 32-bit\r\n  uInt uiwork;                     // for macros\r\n\r\n  // load source from storage; this is endian\r\n  sour=UBTOUI(d32->bytes);         // directly load the int\r\n\r\n  comb=(sour>>26)&0x1f;            // combination field\r\n\r\n  decNumberZero(dn);               // clean number\r\n  if (sour&0x80000000) dn->bits=DECNEG; // set sign if negative\r\n\r\n  msd=COMBMSD[comb];               // decode the combination field\r\n  exp=COMBEXP[comb];               // ..\r\n\r\n  if (exp==3) {                    // is a special\r\n    if (msd==0) {\r\n      dn->bits|=DECINF;\r\n      return dn;                   // no coefficient needed\r\n      }\r\n    else if (sour&0x02000000) dn->bits|=DECSNAN;\r\n    else dn->bits|=DECNAN;\r\n    msd=0;                         // no top digit\r\n    }\r\n   else {                          // is a finite number\r\n    dn->exponent=(exp<<6)+((sour>>20)&0x3f)-DECIMAL32_Bias; // unbiased\r\n    }\r\n\r\n  // get the coefficient\r\n  sour&=0x000fffff;                // clean coefficient continuation\r\n  if (msd) {                       // non-zero msd\r\n    sour|=msd<<20;                 // prefix to coefficient\r\n    decDigitsFromDPD(dn, &sour, 3); // process 3 declets\r\n    return dn;\r\n    }\r\n  // msd=0\r\n  if (!sour) return dn;            // easy: coefficient is 0\r\n  if (sour&0x000ffc00)             // need 2 declets?\r\n    decDigitsFromDPD(dn, &sour, 2); // process 2 declets\r\n   else\r\n    decDigitsFromDPD(dn, &sour, 1); // process 1 declet\r\n  return dn;\r\n  } // decimal32ToNumber\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* to-scientific-string -- conversion to numeric string               */\r\n/* to-engineering-string -- conversion to numeric string              */\r\n/*                                                                    */\r\n/*   decimal32ToString(d32, string);                                  */\r\n/*   decimal32ToEngString(d32, string);                               */\r\n/*                                                                    */\r\n/*  d32 is the decimal32 format number to convert                     */\r\n/*  string is the string where the result will be laid out            */\r\n/*                                                                    */\r\n/*  string must be at least 24 characters                             */\r\n/*                                                                    */\r\n/*  No error is possible, and no status can be set.                   */\r\n/* ------------------------------------------------------------------ */\r\nchar * decimal32ToEngString(const decimal32 *d32, char *string){\r\n  decNumber dn;                         // work\r\n  decimal32ToNumber(d32, &dn);\r\n  decNumberToEngString(&dn, string);\r\n  return string;\r\n  } // decimal32ToEngString\r\n\r\nchar * decimal32ToString(const decimal32 *d32, char *string){\r\n  uInt msd;                        // coefficient MSD\r\n  Int  exp;                        // exponent top two bits or full\r\n  uInt comb;                       // combination field\r\n  char *cstart;                    // coefficient start\r\n  char *c;                         // output pointer in string\r\n  const uByte *u;                  // work\r\n  char *s, *t;                     // .. (source, target)\r\n  Int  dpd;                        // ..\r\n  Int  pre, e;                     // ..\r\n  uInt uiwork;                     // for macros\r\n  uInt sour;                       // source 32-bit\r\n\r\n  // load source from storage; this is endian\r\n  sour=UBTOUI(d32->bytes);         // directly load the int\r\n\r\n  c=string;                        // where result will go\r\n  if (((Int)sour)<0) *c++='-';     // handle sign\r\n\r\n  comb=(sour>>26)&0x1f;            // combination field\r\n  msd=COMBMSD[comb];               // decode the combination field\r\n  exp=COMBEXP[comb];               // ..\r\n\r\n  if (exp==3) {\r\n    if (msd==0) {                  // infinity\r\n      strcpy(c,   \"Inf\");\r\n      strcpy(c+3, \"inity\");\r\n      return string;               // easy\r\n      }\r\n    if (sour&0x02000000) *c++='s'; // sNaN\r\n    strcpy(c, \"NaN\");              // complete word\r\n    c+=3;                          // step past\r\n    if ((sour&0x000fffff)==0) return string; // zero payload\r\n    // otherwise drop through to add integer; set correct exp\r\n    exp=0; msd=0;                  // setup for following code\r\n    }\r\n   else exp=(exp<<6)+((sour>>20)&0x3f)-DECIMAL32_Bias; // unbiased\r\n\r\n  // convert 7 digits of significand to characters\r\n  cstart=c;                        // save start of coefficient\r\n  if (msd) *c++='0'+(char)msd;     // non-zero most significant digit\r\n\r\n  // Now decode the declets.  After extracting each one, it is\r\n  // decoded to binary and then to a 4-char sequence by table lookup;\r\n  // the 4-chars are a 1-char length (significant digits, except 000\r\n  // has length 0).  This allows us to left-align the first declet\r\n  // with non-zero content, then remaining ones are full 3-char\r\n  // length.  We use fixed-length memcpys because variable-length\r\n  // causes a subroutine call in GCC.  (These are length 4 for speed\r\n  // and are safe because the array has an extra terminator byte.)\r\n  #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4];                   \\\r\n                   if (c!=cstart) {memcpy(c, u+1, 4); c+=3;}      \\\r\n                    else if (*u)  {memcpy(c, u+4-*u, 4); c+=*u;}\r\n\r\n  dpd=(sour>>10)&0x3ff;            // declet 1\r\n  dpd2char;\r\n  dpd=(sour)&0x3ff;                // declet 2\r\n  dpd2char;\r\n\r\n  if (c==cstart) *c++='0';         // all zeros -- make 0\r\n\r\n  if (exp==0) {                    // integer or NaN case -- easy\r\n    *c='\\0';                       // terminate\r\n    return string;\r\n    }\r\n\r\n  /* non-0 exponent */\r\n  e=0;                             // assume no E\r\n  pre=c-cstart+exp;\r\n  // [here, pre-exp is the digits count (==1 for zero)]\r\n  if (exp>0 || pre<-5) {           // need exponential form\r\n    e=pre-1;                       // calculate E value\r\n    pre=1;                         // assume one digit before '.'\r\n    } // exponential form\r\n\r\n  /* modify the coefficient, adding 0s, '.', and E+nn as needed */\r\n  s=c-1;                           // source (LSD)\r\n  if (pre>0) {                     // ddd.ddd (plain), perhaps with E\r\n    char *dotat=cstart+pre;\r\n    if (dotat<c) {                 // if embedded dot needed...\r\n      t=c;                              // target\r\n      for (; s>=dotat; s--, t--) *t=*s; // open the gap; leave t at gap\r\n      *t='.';                           // insert the dot\r\n      c++;                              // length increased by one\r\n      }\r\n\r\n    // finally add the E-part, if needed; it will never be 0, and has\r\n    // a maximum length of 3 digits (E-101 case)\r\n    if (e!=0) {\r\n      *c++='E';                    // starts with E\r\n      *c++='+';                    // assume positive\r\n      if (e<0) {\r\n        *(c-1)='-';                // oops, need '-'\r\n        e=-e;                      // uInt, please\r\n        }\r\n      u=&BIN2CHAR[e*4];            // -> length byte\r\n      memcpy(c, u+4-*u, 4);        // copy fixed 4 characters [is safe]\r\n      c+=*u;                       // bump pointer appropriately\r\n      }\r\n    *c='\\0';                       // add terminator\r\n    //printf(\"res %s\\n\", string);\r\n    return string;\r\n    } // pre>0\r\n\r\n  /* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (can never have E) */\r\n  t=c+1-pre;\r\n  *(t+1)='\\0';                          // can add terminator now\r\n  for (; s>=cstart; s--, t--) *t=*s;    // shift whole coefficient right\r\n  c=cstart;\r\n  *c++='0';                             // always starts with 0.\r\n  *c++='.';\r\n  for (; pre<0; pre++) *c++='0';        // add any 0's after '.'\r\n  //printf(\"res %s\\n\", string);\r\n  return string;\r\n  } // decimal32ToString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* to-number -- conversion from numeric string                        */\r\n/*                                                                    */\r\n/*   decimal32FromString(result, string, set);                        */\r\n/*                                                                    */\r\n/*  result  is the decimal32 format number which gets the result of   */\r\n/*          the conversion                                            */\r\n/*  *string is the character string which should contain a valid      */\r\n/*          number (which may be a special value)                     */\r\n/*  set     is the context                                            */\r\n/*                                                                    */\r\n/* The context is supplied to this routine is used for error handling */\r\n/* (setting of status and traps) and for the rounding mode, only.     */\r\n/* If an error occurs, the result will be a valid decimal32 NaN.      */\r\n/* ------------------------------------------------------------------ */\r\ndecimal32 * decimal32FromString(decimal32 *result, const char *string,\r\n                                decContext *set) {\r\n  decContext dc;                             // work\r\n  decNumber dn;                              // ..\r\n\r\n  decContextDefault(&dc, DEC_INIT_DECIMAL32); // no traps, please\r\n  dc.round=set->round;                        // use supplied rounding\r\n\r\n  decNumberFromString(&dn, string, &dc);     // will round if needed\r\n  decimal32FromNumber(result, &dn, &dc);\r\n  if (dc.status!=0) {                        // something happened\r\n    decContextSetStatus(set, dc.status);     // .. pass it on\r\n    }\r\n  return result;\r\n  } // decimal32FromString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal32IsCanonical -- test whether encoding is canonical         */\r\n/*   d32 is the source decimal32                                      */\r\n/*   returns 1 if the encoding of d32 is canonical, 0 otherwise       */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\nuInt decimal32IsCanonical(const decimal32 *d32) {\r\n  decNumber dn;                         // work\r\n  decimal32 canon;                      // ..\r\n  decContext dc;                        // ..\r\n  decContextDefault(&dc, DEC_INIT_DECIMAL32);\r\n  decimal32ToNumber(d32, &dn);\r\n  decimal32FromNumber(&canon, &dn, &dc);// canon will now be canonical\r\n  return memcmp(d32, &canon, DECIMAL32_Bytes)==0;\r\n  } // decimal32IsCanonical\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal32Canonical -- copy an encoding, ensuring it is canonical   */\r\n/*   d32 is the source decimal32                                      */\r\n/*   result is the target (may be the same decimal32)                 */\r\n/*   returns result                                                   */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecimal32 * decimal32Canonical(decimal32 *result, const decimal32 *d32) {\r\n  decNumber dn;                         // work\r\n  decContext dc;                        // ..\r\n  decContextDefault(&dc, DEC_INIT_DECIMAL32);\r\n  decimal32ToNumber(d32, &dn);\r\n  decimal32FromNumber(result, &dn, &dc);// result will now be canonical\r\n  return result;\r\n  } // decimal32Canonical\r\n\r\n#if DECTRACE || DECCHECK\r\n/* Macros for accessing decimal32 fields.  These assume the argument\r\n   is a reference (pointer) to the decimal32 structure, and the\r\n   decimal32 is in network byte order (big-endian) */\r\n// Get sign\r\n#define decimal32Sign(d)       ((unsigned)(d)->bytes[0]>>7)\r\n\r\n// Get combination field\r\n#define decimal32Comb(d)       (((d)->bytes[0] & 0x7c)>>2)\r\n\r\n// Get exponent continuation [does not remove bias]\r\n#define decimal32ExpCon(d)     ((((d)->bytes[0] & 0x03)<<4)           \\\r\n                             | ((unsigned)(d)->bytes[1]>>4))\r\n\r\n// Set sign [this assumes sign previously 0]\r\n#define decimal32SetSign(d, b) {                                      \\\r\n  (d)->bytes[0]|=((unsigned)(b)<<7);}\r\n\r\n// Set exponent continuation [does not apply bias]\r\n// This assumes range has been checked and exponent previously 0;\r\n// type of exponent must be unsigned\r\n#define decimal32SetExpCon(d, e) {                                    \\\r\n  (d)->bytes[0]|=(uByte)((e)>>4);                                     \\\r\n  (d)->bytes[1]|=(uByte)(((e)&0x0F)<<4);}\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal32Show -- display a decimal32 in hexadecimal [debug aid]    */\r\n/*   d32 -- the number to show                                        */\r\n/* ------------------------------------------------------------------ */\r\n// Also shows sign/cob/expconfields extracted - valid bigendian only\r\nvoid decimal32Show(const decimal32 *d32) {\r\n  char buf[DECIMAL32_Bytes*2+1];\r\n  Int i, j=0;\r\n\r\n  if (DECLITEND) {\r\n    for (i=0; i<DECIMAL32_Bytes; i++, j+=2) {\r\n      sprintf(&buf[j], \"%02x\", d32->bytes[3-i]);\r\n      }\r\n    printf(\" D32> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\\n\", buf,\r\n           d32->bytes[3]>>7, (d32->bytes[3]>>2)&0x1f,\r\n           ((d32->bytes[3]&0x3)<<4)| (d32->bytes[2]>>4));\r\n    }\r\n   else {\r\n    for (i=0; i<DECIMAL32_Bytes; i++, j+=2) {\r\n      sprintf(&buf[j], \"%02x\", d32->bytes[i]);\r\n      }\r\n    printf(\" D32> %s [S:%d Cb:%02x Ec:%02x] BigEndian\\n\", buf,\r\n           decimal32Sign(d32), decimal32Comb(d32), decimal32ExpCon(d32));\r\n    }\r\n  } // decimal32Show\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decimal32.h",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal 32-bit format module header                                */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2006.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#if !defined(DECIMAL32)\r\n  #define DECIMAL32\r\n  #define DEC32NAME     \"decimal32\"                   /* Short name   */\r\n  #define DEC32FULLNAME \"Decimal 32-bit Number\"       /* Verbose name */\r\n  #define DEC32AUTHOR   \"Mike Cowlishaw\"              /* Who to blame */\r\n\r\n  /* parameters for decimal32s */\r\n  #define DECIMAL32_Bytes  4            /* length                     */\r\n  #define DECIMAL32_Pmax   7            /* maximum precision (digits) */\r\n  #define DECIMAL32_Emax   96           /* maximum adjusted exponent  */\r\n  #define DECIMAL32_Emin  -95           /* minimum adjusted exponent  */\r\n  #define DECIMAL32_Bias   101          /* bias for the exponent      */\r\n  #define DECIMAL32_String 15           /* maximum string length, +1  */\r\n  #define DECIMAL32_EconL  6            /* exp. continuation length   */\r\n  /* highest biased exponent (Elimit-1)                               */\r\n  #define DECIMAL32_Ehigh  (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1)\r\n\r\n  /* check enough digits, if pre-defined                              */\r\n  #if defined(DECNUMDIGITS)\r\n    #if (DECNUMDIGITS<DECIMAL32_Pmax)\r\n      #error decimal32.h needs pre-defined DECNUMDIGITS>=7 for safe use\r\n    #endif\r\n  #endif\r\n\r\n  #ifndef DECNUMDIGITS\r\n    #define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined*/\r\n  #endif\r\n  #ifndef DECNUMBER\r\n    #include \"decNumber.h\"              /* context and number library */\r\n  #endif\r\n\r\n  /* Decimal 32-bit type, accessible by bytes */\r\n  typedef struct {\r\n    uint8_t bytes[DECIMAL32_Bytes];     /* decimal32: 1, 5, 6, 20 bits*/\r\n    } decimal32;\r\n\r\n  /* special values [top byte excluding sign bit; last two bits are   */\r\n  /* don't-care for Infinity on input, last bit don't-care for NaN]   */\r\n  #if !defined(DECIMAL_NaN)\r\n    #define DECIMAL_NaN     0x7c        /* 0 11111 00 NaN             */\r\n    #define DECIMAL_sNaN    0x7e        /* 0 11111 10 sNaN            */\r\n    #define DECIMAL_Inf     0x78        /* 0 11110 00 Infinity        */\r\n  #endif\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* Routines                                                         */\r\n  /* ---------------------------------------------------------------- */\r\n  /* String conversions                                               */\r\n  decimal32 * decimal32FromString(decimal32 *, const char *, decContext *);\r\n  char * decimal32ToString(const decimal32 *, char *);\r\n  char * decimal32ToEngString(const decimal32 *, char *);\r\n\r\n  /* decNumber conversions                                            */\r\n  decimal32 * decimal32FromNumber(decimal32 *, const decNumber *,\r\n                                  decContext *);\r\n  decNumber * decimal32ToNumber(const decimal32 *, decNumber *);\r\n\r\n  /* Format-dependent utilities                                       */\r\n  uint32_t    decimal32IsCanonical(const decimal32 *);\r\n  decimal32 * decimal32Canonical(decimal32 *, const decimal32 *);\r\n\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/decimal64.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal 64-bit format module                                       */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2009.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n/* This module comprises the routines for decimal64 format numbers.   */\r\n/* Conversions are supplied to and from decNumber and String.         */\r\n/*                                                                    */\r\n/* This is used when decNumber provides operations, either for all    */\r\n/* operations or as a proxy between decNumber and decSingle.          */\r\n/*                                                                    */\r\n/* Error handling is the same as decNumber (qv.).                     */\r\n/* ------------------------------------------------------------------ */\r\n#include <string.h>           // [for memset/memcpy]\r\n#include <stdio.h>            // [for printf]\r\n\r\n#define  DECNUMDIGITS 16      // make decNumbers with space for 16\r\n#include \"decNumber.h\"        // base number library\r\n#include \"decNumberLocal.h\"   // decNumber local types, etc.\r\n#include \"decimal64.h\"        // our primary include\r\n\r\n/* Utility routines and tables [in decimal64.c]; externs for C++ */\r\n// DPD2BIN and the reverse are renamed to prevent link-time conflict\r\n// if decQuad is also built in the same executable\r\n#define DPD2BIN DPD2BINx\r\n#define BIN2DPD BIN2DPDx\r\nextern const uInt COMBEXP[32], COMBMSD[32];\r\nextern const uShort DPD2BIN[1024];\r\nextern const uShort BIN2DPD[1000];\r\nextern const uByte  BIN2CHAR[4001];\r\n\r\nextern void decDigitsFromDPD(decNumber *, const uInt *, Int);\r\nextern void decDigitsToDPD(const decNumber *, uInt *, Int);\r\n\r\n#if DECTRACE || DECCHECK\r\nvoid decimal64Show(const decimal64 *);            // for debug\r\nextern void decNumberShow(const decNumber *);     // ..\r\n#endif\r\n\r\n/* Useful macro */\r\n// Clear a structure (e.g., a decNumber)\r\n#define DEC_clear(d) memset(d, 0, sizeof(*d))\r\n\r\n/* define and include the tables to use for conversions */\r\n#define DEC_BIN2CHAR 1\r\n#define DEC_DPD2BIN  1\r\n#define DEC_BIN2DPD  1             // used for all sizes\r\n#include \"decDPD.h\"                // lookup tables\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal64FromNumber -- convert decNumber to decimal64              */\r\n/*                                                                    */\r\n/*   ds is the target decimal64                                       */\r\n/*   dn is the source number (assumed valid)                          */\r\n/*   set is the context, used only for reporting errors               */\r\n/*                                                                    */\r\n/* The set argument is used only for status reporting and for the     */\r\n/* rounding mode (used if the coefficient is more than DECIMAL64_Pmax */\r\n/* digits or an overflow is detected).  If the exponent is out of the */\r\n/* valid range then Overflow or Underflow will be raised.             */\r\n/* After Underflow a subnormal result is possible.                    */\r\n/*                                                                    */\r\n/* DEC_Clamped is set if the number has to be 'folded down' to fit,   */\r\n/* by reducing its exponent and multiplying the coefficient by a      */\r\n/* power of ten, or if the exponent on a zero had to be clamped.      */\r\n/* ------------------------------------------------------------------ */\r\ndecimal64 * decimal64FromNumber(decimal64 *d64, const decNumber *dn,\r\n                                decContext *set) {\r\n  uInt status=0;                   // status accumulator\r\n  Int ae;                          // adjusted exponent\r\n  decNumber  dw;                   // work\r\n  decContext dc;                   // ..\r\n  uInt comb, exp;                  // ..\r\n  uInt uiwork;                     // for macros\r\n  uInt targar[2]={0, 0};           // target 64-bit\r\n  #define targhi targar[1]         // name the word with the sign\r\n  #define targlo targar[0]         // and the other\r\n\r\n  // If the number has too many digits, or the exponent could be\r\n  // out of range then reduce the number under the appropriate\r\n  // constraints.  This could push the number to Infinity or zero,\r\n  // so this check and rounding must be done before generating the\r\n  // decimal64]\r\n  ae=dn->exponent+dn->digits-1;              // [0 if special]\r\n  if (dn->digits>DECIMAL64_Pmax              // too many digits\r\n   || ae>DECIMAL64_Emax                      // likely overflow\r\n   || ae<DECIMAL64_Emin) {                   // likely underflow\r\n    decContextDefault(&dc, DEC_INIT_DECIMAL64); // [no traps]\r\n    dc.round=set->round;                     // use supplied rounding\r\n    decNumberPlus(&dw, dn, &dc);             // (round and check)\r\n    // [this changes -0 to 0, so enforce the sign...]\r\n    dw.bits|=dn->bits&DECNEG;\r\n    status=dc.status;                        // save status\r\n    dn=&dw;                                  // use the work number\r\n    } // maybe out of range\r\n\r\n  if (dn->bits&DECSPECIAL) {                      // a special value\r\n    if (dn->bits&DECINF) targhi=DECIMAL_Inf<<24;\r\n     else {                                       // sNaN or qNaN\r\n      if ((*dn->lsu!=0 || dn->digits>1)           // non-zero coefficient\r\n       && (dn->digits<DECIMAL64_Pmax)) {          // coefficient fits\r\n        decDigitsToDPD(dn, targar, 0);\r\n        }\r\n      if (dn->bits&DECNAN) targhi|=DECIMAL_NaN<<24;\r\n       else targhi|=DECIMAL_sNaN<<24;\r\n      } // a NaN\r\n    } // special\r\n\r\n   else { // is finite\r\n    if (decNumberIsZero(dn)) {               // is a zero\r\n      // set and clamp exponent\r\n      if (dn->exponent<-DECIMAL64_Bias) {\r\n        exp=0;                               // low clamp\r\n        status|=DEC_Clamped;\r\n        }\r\n       else {\r\n        exp=dn->exponent+DECIMAL64_Bias;     // bias exponent\r\n        if (exp>DECIMAL64_Ehigh) {           // top clamp\r\n          exp=DECIMAL64_Ehigh;\r\n          status|=DEC_Clamped;\r\n          }\r\n        }\r\n      comb=(exp>>5) & 0x18;             // msd=0, exp top 2 bits ..\r\n      }\r\n     else {                             // non-zero finite number\r\n      uInt msd;                         // work\r\n      Int pad=0;                        // coefficient pad digits\r\n\r\n      // the dn is known to fit, but it may need to be padded\r\n      exp=(uInt)(dn->exponent+DECIMAL64_Bias);    // bias exponent\r\n      if (exp>DECIMAL64_Ehigh) {                  // fold-down case\r\n        pad=exp-DECIMAL64_Ehigh;\r\n        exp=DECIMAL64_Ehigh;                      // [to maximum]\r\n        status|=DEC_Clamped;\r\n        }\r\n\r\n      // fastpath common case\r\n      if (DECDPUN==3 && pad==0) {\r\n        uInt dpd[6]={0,0,0,0,0,0};\r\n        uInt i;\r\n        Int d=dn->digits;\r\n        for (i=0; d>0; i++, d-=3) dpd[i]=BIN2DPD[dn->lsu[i]];\r\n        targlo =dpd[0];\r\n        targlo|=dpd[1]<<10;\r\n        targlo|=dpd[2]<<20;\r\n        if (dn->digits>6) {\r\n          targlo|=dpd[3]<<30;\r\n          targhi =dpd[3]>>2;\r\n          targhi|=dpd[4]<<8;\r\n          }\r\n        msd=dpd[5];                // [did not really need conversion]\r\n        }\r\n       else { // general case\r\n        decDigitsToDPD(dn, targar, pad);\r\n        // save and clear the top digit\r\n        msd=targhi>>18;\r\n        targhi&=0x0003ffff;\r\n        }\r\n\r\n      // create the combination field\r\n      if (msd>=8) comb=0x18 | ((exp>>7) & 0x06) | (msd & 0x01);\r\n             else comb=((exp>>5) & 0x18) | msd;\r\n      }\r\n    targhi|=comb<<26;              // add combination field ..\r\n    targhi|=(exp&0xff)<<18;        // .. and exponent continuation\r\n    } // finite\r\n\r\n  if (dn->bits&DECNEG) targhi|=0x80000000; // add sign bit\r\n\r\n  // now write to storage; this is now always endian\r\n  if (DECLITEND) {\r\n    // lo int then hi\r\n    UBFROMUI(d64->bytes,   targar[0]);\r\n    UBFROMUI(d64->bytes+4, targar[1]);\r\n    }\r\n   else {\r\n    // hi int then lo\r\n    UBFROMUI(d64->bytes,   targar[1]);\r\n    UBFROMUI(d64->bytes+4, targar[0]);\r\n    }\r\n\r\n  if (status!=0) decContextSetStatus(set, status); // pass on status\r\n  // decimal64Show(d64);\r\n  return d64;\r\n  } // decimal64FromNumber\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal64ToNumber -- convert decimal64 to decNumber                */\r\n/*   d64 is the source decimal64                                      */\r\n/*   dn is the target number, with appropriate space                  */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecNumber * decimal64ToNumber(const decimal64 *d64, decNumber *dn) {\r\n  uInt msd;                        // coefficient MSD\r\n  uInt exp;                        // exponent top two bits\r\n  uInt comb;                       // combination field\r\n  Int  need;                       // work\r\n  uInt uiwork;                     // for macros\r\n  uInt sourar[2];                  // source 64-bit\r\n  #define sourhi sourar[1]         // name the word with the sign\r\n  #define sourlo sourar[0]         // and the lower word\r\n\r\n  // load source from storage; this is endian\r\n  if (DECLITEND) {\r\n    sourlo=UBTOUI(d64->bytes  );   // directly load the low int\r\n    sourhi=UBTOUI(d64->bytes+4);   // then the high int\r\n    }\r\n   else {\r\n    sourhi=UBTOUI(d64->bytes  );   // directly load the high int\r\n    sourlo=UBTOUI(d64->bytes+4);   // then the low int\r\n    }\r\n\r\n  comb=(sourhi>>26)&0x1f;          // combination field\r\n\r\n  decNumberZero(dn);               // clean number\r\n  if (sourhi&0x80000000) dn->bits=DECNEG; // set sign if negative\r\n\r\n  msd=COMBMSD[comb];               // decode the combination field\r\n  exp=COMBEXP[comb];               // ..\r\n\r\n  if (exp==3) {                    // is a special\r\n    if (msd==0) {\r\n      dn->bits|=DECINF;\r\n      return dn;                   // no coefficient needed\r\n      }\r\n    else if (sourhi&0x02000000) dn->bits|=DECSNAN;\r\n    else dn->bits|=DECNAN;\r\n    msd=0;                         // no top digit\r\n    }\r\n   else {                          // is a finite number\r\n    dn->exponent=(exp<<8)+((sourhi>>18)&0xff)-DECIMAL64_Bias; // unbiased\r\n    }\r\n\r\n  // get the coefficient\r\n  sourhi&=0x0003ffff;              // clean coefficient continuation\r\n  if (msd) {                       // non-zero msd\r\n    sourhi|=msd<<18;               // prefix to coefficient\r\n    need=6;                        // process 6 declets\r\n    }\r\n   else { // msd=0\r\n    if (!sourhi) {                 // top word 0\r\n      if (!sourlo) return dn;      // easy: coefficient is 0\r\n      need=3;                      // process at least 3 declets\r\n      if (sourlo&0xc0000000) need++; // process 4 declets\r\n      // [could reduce some more, here]\r\n      }\r\n     else {                        // some bits in top word, msd=0\r\n      need=4;                      // process at least 4 declets\r\n      if (sourhi&0x0003ff00) need++; // top declet!=0, process 5\r\n      }\r\n    } //msd=0\r\n\r\n  decDigitsFromDPD(dn, sourar, need);   // process declets\r\n  return dn;\r\n  } // decimal64ToNumber\r\n\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* to-scientific-string -- conversion to numeric string               */\r\n/* to-engineering-string -- conversion to numeric string              */\r\n/*                                                                    */\r\n/*   decimal64ToString(d64, string);                                  */\r\n/*   decimal64ToEngString(d64, string);                               */\r\n/*                                                                    */\r\n/*  d64 is the decimal64 format number to convert                     */\r\n/*  string is the string where the result will be laid out            */\r\n/*                                                                    */\r\n/*  string must be at least 24 characters                             */\r\n/*                                                                    */\r\n/*  No error is possible, and no status can be set.                   */\r\n/* ------------------------------------------------------------------ */\r\nchar * decimal64ToEngString(const decimal64 *d64, char *string){\r\n  decNumber dn;                         // work\r\n  decimal64ToNumber(d64, &dn);\r\n  decNumberToEngString(&dn, string);\r\n  return string;\r\n  } // decimal64ToEngString\r\n\r\nchar * decimal64ToString(const decimal64 *d64, char *string){\r\n  uInt msd;                        // coefficient MSD\r\n  Int  exp;                        // exponent top two bits or full\r\n  uInt comb;                       // combination field\r\n  char *cstart;                    // coefficient start\r\n  char *c;                         // output pointer in string\r\n  const uByte *u;                  // work\r\n  char *s, *t;                     // .. (source, target)\r\n  Int  dpd;                        // ..\r\n  Int  pre, e;                     // ..\r\n  uInt uiwork;                     // for macros\r\n\r\n  uInt sourar[2];                  // source 64-bit\r\n  #define sourhi sourar[1]         // name the word with the sign\r\n  #define sourlo sourar[0]         // and the lower word\r\n\r\n  // load source from storage; this is endian\r\n  if (DECLITEND) {\r\n    sourlo=UBTOUI(d64->bytes  );   // directly load the low int\r\n    sourhi=UBTOUI(d64->bytes+4);   // then the high int\r\n    }\r\n   else {\r\n    sourhi=UBTOUI(d64->bytes  );   // directly load the high int\r\n    sourlo=UBTOUI(d64->bytes+4);   // then the low int\r\n    }\r\n\r\n  c=string;                        // where result will go\r\n  if (((Int)sourhi)<0) *c++='-';   // handle sign\r\n\r\n  comb=(sourhi>>26)&0x1f;          // combination field\r\n  msd=COMBMSD[comb];               // decode the combination field\r\n  exp=COMBEXP[comb];               // ..\r\n\r\n  if (exp==3) {\r\n    if (msd==0) {                  // infinity\r\n      strcpy(c,   \"Inf\");\r\n      strcpy(c+3, \"inity\");\r\n      return string;               // easy\r\n      }\r\n    if (sourhi&0x02000000) *c++='s'; // sNaN\r\n    strcpy(c, \"NaN\");              // complete word\r\n    c+=3;                          // step past\r\n    if (sourlo==0 && (sourhi&0x0003ffff)==0) return string; // zero payload\r\n    // otherwise drop through to add integer; set correct exp\r\n    exp=0; msd=0;                  // setup for following code\r\n    }\r\n   else exp=(exp<<8)+((sourhi>>18)&0xff)-DECIMAL64_Bias;\r\n\r\n  // convert 16 digits of significand to characters\r\n  cstart=c;                        // save start of coefficient\r\n  if (msd) *c++='0'+(char)msd;     // non-zero most significant digit\r\n\r\n  // Now decode the declets.  After extracting each one, it is\r\n  // decoded to binary and then to a 4-char sequence by table lookup;\r\n  // the 4-chars are a 1-char length (significant digits, except 000\r\n  // has length 0).  This allows us to left-align the first declet\r\n  // with non-zero content, then remaining ones are full 3-char\r\n  // length.  We use fixed-length memcpys because variable-length\r\n  // causes a subroutine call in GCC.  (These are length 4 for speed\r\n  // and are safe because the array has an extra terminator byte.)\r\n  #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4];                   \\\r\n                   if (c!=cstart) {memcpy(c, u+1, 4); c+=3;}      \\\r\n                    else if (*u)  {memcpy(c, u+4-*u, 4); c+=*u;}\r\n\r\n  dpd=(sourhi>>8)&0x3ff;                     // declet 1\r\n  dpd2char;\r\n  dpd=((sourhi&0xff)<<2) | (sourlo>>30);     // declet 2\r\n  dpd2char;\r\n  dpd=(sourlo>>20)&0x3ff;                    // declet 3\r\n  dpd2char;\r\n  dpd=(sourlo>>10)&0x3ff;                    // declet 4\r\n  dpd2char;\r\n  dpd=(sourlo)&0x3ff;                        // declet 5\r\n  dpd2char;\r\n\r\n  if (c==cstart) *c++='0';         // all zeros -- make 0\r\n\r\n  if (exp==0) {                    // integer or NaN case -- easy\r\n    *c='\\0';                       // terminate\r\n    return string;\r\n    }\r\n\r\n  /* non-0 exponent */\r\n  e=0;                             // assume no E\r\n  pre=c-cstart+exp;\r\n  // [here, pre-exp is the digits count (==1 for zero)]\r\n  if (exp>0 || pre<-5) {           // need exponential form\r\n    e=pre-1;                       // calculate E value\r\n    pre=1;                         // assume one digit before '.'\r\n    } // exponential form\r\n\r\n  /* modify the coefficient, adding 0s, '.', and E+nn as needed */\r\n  s=c-1;                           // source (LSD)\r\n  if (pre>0) {                     // ddd.ddd (plain), perhaps with E\r\n    char *dotat=cstart+pre;\r\n    if (dotat<c) {                 // if embedded dot needed...\r\n      t=c;                              // target\r\n      for (; s>=dotat; s--, t--) *t=*s; // open the gap; leave t at gap\r\n      *t='.';                           // insert the dot\r\n      c++;                              // length increased by one\r\n      }\r\n\r\n    // finally add the E-part, if needed; it will never be 0, and has\r\n    // a maximum length of 3 digits\r\n    if (e!=0) {\r\n      *c++='E';                    // starts with E\r\n      *c++='+';                    // assume positive\r\n      if (e<0) {\r\n        *(c-1)='-';                // oops, need '-'\r\n        e=-e;                      // uInt, please\r\n        }\r\n      u=&BIN2CHAR[e*4];            // -> length byte\r\n      memcpy(c, u+4-*u, 4);        // copy fixed 4 characters [is safe]\r\n      c+=*u;                       // bump pointer appropriately\r\n      }\r\n    *c='\\0';                       // add terminator\r\n    //printf(\"res %s\\n\", string);\r\n    return string;\r\n    } // pre>0\r\n\r\n  /* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (can never have E) */\r\n  t=c+1-pre;\r\n  *(t+1)='\\0';                          // can add terminator now\r\n  for (; s>=cstart; s--, t--) *t=*s;    // shift whole coefficient right\r\n  c=cstart;\r\n  *c++='0';                             // always starts with 0.\r\n  *c++='.';\r\n  for (; pre<0; pre++) *c++='0';        // add any 0's after '.'\r\n  //printf(\"res %s\\n\", string);\r\n  return string;\r\n  } // decimal64ToString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* to-number -- conversion from numeric string                        */\r\n/*                                                                    */\r\n/*   decimal64FromString(result, string, set);                        */\r\n/*                                                                    */\r\n/*  result  is the decimal64 format number which gets the result of   */\r\n/*          the conversion                                            */\r\n/*  *string is the character string which should contain a valid      */\r\n/*          number (which may be a special value)                     */\r\n/*  set     is the context                                            */\r\n/*                                                                    */\r\n/* The context is supplied to this routine is used for error handling */\r\n/* (setting of status and traps) and for the rounding mode, only.     */\r\n/* If an error occurs, the result will be a valid decimal64 NaN.      */\r\n/* ------------------------------------------------------------------ */\r\ndecimal64 * decimal64FromString(decimal64 *result, const char *string,\r\n                                decContext *set) {\r\n  decContext dc;                             // work\r\n  decNumber dn;                              // ..\r\n\r\n  decContextDefault(&dc, DEC_INIT_DECIMAL64); // no traps, please\r\n  dc.round=set->round;                        // use supplied rounding\r\n\r\n  decNumberFromString(&dn, string, &dc);     // will round if needed\r\n\r\n  decimal64FromNumber(result, &dn, &dc);\r\n  if (dc.status!=0) {                        // something happened\r\n    decContextSetStatus(set, dc.status);     // .. pass it on\r\n    }\r\n  return result;\r\n  } // decimal64FromString\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal64IsCanonical -- test whether encoding is canonical         */\r\n/*   d64 is the source decimal64                                      */\r\n/*   returns 1 if the encoding of d64 is canonical, 0 otherwise       */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\nuInt decimal64IsCanonical(const decimal64 *d64) {\r\n  decNumber dn;                         // work\r\n  decimal64 canon;                      // ..\r\n  decContext dc;                        // ..\r\n  decContextDefault(&dc, DEC_INIT_DECIMAL64);\r\n  decimal64ToNumber(d64, &dn);\r\n  decimal64FromNumber(&canon, &dn, &dc);// canon will now be canonical\r\n  return memcmp(d64, &canon, DECIMAL64_Bytes)==0;\r\n  } // decimal64IsCanonical\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal64Canonical -- copy an encoding, ensuring it is canonical   */\r\n/*   d64 is the source decimal64                                      */\r\n/*   result is the target (may be the same decimal64)                 */\r\n/*   returns result                                                   */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\ndecimal64 * decimal64Canonical(decimal64 *result, const decimal64 *d64) {\r\n  decNumber dn;                         // work\r\n  decContext dc;                        // ..\r\n  decContextDefault(&dc, DEC_INIT_DECIMAL64);\r\n  decimal64ToNumber(d64, &dn);\r\n  decimal64FromNumber(result, &dn, &dc);// result will now be canonical\r\n  return result;\r\n  } // decimal64Canonical\r\n\r\n#if DECTRACE || DECCHECK\r\n/* Macros for accessing decimal64 fields.  These assume the\r\n   argument is a reference (pointer) to the decimal64 structure,\r\n   and the decimal64 is in network byte order (big-endian) */\r\n// Get sign\r\n#define decimal64Sign(d)       ((unsigned)(d)->bytes[0]>>7)\r\n\r\n// Get combination field\r\n#define decimal64Comb(d)       (((d)->bytes[0] & 0x7c)>>2)\r\n\r\n// Get exponent continuation [does not remove bias]\r\n#define decimal64ExpCon(d)     ((((d)->bytes[0] & 0x03)<<6)           \\\r\n                             | ((unsigned)(d)->bytes[1]>>2))\r\n\r\n// Set sign [this assumes sign previously 0]\r\n#define decimal64SetSign(d, b) {                                      \\\r\n  (d)->bytes[0]|=((unsigned)(b)<<7);}\r\n\r\n// Set exponent continuation [does not apply bias]\r\n// This assumes range has been checked and exponent previously 0;\r\n// type of exponent must be unsigned\r\n#define decimal64SetExpCon(d, e) {                                    \\\r\n  (d)->bytes[0]|=(uByte)((e)>>6);                                     \\\r\n  (d)->bytes[1]|=(uByte)(((e)&0x3F)<<2);}\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decimal64Show -- display a decimal64 in hexadecimal [debug aid]    */\r\n/*   d64 -- the number to show                                        */\r\n/* ------------------------------------------------------------------ */\r\n// Also shows sign/cob/expconfields extracted\r\nvoid decimal64Show(const decimal64 *d64) {\r\n  char buf[DECIMAL64_Bytes*2+1];\r\n  Int i, j=0;\r\n\r\n  if (DECLITEND) {\r\n    for (i=0; i<DECIMAL64_Bytes; i++, j+=2) {\r\n      sprintf(&buf[j], \"%02x\", d64->bytes[7-i]);\r\n      }\r\n    printf(\" D64> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\\n\", buf,\r\n           d64->bytes[7]>>7, (d64->bytes[7]>>2)&0x1f,\r\n           ((d64->bytes[7]&0x3)<<6)| (d64->bytes[6]>>2));\r\n    }\r\n   else { // big-endian\r\n    for (i=0; i<DECIMAL64_Bytes; i++, j+=2) {\r\n      sprintf(&buf[j], \"%02x\", d64->bytes[i]);\r\n      }\r\n    printf(\" D64> %s [S:%d Cb:%02x Ec:%02x] BigEndian\\n\", buf,\r\n           decimal64Sign(d64), decimal64Comb(d64), decimal64ExpCon(d64));\r\n    }\r\n  } // decimal64Show\r\n#endif\r\n\r\n/* ================================================================== */\r\n/* Shared utility routines and tables                                 */\r\n/* ================================================================== */\r\n// define and include the conversion tables to use for shared code\r\n#if DECDPUN==3\r\n  #define DEC_DPD2BIN 1\r\n#else\r\n  #define DEC_DPD2BCD 1\r\n#endif\r\n#include \"decDPD.h\"           // lookup tables\r\n\r\n// The maximum number of decNumberUnits needed for a working copy of\r\n// the units array is the ceiling of digits/DECDPUN, where digits is\r\n// the maximum number of digits in any of the formats for which this\r\n// is used.  decimal128.h must not be included in this module, so, as\r\n// a very special case, that number is defined as a literal here.\r\n#define DECMAX754   34\r\n#define DECMAXUNITS ((DECMAX754+DECDPUN-1)/DECDPUN)\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* Combination field lookup tables (uInts to save measurable work)    */\r\n/*                                                                    */\r\n/*      COMBEXP - 2-bit most-significant-bits of exponent             */\r\n/*                [11 if an Infinity or NaN]                          */\r\n/*      COMBMSD - 4-bit most-significant-digit                        */\r\n/*                [0=Infinity, 1=NaN if COMBEXP=11]                   */\r\n/*                                                                    */\r\n/* Both are indexed by the 5-bit combination field (0-31)             */\r\n/* ------------------------------------------------------------------ */\r\nconst uInt COMBEXP[32]={0, 0, 0, 0, 0, 0, 0, 0,\r\n                        1, 1, 1, 1, 1, 1, 1, 1,\r\n                        2, 2, 2, 2, 2, 2, 2, 2,\r\n                        0, 0, 1, 1, 2, 2, 3, 3};\r\nconst uInt COMBMSD[32]={0, 1, 2, 3, 4, 5, 6, 7,\r\n                        0, 1, 2, 3, 4, 5, 6, 7,\r\n                        0, 1, 2, 3, 4, 5, 6, 7,\r\n                        8, 9, 8, 9, 8, 9, 0, 1};\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decDigitsToDPD -- pack coefficient into DPD form                   */\r\n/*                                                                    */\r\n/*   dn   is the source number (assumed valid, max DECMAX754 digits)  */\r\n/*   targ is 1, 2, or 4-element uInt array, which the caller must     */\r\n/*        have cleared to zeros                                       */\r\n/*   shift is the number of 0 digits to add on the right (normally 0) */\r\n/*                                                                    */\r\n/* The coefficient must be known small enough to fit.  The full       */\r\n/* coefficient is copied, including the leading 'odd' digit.  This    */\r\n/* digit is retrieved and packed into the combination field by the    */\r\n/* caller.                                                            */\r\n/*                                                                    */\r\n/* The target uInts are altered only as necessary to receive the      */\r\n/* digits of the decNumber.  When more than one uInt is needed, they  */\r\n/* are filled from left to right (that is, the uInt at offset 0 will  */\r\n/* end up with the least-significant digits).                         */\r\n/*                                                                    */\r\n/* shift is used for 'fold-down' padding.                             */\r\n/*                                                                    */\r\n/* No error is possible.                                              */\r\n/* ------------------------------------------------------------------ */\r\n#if DECDPUN<=4\r\n// Constant multipliers for divide-by-power-of five using reciprocal\r\n// multiply, after removing powers of 2 by shifting, and final shift\r\n// of 17 [we only need up to **4]\r\nstatic const uInt multies[]={131073, 26215, 5243, 1049, 210};\r\n// QUOT10 -- macro to return the quotient of unit u divided by 10**n\r\n#define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)\r\n#endif\r\nvoid decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) {\r\n  Int  cut;                   // work\r\n  Int  n;                     // output bunch counter\r\n  Int  digits=dn->digits;     // digit countdown\r\n  uInt dpd;                   // densely packed decimal value\r\n  uInt bin;                   // binary value 0-999\r\n  uInt *uout=targ;            // -> current output uInt\r\n  uInt  uoff=0;               // -> current output offset [from right]\r\n  const Unit *inu=dn->lsu;    // -> current input unit\r\n  Unit  uar[DECMAXUNITS];     // working copy of units, iff shifted\r\n  #if DECDPUN!=3              // not fast path\r\n    Unit in;                  // current unit\r\n  #endif\r\n\r\n  if (shift!=0) {             // shift towards most significant required\r\n    // shift the units array to the left by pad digits and copy\r\n    // [this code is a special case of decShiftToMost, which could\r\n    // be used instead if exposed and the array were copied first]\r\n    const Unit *source;                 // ..\r\n    Unit  *target, *first;              // ..\r\n    uInt  next=0;                       // work\r\n\r\n    source=dn->lsu+D2U(digits)-1;       // where msu comes from\r\n    target=uar+D2U(digits)-1+D2U(shift);// where upper part of first cut goes\r\n    cut=DECDPUN-MSUDIGITS(shift);       // where to slice\r\n    if (cut==0) {                       // unit-boundary case\r\n      for (; source>=dn->lsu; source--, target--) *target=*source;\r\n      }\r\n     else {\r\n      first=uar+D2U(digits+shift)-1;    // where msu will end up\r\n      for (; source>=dn->lsu; source--, target--) {\r\n        // split the source Unit and accumulate remainder for next\r\n        #if DECDPUN<=4\r\n          uInt quot=QUOT10(*source, cut);\r\n          uInt rem=*source-quot*DECPOWERS[cut];\r\n          next+=quot;\r\n        #else\r\n          uInt rem=*source%DECPOWERS[cut];\r\n          next+=*source/DECPOWERS[cut];\r\n        #endif\r\n        if (target<=first) *target=(Unit)next; // write to target iff valid\r\n        next=rem*DECPOWERS[DECDPUN-cut];       // save remainder for next Unit\r\n        }\r\n      } // shift-move\r\n    // propagate remainder to one below and clear the rest\r\n    for (; target>=uar; target--) {\r\n      *target=(Unit)next;\r\n      next=0;\r\n      }\r\n    digits+=shift;                 // add count (shift) of zeros added\r\n    inu=uar;                       // use units in working array\r\n    }\r\n\r\n  /* now densely pack the coefficient into DPD declets */\r\n\r\n  #if DECDPUN!=3                   // not fast path\r\n    in=*inu;                       // current unit\r\n    cut=0;                         // at lowest digit\r\n    bin=0;                         // [keep compiler quiet]\r\n  #endif\r\n\r\n  for(n=0; digits>0; n++) {        // each output bunch\r\n    #if DECDPUN==3                 // fast path, 3-at-a-time\r\n      bin=*inu;                    // 3 digits ready for convert\r\n      digits-=3;                   // [may go negative]\r\n      inu++;                       // may need another\r\n\r\n    #else                          // must collect digit-by-digit\r\n      Unit dig;                    // current digit\r\n      Int j;                       // digit-in-declet count\r\n      for (j=0; j<3; j++) {\r\n        #if DECDPUN<=4\r\n          Unit temp=(Unit)((uInt)(in*6554)>>16);\r\n          dig=(Unit)(in-X10(temp));\r\n          in=temp;\r\n        #else\r\n          dig=in%10;\r\n          in=in/10;\r\n        #endif\r\n        if (j==0) bin=dig;\r\n         else if (j==1)  bin+=X10(dig);\r\n         else /* j==2 */ bin+=X100(dig);\r\n        digits--;\r\n        if (digits==0) break;      // [also protects *inu below]\r\n        cut++;\r\n        if (cut==DECDPUN) {inu++; in=*inu; cut=0;}\r\n        }\r\n    #endif\r\n    // here there are 3 digits in bin, or have used all input digits\r\n\r\n    dpd=BIN2DPD[bin];\r\n\r\n    // write declet to uInt array\r\n    *uout|=dpd<<uoff;\r\n    uoff+=10;\r\n    if (uoff<32) continue;         // no uInt boundary cross\r\n    uout++;\r\n    uoff-=32;\r\n    *uout|=dpd>>(10-uoff);         // collect top bits\r\n    } // n declets\r\n  return;\r\n  } // decDigitsToDPD\r\n\r\n/* ------------------------------------------------------------------ */\r\n/* decDigitsFromDPD -- unpack a format's coefficient                  */\r\n/*                                                                    */\r\n/*   dn is the target number, with 7, 16, or 34-digit space.          */\r\n/*   sour is a 1, 2, or 4-element uInt array containing only declets  */\r\n/*   declets is the number of (right-aligned) declets in sour to      */\r\n/*     be processed.  This may be 1 more than the obvious number in   */\r\n/*     a format, as any top digit is prefixed to the coefficient      */\r\n/*     continuation field.  It also may be as small as 1, as the      */\r\n/*     caller may pre-process leading zero declets.                   */\r\n/*                                                                    */\r\n/* When doing the 'extra declet' case care is taken to avoid writing  */\r\n/* extra digits when there are leading zeros, as these could overflow */\r\n/* the units array when DECDPUN is not 3.                             */\r\n/*                                                                    */\r\n/* The target uInts are used only as necessary to process declets     */\r\n/* declets into the decNumber.  When more than one uInt is needed,    */\r\n/* they are used from left to right (that is, the uInt at offset 0    */\r\n/* provides the least-significant digits).                            */\r\n/*                                                                    */\r\n/* dn->digits is set, but not the sign or exponent.                   */\r\n/* No error is possible [the redundant 888 codes are allowed].        */\r\n/* ------------------------------------------------------------------ */\r\nvoid decDigitsFromDPD(decNumber *dn, const uInt *sour, Int declets) {\r\n\r\n  uInt  dpd;                       // collector for 10 bits\r\n  Int   n;                         // counter\r\n  Unit  *uout=dn->lsu;             // -> current output unit\r\n  Unit  *last=uout;                // will be unit containing msd\r\n  const uInt *uin=sour;            // -> current input uInt\r\n  uInt  uoff=0;                    // -> current input offset [from right]\r\n\r\n  #if DECDPUN!=3\r\n  uInt  bcd;                       // BCD result\r\n  uInt  nibble;                    // work\r\n  Unit  out=0;                     // accumulator\r\n  Int   cut=0;                     // power of ten in current unit\r\n  #endif\r\n  #if DECDPUN>4\r\n  uInt const *pow;                 // work\r\n  #endif\r\n\r\n  // Expand the densely-packed integer, right to left\r\n  for (n=declets-1; n>=0; n--) {   // count down declets of 10 bits\r\n    dpd=*uin>>uoff;\r\n    uoff+=10;\r\n    if (uoff>32) {                 // crossed uInt boundary\r\n      uin++;\r\n      uoff-=32;                    // [if using this code for wider, check this]\r\n      dpd|=*uin<<(10-uoff);        // get waiting bits\r\n      }\r\n    dpd&=0x3ff;                    // clear uninteresting bits\r\n\r\n  #if DECDPUN==3\r\n    if (dpd==0) *uout=0;\r\n     else {\r\n      *uout=DPD2BIN[dpd];          // convert 10 bits to binary 0-999\r\n      last=uout;                   // record most significant unit\r\n      }\r\n    uout++;\r\n    } // n\r\n\r\n  #else // DECDPUN!=3\r\n    if (dpd==0) {                  // fastpath [e.g., leading zeros]\r\n      // write out three 0 digits (nibbles); out may have digit(s)\r\n      cut++;\r\n      if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}\r\n      if (n==0) break;             // [as below, works even if MSD=0]\r\n      cut++;\r\n      if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}\r\n      cut++;\r\n      if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}\r\n      continue;\r\n      }\r\n\r\n    bcd=DPD2BCD[dpd];              // convert 10 bits to 12 bits BCD\r\n\r\n    // now accumulate the 3 BCD nibbles into units\r\n    nibble=bcd & 0x00f;\r\n    if (nibble) out=(Unit)(out+nibble*DECPOWERS[cut]);\r\n    cut++;\r\n    if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}\r\n    bcd>>=4;\r\n\r\n    // if this is the last declet and the remaining nibbles in bcd\r\n    // are 00 then process no more nibbles, because this could be\r\n    // the 'odd' MSD declet and writing any more Units would then\r\n    // overflow the unit array\r\n    if (n==0 && !bcd) break;\r\n\r\n    nibble=bcd & 0x00f;\r\n    if (nibble) out=(Unit)(out+nibble*DECPOWERS[cut]);\r\n    cut++;\r\n    if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}\r\n    bcd>>=4;\r\n\r\n    nibble=bcd & 0x00f;\r\n    if (nibble) out=(Unit)(out+nibble*DECPOWERS[cut]);\r\n    cut++;\r\n    if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;}\r\n    } // n\r\n  if (cut!=0) {                         // some more left over\r\n    *uout=out;                          // write out final unit\r\n    if (out) last=uout;                 // and note if non-zero\r\n    }\r\n  #endif\r\n\r\n  // here, last points to the most significant unit with digits;\r\n  // inspect it to get the final digits count -- this is essentially\r\n  // the same code as decGetDigits in decNumber.c\r\n  dn->digits=(last-dn->lsu)*DECDPUN+1;  // floor of digits, plus\r\n                                        // must be at least 1 digit\r\n  #if DECDPUN>1\r\n  if (*last<10) return;                 // common odd digit or 0\r\n  dn->digits++;                         // must be 2 at least\r\n  #if DECDPUN>2\r\n  if (*last<100) return;                // 10-99\r\n  dn->digits++;                         // must be 3 at least\r\n  #if DECDPUN>3\r\n  if (*last<1000) return;               // 100-999\r\n  dn->digits++;                         // must be 4 at least\r\n  #if DECDPUN>4\r\n  for (pow=&DECPOWERS[4]; *last>=*pow; pow++) dn->digits++;\r\n  #endif\r\n  #endif\r\n  #endif\r\n  #endif\r\n  return;\r\n  } //decDigitsFromDPD\r\n"
  },
  {
    "path": "vendor/decNumber/decimal64.h",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal 64-bit format module header                                */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2000, 2005.  All rights reserved.   */\r\n/*                                                                    */\r\n/* This software is made available under the terms of the             */\r\n/* ICU License -- ICU 1.8.1 and later.                                */\r\n/*                                                                    */\r\n/* The description and User's Guide (\"The decNumber C Library\") for   */\r\n/* this software is called decNumber.pdf.  This document is           */\r\n/* available, together with arithmetic and format specifications,     */\r\n/* testcases, and Web links, on the General Decimal Arithmetic page.  */\r\n/*                                                                    */\r\n/* Please send comments, suggestions, and corrections to the author:  */\r\n/*   mfc@uk.ibm.com                                                   */\r\n/*   Mike Cowlishaw, IBM Fellow                                       */\r\n/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */\r\n/* ------------------------------------------------------------------ */\r\n\r\n#if !defined(DECIMAL64)\r\n  #define DECIMAL64\r\n  #define DEC64NAME     \"decimal64\"                   /* Short name   */\r\n  #define DEC64FULLNAME \"Decimal 64-bit Number\"       /* Verbose name */\r\n  #define DEC64AUTHOR   \"Mike Cowlishaw\"              /* Who to blame */\r\n\r\n\r\n  /* parameters for decimal64s                                        */\r\n  #define DECIMAL64_Bytes  8            /* length                     */\r\n  #define DECIMAL64_Pmax   16           /* maximum precision (digits) */\r\n  #define DECIMAL64_Emax   384          /* maximum adjusted exponent  */\r\n  #define DECIMAL64_Emin  -383          /* minimum adjusted exponent  */\r\n  #define DECIMAL64_Bias   398          /* bias for the exponent      */\r\n  #define DECIMAL64_String 24           /* maximum string length, +1  */\r\n  #define DECIMAL64_EconL  8            /* exp. continuation length   */\r\n  /* highest biased exponent (Elimit-1)                               */\r\n  #define DECIMAL64_Ehigh  (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1)\r\n\r\n  /* check enough digits, if pre-defined                              */\r\n  #if defined(DECNUMDIGITS)\r\n    #if (DECNUMDIGITS<DECIMAL64_Pmax)\r\n      #error decimal64.h needs pre-defined DECNUMDIGITS>=16 for safe use\r\n    #endif\r\n  #endif\r\n\r\n\r\n  #ifndef DECNUMDIGITS\r\n    #define DECNUMDIGITS DECIMAL64_Pmax /* size if not already defined*/\r\n  #endif\r\n  #ifndef DECNUMBER\r\n    #include \"decNumber.h\"              /* context and number library */\r\n  #endif\r\n\r\n  /* Decimal 64-bit type, accessible by bytes                         */\r\n  typedef struct {\r\n    uint8_t bytes[DECIMAL64_Bytes];     /* decimal64: 1, 5, 8, 50 bits*/\r\n    } decimal64;\r\n\r\n  /* special values [top byte excluding sign bit; last two bits are   */\r\n  /* don't-care for Infinity on input, last bit don't-care for NaN]   */\r\n  #if !defined(DECIMAL_NaN)\r\n    #define DECIMAL_NaN     0x7c        /* 0 11111 00 NaN             */\r\n    #define DECIMAL_sNaN    0x7e        /* 0 11111 10 sNaN            */\r\n    #define DECIMAL_Inf     0x78        /* 0 11110 00 Infinity        */\r\n  #endif\r\n\r\n  /* ---------------------------------------------------------------- */\r\n  /* Routines                                                         */\r\n  /* ---------------------------------------------------------------- */\r\n  /* String conversions                                               */\r\n  decimal64 * decimal64FromString(decimal64 *, const char *, decContext *);\r\n  char * decimal64ToString(const decimal64 *, char *);\r\n  char * decimal64ToEngString(const decimal64 *, char *);\r\n\r\n  /* decNumber conversions                                            */\r\n  decimal64 * decimal64FromNumber(decimal64 *, const decNumber *,\r\n                                  decContext *);\r\n  decNumber * decimal64ToNumber(const decimal64 *, decNumber *);\r\n\r\n  /* Format-dependent utilities                                       */\r\n  uint32_t    decimal64IsCanonical(const decimal64 *);\r\n  decimal64 * decimal64Canonical(decimal64 *, const decimal64 *);\r\n\r\n#endif\r\n"
  },
  {
    "path": "vendor/decNumber/example1.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Number Library Demonstration program                       */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2001, 2007.  All rights reserved.   */\r\n/* ----------------------------------------------------------------+- */\r\n/*                                                 right margin -->|  */\r\n\r\n// example1.c -- convert the first two argument words to decNumber,\r\n// add them together, and display the result\r\n\r\n#define  DECNUMDIGITS 34           // work with up to 34 digits\r\n#include \"decNumber.h\"             // base number library\r\n#include <stdio.h>                 // for printf\r\n\r\nint main(int argc, char *argv[]) {\r\n  decNumber a, b;                  // working numbers\r\n  decContext set;                  // working context\r\n  char string[DECNUMDIGITS+14];    // conversion buffer\r\n\r\n  decContextTestEndian(0);         // warn if DECLITEND is wrong\r\n\r\n  if (argc<3) {                    // not enough words\r\n    printf(\"Please supply two numbers to add.\\n\");\r\n    return 1;\r\n    }\r\n  decContextDefault(&set, DEC_INIT_BASE); // initialize\r\n  set.traps=0;                     // no traps, thank you\r\n  set.digits=DECNUMDIGITS;         // set precision\r\n\r\n  decNumberFromString(&a, argv[1], &set);\r\n  decNumberFromString(&b, argv[2], &set);\r\n\r\n  decNumberAdd(&a, &a, &b, &set);            // a=a+b\r\n  decNumberToString(&a, string);\r\n\r\n  printf(\"%s + %s => %s\\n\", argv[1], argv[2], string);\r\n  return 0;\r\n  } // main\r\n"
  },
  {
    "path": "vendor/decNumber/example2.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Number Library Demonstration program                       */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2001.  All rights reserved.         */\r\n/* ----------------------------------------------------------------+- */\r\n/*                                                 right margin -->|  */\r\n\r\n// example2.c -- calculate compound interest\r\n// Arguments are investment, rate (%), and years\r\n\r\n#define  DECNUMDIGITS 38           // work with up to 38 digits\r\n#include \"decNumber.h\"             // base number library\r\n#include <stdio.h>                 // for printf\r\n\r\nint main(int argc, char *argv[]) {\r\n  int need=3;\r\n  if (argc<need+1) {               // not enough words\r\n    printf(\"Please supply %d number(s).\\n\", need);\r\n    return 1;\r\n    }\r\n\r\n  { // excerpt for User's Guide starts here--------------------------|\r\n  decNumber one, mtwo, hundred;                   // constants\r\n  decNumber start, rate, years;                   // parameters\r\n  decNumber total;                                // result\r\n  decContext set;                                 // working context\r\n  char string[DECNUMDIGITS+14];                   // conversion buffer\r\n\r\n  decContextDefault(&set, DEC_INIT_BASE);         // initialize\r\n  set.traps=0;                                    // no traps\r\n  set.digits=25;                                  // precision 25\r\n  decNumberFromString(&one,       \"1\", &set);     // set constants\r\n  decNumberFromString(&mtwo,     \"-2\", &set);\r\n  decNumberFromString(&hundred, \"100\", &set);\r\n\r\n  decNumberFromString(&start, argv[1], &set);     // parameter words\r\n  decNumberFromString(&rate,  argv[2], &set);\r\n  decNumberFromString(&years, argv[3], &set);\r\n\r\n  decNumberDivide(&rate, &rate, &hundred, &set);  // rate=rate/100\r\n  decNumberAdd(&rate, &rate, &one, &set);         // rate=rate+1\r\n  decNumberPower(&rate, &rate, &years, &set);     // rate=rate^years\r\n  decNumberMultiply(&total, &rate, &start, &set); // total=rate*start\r\n  decNumberRescale(&total, &total, &mtwo, &set);  // two digits please\r\n\r\n  decNumberToString(&total, string);\r\n  printf(\"%s at %s%% for %s years => %s\\n\",\r\n         argv[1], argv[2], argv[3], string);\r\n\r\n  } //---------------------------------------------------------------|\r\n  return 0;\r\n  } // main\r\n"
  },
  {
    "path": "vendor/decNumber/example3.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Number Library Demonstration program                       */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2001.  All rights reserved.         */\r\n/* ----------------------------------------------------------------+- */\r\n/*                                                 right margin -->|  */\r\n\r\n// example3.c -- calculate compound interest, passive checking\r\n// Arguments are investment, rate (%), and years\r\n\r\n#define  DECNUMDIGITS 38           // work with up to 38 digits\r\n#include \"decNumber.h\"             // base number library\r\n#include <stdio.h>                 // for printf\r\n\r\nint main(int argc, char *argv[]) {\r\n  int need=3;\r\n  if (argc<need+1) {               // not enough words\r\n    printf(\"Please supply %d number(s).\\n\", need);\r\n    return 1;\r\n    }\r\n\r\n  { // start of Example 2 segment\r\n  decNumber one, mtwo, hundred;                   // constants\r\n  decNumber start, rate, years;                   // parameters\r\n  decNumber total;                                // result\r\n  decContext set;                                 // working context\r\n  char string[DECNUMDIGITS+14];                   // conversion buffer\r\n\r\n  decContextDefault(&set, DEC_INIT_BASE);         // initialize\r\n  set.traps=0;                                    // no traps\r\n  set.digits=25;                                  // precision 25\r\n  decNumberFromString(&one,       \"1\", &set);     // set constants\r\n  decNumberFromString(&mtwo,     \"-2\", &set);\r\n  decNumberFromString(&hundred, \"100\", &set);\r\n\r\n// [snip...\r\n  decNumberFromString(&start, argv[1], &set);     // parameter words\r\n  decNumberFromString(&rate,  argv[2], &set);\r\n  decNumberFromString(&years, argv[3], &set);\r\n  if (set.status & DEC_Errors) {\r\n    printf(\"An input argument word was invalid [%s]\\n\",\r\n           decContextStatusToString(&set));\r\n    return 1;\r\n    }\r\n  decNumberDivide(&rate, &rate, &hundred, &set);  // rate=rate/100\r\n  decNumberAdd(&rate, &rate, &one, &set);         // rate=rate+1\r\n  decNumberPower(&rate, &rate, &years, &set);     // rate=rate^years\r\n  decNumberMultiply(&total, &rate, &start, &set); // total=rate*start\r\n  decNumberRescale(&total, &total, &mtwo, &set);  // two digits please\r\n  if (set.status & DEC_Errors) {\r\n    set.status &= DEC_Errors;                     // keep only errors\r\n    printf(\"Result could not be calculated [%s]\\n\",\r\n           decContextStatusToString(&set));\r\n    return 1;\r\n    }\r\n// ...snip]\r\n\r\n  decNumberToString(&total, string);\r\n  printf(\"%s at %s%% for %s years => %s\\n\",\r\n         argv[1], argv[2], argv[3], string);\r\n\r\n  } //---------------------------------------------------------------|\r\n  return 0;\r\n  } // main\r\n"
  },
  {
    "path": "vendor/decNumber/example4.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Number Library Demonstration program                       */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2001.  All rights reserved.         */\r\n/* ----------------------------------------------------------------+- */\r\n/*                                                 right margin -->|  */\r\n\r\n// example4.c -- add two numbers, active error handling\r\n// Arguments are two numbers\r\n\r\n#define  DECNUMDIGITS 38           // work with up to 38 digits\r\n#include \"decNumber.h\"             // base number library\r\n#include <stdio.h>                 // for printf\r\n\r\n// [snip...\r\n#include <signal.h>                // signal handling\r\n#include <setjmp.h>                // setjmp/longjmp\r\n\r\njmp_buf preserve;                  // stack snapshot\r\n\r\nvoid signalHandler(int);           // prototype for GCC\r\nvoid signalHandler(int sig) {\r\n  signal(SIGFPE, signalHandler);   // re-enable\r\n  longjmp(preserve, sig);          // branch to preserved point\r\n  }\r\n// ...snip]\r\nint main(int argc, char *argv[]) {\r\n  decNumber a, b;                  // working numbers\r\n  decContext set;                  // working context\r\n  char string[DECNUMDIGITS+14];    // conversion buffer\r\n  int value;                       // work variable\r\n\r\n  if (argc<3) {                    // not enough words\r\n    printf(\"Please supply two numbers to add.\\n\");\r\n    return 1;\r\n    }\r\n  decContextDefault(&set, DEC_INIT_BASE);    // initialize\r\n\r\n// [snip...\r\n  signal(SIGFPE, signalHandler);   // set up signal handler\r\n  value=setjmp(preserve);          // preserve and test environment\r\n  if (value) {                     // (non-0 after longjmp)\r\n    set.status &= DEC_Errors;      // keep only errors\r\n    printf(\"Signal trapped [%s].\\n\", decContextStatusToString(&set));\r\n    return 1;\r\n    }\r\n// ...snip]\r\n\r\n// [change from Example 1, here]\r\n  // leave traps enabled\r\n  set.digits=DECNUMDIGITS;         // set precision\r\n\r\n  decNumberFromString(&a, argv[1], &set);\r\n  decNumberFromString(&b, argv[2], &set);\r\n\r\n  decNumberAdd(&a, &a, &b, &set);            // A=A+B\r\n  decNumberToString(&a, string);\r\n\r\n  printf(\"%s + %s => %s\\n\", argv[1], argv[2], string);\r\n  return 0;\r\n  } // main\r\n"
  },
  {
    "path": "vendor/decNumber/example5.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Number Library Demonstration program                       */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2001, 2007.  All rights reserved.   */\r\n/* ----------------------------------------------------------------+- */\r\n/*                                                 right margin -->|  */\r\n\r\n// example5.c -- decimal64 conversions\r\n\r\n#include \"decimal64.h\"             // decimal64 and decNumber library\r\n#include <stdio.h>                 // for (s)printf\r\n\r\nint main(int argc, char *argv[]) {\r\n  decimal64 a;                     // working decimal64 number\r\n  decNumber d;                     // working number\r\n  decContext set;                  // working context\r\n  char string[DECIMAL64_String];   // number->string buffer\r\n  char hexes[25];                  // decimal64->hex buffer\r\n  int i;                           // counter\r\n\r\n  if (argc<2) {                    // not enough words\r\n    printf(\"Please supply a number.\\n\");\r\n    return 1;\r\n    }\r\n  decContextDefault(&set, DEC_INIT_DECIMAL64); // initialize\r\n\r\n  decimal64FromString(&a, argv[1], &set);\r\n  // lay out the decimal64 as eight hexadecimal pairs\r\n  for (i=0; i<8; i++) {\r\n    sprintf(&hexes[i*3], \"%02x \", a.bytes[i]);\r\n    }\r\n  decimal64ToNumber(&a, &d);\r\n  decNumberToString(&d, string);\r\n  printf(\"%s => %s=> %s\\n\", argv[1], hexes, string);\r\n  return 0;\r\n  } // main\r\n"
  },
  {
    "path": "vendor/decNumber/example6.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Number Library Demonstration program                       */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2001.  All rights reserved.         */\r\n/* ----------------------------------------------------------------+- */\r\n/*                                                 right margin -->|  */\r\n\r\n// example6.c -- calculate compound interest, using Packed Decimal\r\n// Values are investment, rate (%), and years\r\n\r\n#include \"decPacked.h\"             // base number library\r\n#include <stdio.h>                 // for printf\r\n\r\nint main(int argc, char *argv[]) {\r\n  { // excerpt for User's Guide starts here--------------------------|\r\n  decNumber one, mtwo, hundred;                   // constants\r\n  decNumber start, rate, years;                   // parameters\r\n  decNumber total;                                // result\r\n  decContext set;                                 // working context\r\n\r\n  uint8_t startpack[]={0x01, 0x00, 0x00, 0x0C};   // investment=100000\r\n  int32_t startscale=0;\r\n  uint8_t ratepack[]={0x06, 0x5C};                // rate=6.5%\r\n  int32_t ratescale=1;\r\n  uint8_t yearspack[]={0x02, 0x0C};               // years=20\r\n  int32_t yearsscale=0;\r\n  uint8_t respack[16];                            // result, packed\r\n  int32_t resscale;                               // ..\r\n  char  hexes[49];                                // for packed->hex\r\n  int   i;                                        // counter\r\n\r\n  if (argc<0) printf(\"%s\", argv[1]);              // noop for warning\r\n\r\n  decContextDefault(&set, DEC_INIT_BASE);         // initialize\r\n  set.traps=0;                                    // no traps\r\n  set.digits=25;                                  // precision 25\r\n  decNumberFromString(&one,       \"1\", &set);     // set constants\r\n  decNumberFromString(&mtwo,     \"-2\", &set);\r\n  decNumberFromString(&hundred, \"100\", &set);\r\n\r\n  decPackedToNumber(startpack, sizeof(startpack), &startscale, &start);\r\n  decPackedToNumber(ratepack,  sizeof(ratepack),  &ratescale,  &rate);\r\n  decPackedToNumber(yearspack, sizeof(yearspack), &yearsscale, &years);\r\n\r\n  decNumberDivide(&rate, &rate, &hundred, &set);  // rate=rate/100\r\n  decNumberAdd(&rate, &rate, &one, &set);         // rate=rate+1\r\n  decNumberPower(&rate, &rate, &years, &set);     // rate=rate^years\r\n  decNumberMultiply(&total, &rate, &start, &set); // total=rate*start\r\n  decNumberRescale(&total, &total, &mtwo, &set);  // two digits please\r\n\r\n  decPackedFromNumber(respack, sizeof(respack), &resscale, &total);\r\n\r\n  // lay out the total as sixteen hexadecimal pairs\r\n  for (i=0; i<16; i++) {\r\n    sprintf(&hexes[i*3], \"%02x \", respack[i]);\r\n    }\r\n  printf(\"Result: %s (scale=%ld)\\n\", hexes, (long int)resscale);\r\n\r\n  } //---------------------------------------------------------------|\r\n  return 0;\r\n  } // main\r\n"
  },
  {
    "path": "vendor/decNumber/example7.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Number Library Demonstration program                       */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2001, 2008.  All rights reserved.   */\r\n/* ----------------------------------------------------------------+- */\r\n/*                                                 right margin -->|  */\r\n\r\n// example7.c -- using decQuad to add two numbers together\r\n\r\n// compile: example7.c decContext.c decQuad.c\r\n\r\n#include \"decQuad.h\"               // decQuad library\r\n#include <stdio.h>                 // for printf\r\n\r\nint main(int argc, char *argv[]) {\r\n  decQuad a, b;                    // working decQuads\r\n  decContext set;                  // working context\r\n  char string[DECQUAD_String];     // number->string buffer\r\n\r\n  decContextTestEndian(0);         // warn if DECLITEND is wrong\r\n\r\n  if (argc<3) {                    // not enough words\r\n    printf(\"Please supply two numbers to add.\\n\");\r\n    return 1;\r\n    }\r\n  decContextDefault(&set, DEC_INIT_DECQUAD); // initialize\r\n\r\n  decQuadFromString(&a, argv[1], &set);\r\n  decQuadFromString(&b, argv[2], &set);\r\n  decQuadAdd(&a, &a, &b, &set);    // a=a+b\r\n  decQuadToString(&a, string);\r\n\r\n  printf(\"%s + %s => %s\\n\", argv[1], argv[2], string);\r\n  return 0;\r\n  } // main\r\n"
  },
  {
    "path": "vendor/decNumber/example8.c",
    "content": "/* ------------------------------------------------------------------ */\r\n/* Decimal Number Library Demonstration program                       */\r\n/* ------------------------------------------------------------------ */\r\n/* Copyright (c) IBM Corporation, 2001, 2007.  All rights reserved.   */\r\n/* ----------------------------------------------------------------+- */\r\n/*                                                 right margin -->|  */\r\n\r\n// example8.c -- using decQuad with the decNumber module\r\n\r\n// compile: example8.c decContext.c decQuad.c\r\n//     and: decNumber.c decimal128.c decimal64.c\r\n\r\n#include \"decQuad.h\"               // decQuad library\r\n#include \"decimal128.h\"            // interface to decNumber\r\n#include <stdio.h>                 // for printf\r\n\r\nint main(int argc, char *argv[]) {\r\n  decQuad a;                       // working decQuad\r\n  decNumber numa, numb;            // working decNumbers\r\n  decContext set;                  // working context\r\n  char string[DECQUAD_String];     // number->string buffer\r\n\r\n  if (argc<3) {                    // not enough words\r\n    printf(\"Please supply two numbers for power(2*a, b).\\n\");\r\n    return 1;\r\n    }\r\n  decContextDefault(&set, DEC_INIT_DECQUAD); // initialize\r\n\r\n  decQuadFromString(&a, argv[1], &set);      // get a\r\n  decQuadAdd(&a, &a, &a, &set);              // double a\r\n  decQuadToNumber(&a, &numa);                // convert to decNumber\r\n  decNumberFromString(&numb, argv[2], &set);\r\n  decNumberPower(&numa, &numa, &numb, &set); // numa=numa**numb\r\n  decQuadFromNumber(&a, &numa, &set);        // back via a Quad\r\n  decQuadToString(&a, string);               // ..\r\n\r\n  printf(\"power(2*%s, %s) => %s\\n\", argv[1], argv[2], string);\r\n  return 0;\r\n  } // main\r\n"
  },
  {
    "path": "vendor/decNumber/readme.txt",
    "content": "This is the readme.txt for the decNumber package.  It includes\r\ninstructions for compiling and testing the package; please read them.\r\n---------------------------------------------------------------------\r\n\r\ndecNumber is distributed in two forms; as a complete package from\r\nthe International Components for Unicode (ICU) site (under an as-is\r\nlicense), or as a collection of Open Source files from the GCC source\r\nrepository (under the GPL license).\r\n\r\nIf you are using the GCC files, you can obtain the documentation, the\r\nexample files mentioned below, and this readme from the General\r\nDecimal Arithmetic web page -- http://speleotrove.com/decimal/ (the\r\nURL for the open source files is also linked from there).\r\n\r\n\r\nThe ICU package\r\n---------------\r\n\r\nThe ICU package includes the files:\r\n\r\n  *  readme.txt (this file)\r\n\r\n  *  ICU-license.html\r\n\r\n  *  decNumber.pdf (documentation)\r\n\r\n  *  The .c and .h file for each module in the package (see the\r\n     decNumber documentation), together with other included files.\r\n\r\n  *  The .c files for each of the examples (example1.c through\r\n     example8.c).\r\n\r\nThe ICU package is made available under the terms of the ICU License\r\n(ICU 1.8.1 and later) included in the package as ICU-license.html.\r\nYour use of that package indicates your acceptance of the terms and\r\nconditions of that Agreement.\r\n\r\n\r\nTo use and check decNumber\r\n--------------------------\r\n\r\n  Please read the appropriate license and documentation before using\r\n  this package.  If you are upgrading an existing use of decNumber\r\n  (with version <= 3.37) please read the Changes Appendix for later\r\n  versions -- you may need to change the DECLITEND flag.\r\n\r\n  1. Compile and link example1.c, decNumber.c, and decContext.c\r\n     For instance, use:\r\n\r\n       gcc -o example1 example1.c decNumber.c decContext.c\r\n\r\n     Note: If your compiler does not provide stdint.h or if your C\r\n     compiler does not handle line comments (// ...), then see the\r\n     User's Guide section in the documentation for further information\r\n     (including a sample minimal stdint.h).\r\n\r\n     The use of compiler optimization is strongly recommended (e.g.,\r\n     -O3 for GCC or /O2 for Visual Studio).\r\n\r\n  2. Run example1 with two numeric arguments, for example:\r\n\r\n       example1 1.23 1.27\r\n\r\n     this should display:\r\n\r\n       1.23 + 1.27 => 2.50\r\n\r\n  3. Similarly, try the other examples, at will.\r\n\r\n     Examples 2->4 require three files to be compiled, like Example 1.\r\n\r\n     Example 5 requires decimal64.c in addition to the core modules.\r\n\r\n     Example 6 requires decPacked.c in addition to the core modules.\r\n\r\n     Example 7 requires only example7.c decContext.c and decQuad.c\r\n\r\n     Example 8 requires example8.c, decContext.c, and decQuad.c, plus\r\n               decNumber.c, decimal128.c, and decimal64.c (the latter\r\n               for shared tables and code)\r\n\r\n"
  }
]